Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

common dialogs stall

Status
Not open for further replies.

LyMc

Programmer
Jun 3, 2003
84
US
I have an win32 app which places a dialog on the screen - no "main window", just a dialog. If I call any other common control (such as message box or an open dialog) The main dialog loses focus, but the new subdialog never gains it; it remains inert, and the main dialog is likewise dead - I have to kill the program. So what is going wrong with the subdialog?

I include here a part of the main program which shows what I'm doing - there are two dialogs which cycle, but otherwise the main routine is pretty generic. BTW, I'm using VC++ .NET:

#include "stdafx.h"
#include <commctrl.h>
#include &quot;GroundZero.h&quot;
#define MAX_LOADSTRING 100

// Global Variables:
static HWND hDlg = NULL;
HINSTANCE hInst; // current instance
TCHAR szTitle [MAX_LOADSTRING]; // The title bar text
Options opts;

// Forward declarations of functions included in this code module:
LRESULT CALLBACK Wnd1Proc (HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK Wnd2Proc (HWND, UINT, WPARAM, LPARAM);

int APIENTRY _tWinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPTSTR lpCmdLine, int nCmdShow)
{
MSG msg;
HACCEL hAccelTable;

// Initialize global strings
LoadString (hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);

// Perform application initialization:
hInst = hInstance; // Store instance handle in our global variable
hAccelTable = LoadAccelerators (hInstance, (LPCTSTR) IDC_ON_THE_FLOOR);
bool phase = true;
while (true) {
opts.back = false;
if ((hDlg = CreateDialog (hInst, (LPCTSTR) (phase ? IDD_DLG1 : IDD_DLG2),
NULL, (DLGPROC) (phase ? Wnd1Proc : Wnd2Proc))) == NULL) {
ErrBox (MB_OK, &quot;Error creating dialog %d.&quot;, phase);
exit (0);
}
while (GetMessage (&msg, NULL, 0, 0)) {
if (!IsWindow (hDlg) || !IsDialogMessage (hDlg, &msg)) {
if (!TranslateAccelerator (msg.hwnd, hAccelTable, &msg)) {
TranslateMessage (&msg);
DispatchMessage (&msg);
}
}
}
if ((phase && opts.immediate) ||
(!phase && (opts.immediate || !opts.back))) break;
phase = !phase;
}
return (int) msg.wParam;
}


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top