Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

peter86

Create a modeless dialogbox

This topic is 5809 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

The dialogbox is created but I can´t see it on the screen. I´ve even tryed to set focus on the dialogbox, without result. Have I missed anything or what´s wrong?
        
HWND InitDialog( HINSTANCE	hInst, 
		 HWND		hWndDlg, 
		 LPCTSTR	lpTemplate, 
		 DLGPROC	lpDialogFunc )
{
	CreateDialog(hInst, lpTemplate, hWndDlg, lpDialogFunc);

	if( !hWndDlg )
	{
		MessageBox(NULL, "Couldn´t create dialogbox!", "Ch2Exc1", MB_ICONSTOP);
		return 0;
	}

	ShowWindow(hWndDlg, SW_SHOW);  // I haven´t missed this one


	return hWndDlg;
}
// And in WinMain()

hWndDialog = InitDialog(hInstance, hWndDialog, MAKEINTRESOURCE(IDD_COLOR), DialogProc);
    
[edited by - peter86 on June 27, 2002 12:12:57 PM]

Share this post


Link to post
Share on other sites
Advertisement
Yes, here´s my message pump:


  
while(1)
{
MSG msg;
if( PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE) )
{
int result = GetMessage(&msg, NULL, 0, 0);
if( !result )
return msg.wParam;

if (!IsWindow(hWndDlg) || !IsDialogMessage(hWndDlg, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
}

Share this post


Link to post
Share on other sites
erm. i''m no expert on the winAPI, but doesn''t this if check explicitely PREVENT dialoge boxes from being pumped?


if (!IsWindow(hWndDlg) || !IsDialogMessage(hWndDlg, &msg)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}



i.e. the !ISDialogMessage part means if this is a DialogMessage neither translate nor dispatch the message.

-me

Share this post


Link to post
Share on other sites
seriously have you tried removing the if block around Translate and DispatchMessage, even if that check is there for good reason? it looks suspiciously guilty.

alternatively if someone could let me know why you could want to restrict dispatching of messages that would be cool too. if only to shut me up

-me

[edited by - Palidine on June 27, 2002 4:37:13 PM]

Share this post


Link to post
Share on other sites
It dosen´t work if I remove the if block either, but if I make it as an modal dialogbox, it work. WM_INITDIALOG is never reached when I make it as an modeless dialog box, why?

[edited by - peter86 on June 27, 2002 4:43:39 PM]

Share this post


Link to post
Share on other sites
The CreateDialog() function returns a handle to the dialog, if successful, but you do not use this (assuming you did not just mistype the code by mistake). Actually it should look like this:

hWndDlg = CreateDialog(hInst, lpTemplate, hParent, lpDialogFunc);

If there''s no parent window simply pass NULL as the parent handle.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!