-
May 10th, 2017, 10:52 AM
#1
Child Dialog constraint inside a Window
Hello everyone,
could you please help me to find a good solution to constraint a dialog inside a window? So it move when window move, resize when window resize and so on.
Thank you
-
May 10th, 2017, 11:02 AM
#2
Re: Child Dialog constraint inside a Window
Are you using MFC, WIN32 API or some other framework?
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
May 10th, 2017, 11:42 AM
#3
Re: Child Dialog constraint inside a Window
Originally Posted by 2kaud
Are you using MFC, WIN32 API or some other framework?
I created a dialog in my .dll using createdialogparam and I call it from external program where I have parent window
-
May 10th, 2017, 01:05 PM
#4
Re: Child Dialog constraint inside a Window
No matter what part of process code creates it, a child window moves along with its parent. However, resizing is totally different aspect. Beng resized the parent may resize its child as well, or inform the child using custom message to let the child adapt. Or the child may monitor parent's resizing by installng a hook. The way you go really depends on many other factors, so it's fnally up to you.
Same to "and so on" part.
Last edited by Igor Vartanov; May 10th, 2017 at 01:14 PM.
Best regards,
Igor
-
May 10th, 2017, 02:38 PM
#5
Re: Child Dialog constraint inside a Window
Originally Posted by Igor Vartanov
No matter what part of process code creates it, a child window moves along with its parent. However, resizing is totally different aspect. Beng resized the parent may resize its child as well, or inform the child using custom message to let the child adapt. Or the child may monitor parent's resizing by installng a hook. The way you go really depends on many other factors, so it's fnally up to you.
Same to "and so on" part.
I think the problem is that, I created my dialog as follow:
CreateDialogParam(hModule, MAKEINTRESOURCE(IDD_DIALOG1), parent_Handle, DialogProc, 0);
but when I move parent window (parent_Handle is its hwnd) the dialog doesn't move, like it isn't a child.
-
May 10th, 2017, 06:26 PM
#6
Re: Child Dialog constraint inside a Window
Originally Posted by Aidoru
I think the problem is that, I created my dialog as follow:
CreateDialogParam(hModule, MAKEINTRESOURCE(IDD_DIALOG1), parent_Handle, DialogProc, 0);
but when I move parent window (parent_Handle is its hwnd) the dialog doesn't move, like it isn't a child.
I tried using SetParent to set dialog child of the window, now seems to work (moving parent move child too) but I have big paint problems on dialog, dialog disappear or paint only 1 or 2 controls and the dialog background look like parent window background.
Is there any solution?
Thank you
-
May 10th, 2017, 07:28 PM
#7
Re: Child Dialog constraint inside a Window
Originally Posted by Aidoru
I tried using SetParent to set dialog child of the window, now seems to work (moving parent move child too) but I have big paint problems on dialog, dialog disappear or paint only 1 or 2 controls and the dialog background look like parent window background.
Is there any solution?
Thank you
Solved changing GWL_STYLE of parent window (do you know better solution?).
But finally I don't understand a thing: why if I put window parent handle in CreateDialogParam function I still need SetParent function? Without SetParent can't solve my problem, and if I remove parent window handle from CreateDialogParam function nothing change!
Thank you
-
May 11th, 2017, 04:35 AM
#8
Re: Child Dialog constraint inside a Window
Originally Posted by Aidoru
But finally I don't understand a thing: why if I put window parent handle in CreateDialogParam function I still need SetParent function?
Whether the dialog is to be a child or not is controlled by dialog template styles. Afraid the dialog template IDD_DIALOG1 has no WS_CHILD style, but does have something like WS_POPUP, or thickframe, or overlappedwindow, etc.
Best regards,
Igor
-
May 11th, 2017, 05:18 AM
#9
Re: Child Dialog constraint inside a Window
Originally Posted by Igor Vartanov
Whether the dialog is to be a child or not is controlled by dialog template styles. Afraid the dialog template IDD_DIALOG1 has no WS_CHILD style, but does have something like WS_POPUP, or thickframe, or overlappedwindow, etc.
You do have DS_CONTROL which should work.
James
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|