Advertisement

Ctl3d in dialog boxes

Started by March 13, 2000 04:30 PM
4 comments, last by rotud 24 years, 9 months ago
This is probably not the right place to ask this question, but it has been bothering me for a while. At the beginning of my DirectX 7 based game, I want to have a dialog box. I made a dialog box resource(using Visual C++ 6), making sure to check the "3D Look" checkbox, and I use the DialogBox() function to use it. However, it is white, non 3d, and cannot be moved or resized. The controls within it, however, work properly. Why isn''t it 3D? Am I doing something wrong?
There isn''t enough information there really...is the source closed or could I see it - give my 5 mins with VC++6 and your source and i''m sure I could fix it
Advertisement
It turns out that the dialog was in fact 3D, but the dialog box color was white, not the default light-gray color. I did manage to fix the problem by intercepting the WM_CTLCOLORDLG message in the DialogProc callback function and returning GetStockObject(LTGRAY_BRUSH). However, I have seen numerous programs that use dialog boxes, and they do not have to intercept that message. Here are parts of my source:

LRESULT CALLBACK MainDialogProc(HWND hDlg, UINT iMsg, WPARAM wParam, LPARAM lParam)
{
switch (iMsg)
{
case WM_CTLCOLORDLG:
{
return (LRESULT)(HBRUSH)GetStockObject(LTGRAY_BRUSH);
}
case WM_INITDIALOG:
{
return true;
}
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDOK:
EndDialog(hDlg, TRUE);
return true;
}
return false;
}

in winmain...

DialogBox(hinst, MAKEINTRESOURCE(IDD_MAIN), hwnd, (DLGPROC)MainDialogProc);

Why is it necessary to manually set the color to Light Gray?
Hmmmm - thats a weird one - i''ve never even heard of a problem like that before, let alone experienced it myself.
I have come up with a very interesting conclusion: When writing the Dialog Box Callback function, it looks something like this:

bool CALLBACK MainDialogProc(HWND hDlg, UINT iMsg, WPARAM wParam, LPARAM lParam);

Note the bool return value at the beggining of the line. If it is written in lowercase, the dialog box will appear white, non 3d, and will not be able to be moved or resized. If I spell it as BOOL in all caps, it will work like a normal dialog box. Any idea why that makes a difference?
The only thing I can think of is that "bool" is 1 byte, while "BOOL" is a typedef for an int (I''m pretty sure) so I suppose Windows could be set up so that if the dialog proc returns 1 byte, it will not be 3d, and if it returns an integer, it will be 3d. That''s weird, but it''s all I can think of...

------------------------------
Jonathan Little
invader@hushmail.com
http://www.crosswinds.net/~uselessknowledge

This topic is closed to new replies.

Advertisement