Results 1 to 7 of 7

Thread: [Resolved] Show window as modal dialog

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Location
    Birmingham, AL
    Posts
    1,276

    Resolved [Resolved] Show window as modal dialog

    Is there a way to display a client window created with CreateWindowEx(...) as a modal dialog, other than calling DialogBox(...)?

    Ex:
    A client window is created with CreateWindowEx and HWND_DESKTOP is specified as the parent. Then, another client is created with CreateWindowEx and the first hWnd is specified as the last's parent. This keeps the child window always on top of the parent but still allows the parent to be manipulated.

    I don't think there is a way other than using a Dialog Box.
    Last edited by wey97; Oct 20th, 2006 at 07:28 AM.

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: Show window as modal dialog

    Sure there is: you just need to emulate DialogBox. In other words, disable the parent window.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Location
    Birmingham, AL
    Posts
    1,276

    Re: Show window as modal dialog

    Quote Originally Posted by CornedBee
    Sure there is: you just need to emulate DialogBox. In other words, disable the parent window.
    Yeah, the closest I've gotten is calling GetClassInfoEx with the #32770 dialog box class and changing the WndProc and Class Name. Find the window styles with Spy++ calling CreateWindowEx with no luck. The window isn't shown.

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: Show window as modal dialog

    Huh? Just call EnableWindow on the parent window handle!

    Also, search http://blogs.msdn.com/oldnewthing/
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Location
    Birmingham, AL
    Posts
    1,276

    Re: Show window as modal dialog

    Quote Originally Posted by CornedBee
    Huh? Just call EnableWindow on the parent window handle!

    Also, search http://blogs.msdn.com/oldnewthing/
    Ok, so calling GetClassInfo to the dialog class was an admittedly bad idea I borrowed.

    You're a lifesaver once again!

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Location
    Birmingham, AL
    Posts
    1,276

    Re: [resolved]Show window as modal dialog

    One more thing. I assume the DialogBox or CreateDialog calls centers the dialog behind the scenes after the call to CreateWindow if the style DS_CENTER is specified. DS_CENTER has no effect if specified in CreateWindow.

    So will I need to do this manually?

  7. #7
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: Show window as modal dialog

    Probably, yeah. DS_CENTER, as the DS prefix says, is a dialog-specific style, so it's a good guess that DialogBox and CreateDialog are responsible for handling it. (Or perhaps the dialog default procedure.)
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

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