• 13
• 18
• 19
• 27
• 10

# Dialog Boxes

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

## Recommended Posts

Hi, I'm having trouble making my dialog box show up. It whows up but it's sort of embedded within a window for some reason. What I mean is that instead of having it's own window so I can move it around, it simply puts all the controls that were in a dialog box, into a the parents' window client area. I'm not using MFC classes . Does anyone know what the problem might be? Thanks

##### Share on other sites
Sounds like you're setting the WS_CHILD style somewhere. Can you post the code where you create the dialog?

##### Share on other sites
Quote:
 Original post by Colin JeanneSounds like you're setting the WS_CHILD style somewhere. Can you post the code where you create the dialog?

Thats what I get, it looks like the Dialog Box is inside the window, but when I took a screenshot of an active window while the dialog was displayed, the software took a screenshot of the dialog box, but it had no frames or borders just white around the controls, that means that it's actually a window, but something is wrong with the style? Also I tried to find FromBorderstyle in the dialog editor (im using VS 2003) but didn't find that property. Maybe something is wrong with the type of a Diolog that I created? (There were 4 categories in the resource manager, I chose the standard dialog).

this is the source for the dialog as created by VS (in .rc file)

[source = cpp]///////////////////////////////////////////////////////////////////////////////// Dialog//IDD_DIALOG1 DIALOGEX 0, 0, 253, 247STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_VISIBLE | WS_CAPTION |WS_THICKFRAMEEXSTYLE WS_EX_OVERLAPPEDWINDOW | WS_EX_TOOLWINDOWCAPTION "Grid Size"FONT 8, "MS Shell Dlg", 400, 0, 0x1BEGINDEFPUSHBUTTON "OK",IDOK,12,226,50,14PUSHBUTTON "Cancel",IDCANCEL,162,226,50,14CONTROL "By Image Size",IDC_RADIO1,"Button",BS_AUTORADIOBUTTON,12,18,60,8LTEXT "___________________________________________________________",IDC_STATIC,6,30,237,8LTEXT "Image Dimensions:",IDC_STATIC,6,48,60,8LTEXT "X:",IDC_STATIC,12,60,8,8EDITTEXT IDC_EDIT2,30,60,30,12,ES_AUTOHSCROLL | ES_NUMBERLTEXT "Y:",IDC_STATIC,12,78,8,8EDITTEXT IDC_EDIT3,30,78,30,12,ES_AUTOHSCROLL | ES_NUMBERLTEXT "Num Images:",IDC_STATIC,78,60,43,8EDITTEXT IDC_EDIT4,126,60,30,12,ES_AUTOHSCROLL | ES_NUMBERCONTROL "Every N Pixels",IDC_RADIO2,"Button",BS_AUTORADIOBUTTON,12,108,60,12LTEXT "___________________________________________________________",IDC_STATIC,6,126,237,8LTEXT "X:",IDC_STATIC,12,144,8,8LTEXT "Y:",IDC_STATIC,12,168,8,8EDITTEXT IDC_EDIT5,30,144,30,12,ES_AUTOHSCROLL | ES_NUMBEREDITTEXT IDC_EDIT6,30,168,30,12,ES_AUTOHSCROLL | ES_NUMBERCONTROL "Inclusive",IDC_CHECK1,"Button",BS_AUTOCHECKBOX |WS_TABSTOP,90,144,44,10CONTROL "1 Pixel Offset",IDC_CHECK2,"Button",BS_AUTOCHECKBOX |WS_TABSTOP,90,168,59,10END

I call it with

case WM_COMMAND:
{
if(LOWORD(wparam == ID_OPTIONS_GRIDSIZE))
if(DialogBox(g_hinst, MAKEINTRESOURCE(IDD_DIALOG1), g_hwnd, MyDialogProc) <= 0)
MessageBox(NULL, 0, "DB Create Failed", MB_OK);
} break;

from inside WinProc()

maybe the hInstance, required by DialogBox() is the wrong one? To get it I declare a global HINSTANCE g_hinst, and say g_hinst = hInstance; on the first line of WinMain()

##### Share on other sites
e-books, e-mule, sonar, maya, rar files... if i were u i'd change that pic quick lol.

##### Share on other sites
Quote:
 Original post by yadangoe-books, e-mule, sonar, maya, rar files... if i were u i'd change that pic quick lol.

nothing imortant, lol

##### Share on other sites
well for one thing your line:

if(LOWORD(wparam == ID_OPTIONS_GRIDSIZE))

should be

if(LOWORD(wparam) == ID_OPTIONS_GRIDSIZE)

and i'd get rid of the WS_EX_TOOLWINDOW extended dialog box style and the WS_OVERLAPPEDWINDOW style as well, plus i'd check your dialog procedure to see if you are doing something funky with the WM_CTLCOLORDLG message (logic errors in your dialog procedure can cause weird painting bugs in your dialog as well). but since u seem to be calling DialogBox correctly, i think ur main problem is with your dialog template, having kind of an odd set of dialog style flags you have there. i would switch to a DIALOG template rather than a DIALOGEX template, get rid of those extended flags, get rid of the FONT line and the DS_FONT flag and see what happens.

##### Share on other sites
Quote:
 Original post by yadangowell for one thing your line:if(LOWORD(wparam == ID_OPTIONS_GRIDSIZE))should beif(LOWORD(wparam) == ID_OPTIONS_GRIDSIZE)and i'd get rid of the WS_EX_TOOLWINDOW extended dialog box style and the WS_OVERLAPPEDWINDOW style as well, plus i'd check your dialog procedure to see if you are doing something funky with the WM_CTLCOLORDLG message (logic errors in your dialog procedure can cause weird painting bugs in your dialog as well). but since u seem to be calling DialogBox correctly, i think ur main problem is with your dialog template, having kind of an odd set of dialog style flags you have there. i would switch to a DIALOG template rather than a DIALOGEX template, get rid of those extended flags, get rid of the FONT line and the DS_FONT flag and see what happens.

K, tried most of the stuff, even created a brand new dialog template with all the default falues, same results, right now I'm pretty sure that my problem lies somewhere in the calling of the actual template, I took a look at an example of a Dialog app, that uses MFC and they do some extra stuff to repaint the box. Are there any examples somewhere that create DBs without MFC?