Show Dialog (WS_CHILD) but with hidden (SW_HIDE) parent's window
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Thread: Show Dialog (WS_CHILD) but with hidden (SW_HIDE) parent's window

  1. #1
    Join Date
    Apr 2013
    Location
    Prague / Cracow
    Posts
    47

    Show Dialog (WS_CHILD) but with hidden (SW_HIDE) parent's window

    Hey ho..

    Does anyone know how to show a child dialog with a hidden parent (SW_HIDE)?

    I've got window HWND parent .. and now:


    Code:
    HWND child= CreateDialog( GetModuleHandle( 0 ), MAKEINTRESOURCE( IDD_child ), parent, WndProc_child );
    ShowWindow( parent, SW_HIDE );
    I would like to show my child dialog but when i hide my parent, the child would not appear... is there any other way of doing this... ?

    my dialog must be parent's child...


    gracias!
    b

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    11,359

    Re: Show Dialog (WS_CHILD) but with hidden (SW_HIDE) parent's window

    When you hide the parent, change the child's parent hwnd to a visible hwnd in your app. If all other hwnds are also hidden, use the desktop hwnd or NULL. When the true parent becomes visible, change the child's parent hwnd back to it again.

  3. #3
    Join Date
    Apr 2013
    Location
    Prague / Cracow
    Posts
    47

    Re: Show Dialog (WS_CHILD) but with hidden (SW_HIDE) parent's window

    That is good idea, the only one prob here is that the moment i'd change that child's parent hwnd to some other visible hwnd is exactly the moment i would need the access to my "original" parent the most (by GetParent(child)) because i use the information chosen on dialog to properly display information on parent .. (user select enter some info, click ok, dialog closes and parent is displayed) ....so this isn't solution for me really...

    i guess the most effective way here would be only to store my parent's hwnd on child's hwnd by e.g. SetWindowLongPtr .... or anyone has some other idea of showing child of hidden parent?

  4. #4
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    11,359

    Re: Show Dialog (WS_CHILD) but with hidden (SW_HIDE) parent's window

    Quote Originally Posted by berkov View Post
    That is good idea, the only one prob here is that the moment i'd change that child's parent hwnd to some other visible hwnd is exactly the moment i would need the access to my "original" parent the most (by GetParent(child)) because i use the information chosen on dialog to properly display information on parent .. (user select enter some info, click ok, dialog closes and parent is displayed) ....so this isn't solution for me really...
    Sure it is.

    Quote Originally Posted by berkov View Post
    i guess the most effective way here would be only to store my parent's hwnd on child's hwnd by e.g. SetWindowLongPtr .... or anyone has some other idea of showing child of hidden parent?
    Yep, if you need the parent window in the child, have the child save it off when it gets created. SetWindowLongPtr is a reasonable approach.

  5. #5
    ovidiucucu's Avatar
    ovidiucucu is offline Moderator/Reviewer Power Poster
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,051

    Re: Show Dialog (WS_CHILD) but with hidden (SW_HIDE) parent's window

    Quote Originally Posted by berkov View Post
    Does anyone know how to show a child dialog with a hidden parent (SW_HIDE)?
    [...]
    Short, neat and clear, the answer is: NO WAY.

    Have a look at these FAQs:


    Both child and owned windows are hidden when the parent or owner is hidden.
    Ovidiu Cucu
    "When in Rome, do as Romans do."
    Visit: Microsoft Virtual Academy
    Follow: https://twitter.com/#!/ovidiucucu
    My blog: http://codexpert.ro/blog/author/ovidiu-cucu/

  6. #6
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    11,359

    Re: Show Dialog (WS_CHILD) but with hidden (SW_HIDE) parent's window

    Yes, I was thinking owned.

  7. #7
    Join Date
    Apr 2013
    Location
    Prague / Cracow
    Posts
    47

    Re: Show Dialog (WS_CHILD) but with hidden (SW_HIDE) parent's window

    Gents,

    thanks a lot. I was just hoping that there's some trick for this but i guess SetWindowLongPtr is not so bad idea at the end.

    thanks again!
    SOLVED.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center