Archived

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

drsixstring

Dialog Boxes

Recommended Posts

drsixstring    122
I am currently working on a windows app with GDI graphics. I''m using Visual C++ 6.0. I have created an "about" dialog box but whenever I have it pop up during the program it''s client area is all white and I am unable to move it. I have a feeling it has something to do with my GDI routines running in the parent window, but I have been unable to solve the problem. Any suggestions?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
I assume that you have defined the aboutbox resource with resource id IDD_ABOUT with one OK button with id IDOK

first create a callback function for the dialog
  

BOOL CALLBACK AboutProc(HWND hDlg,UINT iMsg,WPARAM wParam,LPARAM lParam)
{
switch(iMsg)
{
case WM_INITDIALOG:
return TRUE;
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDOK:
EndDialog(hDlg,IDOK);
return TRUE;
default:
break;
}
default:
break;
}
return FALSE;
}


you can then call it using

DialogBox(hInstance,IDD_ABOUT,hwnd,AboutProc);


where hInstance is the program instance
and hwnd is the parent window

Hope this helps

Share this post


Link to post
Share on other sites
drsixstring    122
Right now I just have a basic little dialog box with an OK button and a CANCEL button. I have everything set up correctly (as far as I can tell). This problem is driving me insane. Does anyone else have any ideas?

Share this post


Link to post
Share on other sites
merlin9x9    174
The only reason your dialog box wouldn''t paint itself and wouldn''t respond to move requests is if your app''s message pump weren''t flowing. That could be because you haven''t set it up properly or you have some operation that has blocked it. You mentioned GDI stuff...make sure you''re calling ValidateRect after all of your drawing, otherwise Windows won''t know that your done drawing and it will keep sending paint messages and your app will come to a grinding halt; this could be the thing killing your message pump flow.

Share this post


Link to post
Share on other sites
drsixstring    122
Well I just figured it out everybody. After a lengthy search through the gamedev.net General Programming Forum archives, I came up with this tidbit written last summer by The Senshi:

...a bool is different from a BOOL.

bool == char (i.e, a 1 byte variable)
BOOL == unsigned int (4 byte variable)

Here is my previous Dialog Procedure declaration:

    
bool CALLBACK DialogFunc( HWND hdwnd, UINT message, WPARAM wParam, LPARAM lParam )


Please note the lower-case (and thus incorrect) version of bool. I merely capitalized bool to BOOL and it works perfectly now!

  
BOOL CALLBACK DialogFunc( HWND hdwnd, UINT message, WPARAM wParam, LPARAM lParam )



Thanks for all the help everybody!

Edited by - drsixstring on January 30, 2002 4:12:06 PM

Share this post


Link to post
Share on other sites