I need to create a console application that has a main() function and pop a modeless dialog, so the console can still work in parallel to the modeless dialog (do other work, like communicating with the modeless dialog).
Whatever i tried, i could only pop a modal dialog. (where the console is in hold till the modal dialog close itself).
When switching to modeless dialog using Create() and ShowWindow() the dialog is displayed without its controls and it freeze / block (you can see the hourglass cursor).
1) I tried to pop the modeless dialog from the main() function:
void main()
{
AfxWinInit(GetModuleHandle(NULL), NULL, GetCommandLine(), SW_SHOW);
TestGUI * gui;
gui = new TestGUI();
gui->Create(TestGUI::IDD);
gui->ShowWindow(SW_SHOW);
// just to see if the modeless dialog responses
Sleep(10000);
}
2) I tried to pop the modeless dialog from the InitInstance() of a CWinApp derived class:
extern int AFXAPI AfxWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine, int nCmdShow);
class MyApp : public CWinApp
{
public:
virtual BOOL InitInstance()
{
gui = new TestGUI();
gui->Create(TestGUI::IDD);
gui->ShowWindow(SW_SHOW);
return TRUE;
}
private:
TestGUI * gui;
};
MyApp my_app;
void main()
{
AfxWinMain(GetModuleHandle(NULL), NULL, GetCommandLine(), SW_SHOW);
// just to see if the modeless dialog responses
Sleep(10000);
}
In all cases the modeless dialog freeze.
I believe this is a one line solution.
Please help.
TNX,
Vertilka