Sign in to follow this  

multi dialogs in win32

This topic is 4837 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

hi im trying to create child dialogs to my main window which is also a dialog. the child dialog is WS_CHILD and the main is WS_OVERLOADED. and when i call DialogBox() in the main dialog, the main and the child dialogs are getting mixed and i cant use the program anymore (everything stuck). i think it because the child window uses the window handle of the main window, heres my code:
				case IDC_BUTTON6:
					{
					  DialogBox(hInst, (LPCTSTR)IDD_DIALOG4, h, (DLGPROC)Nick);
					  break;
					}
h is the GetActiveWindow(); both dialogs uses IDC_EDIT1 (same id, different meaning and window handles), so the text i wanted to print in IDC_EDIT1 of the child window i see it in the IDC_EDIT1 of the main window.. how can i ride of this mixing? thanks, amir. edit: anyone? (i found that people who post this question also have to ask "anyone?" so somebody will answer..)

Share this post


Link to post
Share on other sites
Don't use that WS_CHILD style. That is for windows which are inside the client area of another window (like a tab in a tab control), as you are experiencing. The reason that everything gets stuck is that the DialogBox function disables the parent window, which automatically disables that child window too. So for WS_CHILD windows you should always use the CreateDialog function.

But I don't think that's what you want to do. You just have to choose a different style than WS_CHILD.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
- Use CreateDialogParam to create modeless child dialog box
- As Window style of your child windows use WS_CHILD
- As Window style of your main window use WS_CLIPCHILDREN, WS_CLIPSIBLINGS
- Is MDI possible with your project? If yes, use it.
- Take a look at the window message WM_CHILDACTIVATE

Should be all.

Regards,
André

Share this post


Link to post
Share on other sites
@Evil Steve
it doesn't work
@Quasar3D
using different style quits automatically (the main window (dialog) is overlapped, not a child)
@Anonymous(?)

WS_CLIPCHILDREN - using this option makes my group box to render not currectly (it doesn't re-render in the group box pixels), and even when i use this option it still doesn't work..

CreateDialogParam - i have to put lParam in the last parameter, right?

MDI - i dont know what is it

WM_CHILDACTIVATE - what i have to do with this? "return 1;" only? i put that in both dialogs and no result..

by the way, now i cant see the child window (its hidden) but the child window's DLGPROC still work (on the main dialog window handle)

any suggests?

Share this post


Link to post
Share on other sites
anyone?
i tried to CreateDialog w/ GetDesktopWindow() as the parent hwnd, but when i activate the new child dialog it quits automatically with no errors/warnings
i hope it will be my last app that uses child dialogs..

Share this post


Link to post
Share on other sites
I agree with Quasar3D - remove the WS_CHILD style from the second dialog and make it an OverLapped or Popup dialog, not a Child dialog.

I think you're confusing child windows with owned windows. Both require a parent window handle, but a child window exists within client area of the parent, an owned window can exist anywhere but will be hidden when the parent is minimised.

Skizz

Share this post


Link to post
Share on other sites
i tried, it quits automatically
or, when i use SetActiveWindow() in the "child" dlgproc, it set the "child" as the active window and then the other dialog as the active one in a loop until it quits automatically...
its because the other dialog's dlgproc is still running? (if it is, how to disable it?)

Share this post


Link to post
Share on other sites
Do you have a message pump? I don't think you do. I think your main dialog is a modal dialog, i.e. you create it using DialogBox or DialogBoxParam. It's the only thing I can think of that explains your problems.

If that is the case, add a message pump (don't forget the IsDialogMessage call) and make the parent dialog box a modeless dialog, i.e. create using CreateDialog or CreateDialogParam.

Skizz

Share this post


Link to post
Share on other sites
right, it is modal
so i changed it to CreateDialog (instead of DialogBox) and wrote this message pump in the DLGPROC of the main dialog:
int bRet;
while ( (bRet = GetMessage(&msg, NULL, 0, 0)) != 0 )
{
if (bRet == -1 )
{
net.close();
PostQuitMessage(0);
}
else if (!IsWindow(h) || !IsDialogMessage(h, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}

but everytime i use this loop, the program disappear and its process is still running
(i tried to use ShowWindow(h,SW_SHOW), but no result)
i wrote (or copied) it right?
today i lern what is a message pump (i didn't knew its called like that) so im not sure if i used it right..

by the way, will it be better if i'll post my code, or its not necessary anymore? its just night here so i'll post it tomorrow if its necessary

Share this post


Link to post
Share on other sites
You should really call IsDialogMessage for each dialog being displayed.
But, that loop looks fine, so you'll need to post up some more code - the DlgProc, the dialog creation and the RC file.

Skizz

Share this post


Link to post
Share on other sites

This topic is 4837 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this