CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    May 2017
    Posts
    8

    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

  2. #2
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,824

    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)

  3. #3
    Join Date
    May 2017
    Posts
    8

    Re: Child Dialog constraint inside a Window

    Quote Originally Posted by 2kaud View Post
    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

  4. #4
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    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

  5. #5
    Join Date
    May 2017
    Posts
    8

    Re: Child Dialog constraint inside a Window

    Quote Originally Posted by Igor Vartanov View Post
    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.

  6. #6
    Join Date
    May 2017
    Posts
    8

    Re: Child Dialog constraint inside a Window

    Quote Originally Posted by Aidoru View Post
    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

  7. #7
    Join Date
    May 2017
    Posts
    8

    Re: Child Dialog constraint inside a Window

    Quote Originally Posted by Aidoru View Post
    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

  8. #8
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: Child Dialog constraint inside a Window

    Quote Originally Posted by Aidoru View Post
    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

  9. #9
    Join Date
    Nov 2014
    Posts
    37

    Re: Child Dialog constraint inside a Window

    Quote Originally Posted by Igor Vartanov View Post
    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
  •  





Click Here to Expand Forum to Full Width

Featured