Solved

Are popup dialog boxes with a console app possible?

Posted on 1998-10-02
1
483 Views
Last Modified: 2013-11-20
I'm wrestling with a programming request to spawn popup dialog boxes from a previously written console program. I not sure if this is possible as console programs can't handle most USER and GDI functions (ie. Windows, brushes, menus, etc.). If you know a way around this, please respond.
0
Comment
Question by:gmacgougan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 8

Accepted Solution

by:
Answers2000 earned 100 total points
ID: 1322873
Yes you can, but you may not be able to use MFC to do it.

In a Win32 console program you can call just about any Windows API call.  For a dialog box you can create one use the Windows API using DialogBox function call.

For the parent window pass NULL or GetFocus()

The main (relevant) difference between Win32 console programs and Win32 GUI programs is you don't have a message loop.  Fortunately if you use DialogBox to create a modal dialog box, Windows includes a message loop which operates while the dialog box is displayed.

You should note that
1. If you use the MFC CDialog and DoModal function to do this it probably won't work as MFC infrastructure for GUI programs won't have been set up (it's okay to use other MFC functions in the same program though for example CString class)

2.  The dialog box you write should use a dialog box CALLBACK function.  You can cut and paste this from one of the SDK samples.

3. For maximum flexibility the main alternative is to create your GUI elements in a separate process compiled as a GUI program.  You main program can then use CreateProcess to invoke them and WaitForSingleObject to wait for these processes to terminate.  If you use this approach you can do just about anything from your console program, though for simply displaying a dialog it isn't necessary

I have seen a number of console programs which pick a file name use a GUI dialog box.  The GetOpenFileName API is used for this, but for the more general case modal dialog boxes created with DialogBox API is quite okay
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question