Advertisement

Dialog Boxes

Started by September 27, 2001 07:47 PM
7 comments, last by Manfrio 23 years, 2 months ago
I''m trying to put a dialog box as a child window inside my main window. And it keeps locking the whole program always, and i have to close with th ctrl+alt+del... But if i set the dialog box as a popup or an overlapped window, it works, but then i can''t do anything in the main window until i close the dialog... So what do i have to do me make a child dialog box to work in the main window? thanx Manfrio
It doesn''t sound like you''re using MFC to do your dialog boxes, so maybe this post will be totally useless. But regardless, say you''ve got some dialog class CMyDialog. Typically what you do to run the dialog is call its DoModal() method...but that''s not what you want, because by definition, modal dialogs lock up the rest of the application until they have been dismissed. However, the Create() member function is supposed to create a mode-less dialog, which would not lock up the application.
I''ve never actually had to do that though, so don''t take this too seriously...
-david
Advertisement
Yeah, i''m using win32...

And i''d created the dialog as a resource and load it with the DialogBox(...,MAKEINTRESOURCE(IDD_DIALOG),...) function.
But as a child window it shouldn''t lock the program up any way.Modal or not... Right?

Manfrio
ops...i forgot to log in...hehe
here goes again:

Yeah, i''m using win32...

And i''d created the dialog as a resource and load it with the DialogBox(...,MAKEINTRESOURCE(IDD_DIALOG),...) function.
But as a child window it shouldn''t lock the program up any way.Modal or not... Right?

Manfrio
> But as a child window it shouldn''t lock the program up any
> way.Modal or not... Right?

I think it''s wrong, child windows lock their parents if they are modal. Try creating a non modal window.
I just stumbled accross this thread and...
I thought the difference between modal and not, was that one locked the whole computer until closed, and the other just the program... I must be wrong though...
Advertisement
Ok...lets put this way: I wanna load a dialog resource that only has a button(ofcourse there is lots of other stuff like a tab control, check boxes,...). It has to be a child window, no border, no tile bar,will be displayed as soon as the main windows loads and won''t be closed. And have to work within the main window allowing to access the menu and others dialogs resouces that i''d like to load the same way...

how do i do that?

Thanx
Manfrio
Use CreateDialog rather than DialogBox. What''s happening is that you''re creating a modal dialog box.

What this means:

Modal dialog boxes take complete control of the program. Under no circumstances can you create another window, or go back to the previous window until this window handle is gone (well, at least most of the time, but we are not going to bother with these). To get back access to the program, or some other window, you will have to destroy the modal windows handle.

Manfrio, to do what you want, the common control library can do most of that. Just create a window using the correct common control. In CreateWindow(Ex), just pass the system class name of the lpClassName parameter. Look in MSDN for more details.

Also, if you want to create a child window without a border, just pass these parameters.

WS_OVERLAPPED|WS_CHILD|WS_VISIBLE
Yeah...just got that from an online book:

Modeless Dialog Boxes

Most of the dialog boxes you will code will be modal dialog boxes. A modal dialog box is on top of all the other windows in the application: the user must deal with the dialog box and then close it before going on to other work. An example of this is the dialog box that comes up when the user chooses File, Open in any Windows application.

A modeless dialog box allows the user to click the underlying application and do some other work and then return to the dialog box. An example of this is the dialog box that comes up when the user chooses Edit, Find in many Windows applications.

Displaying a modeless dialog box is more difficult than displaying a modal one. The dialog box object, the instance of the dialog box class, must be managed carefully. Typically it is created with new and destroyed with delete when the user closes the dialog box with Cancel or OK. You have to override a number of functions within the dialog box class. In short, you should be familiar and comfortable with modal dialog boxes before you attempt to use a modeless dialog box.


But i''m still wanting to load it from a resource file(So many things... wanna control them just with the CASE ID_something: stuff)...

anyway..so should i try something like this:
HWND hDialog = CreateDialog(dialog_instance,MAKEINTRESOURCE(IDD_DIALOG),hwndParent,DialogProc);
?

Manfrio

This topic is closed to new replies.

Advertisement