Thread: Dialog resources as child windows ...

  1. #1
    Registered User
    Join Date
    Nov 2001
    Posts
    20

    Dialog resources as child windows ...

    Before I start, I'm using MS VC 6.0, and straight C + API only.

    I have created a very basic window - WS_EX_APPWINDOW + WS_OVERLAPPEDWINDOW - no other creation paramerters.

    What i want to do is design, in the resource editor, a panel with various contols on - which I can then display (as a child window) in the main window. Basically it will act as a way for user to enter information when necessary, and be hidden when not needed. This, I reitterate is not a dialog box, but and IDD_FORMVIEW type thing.

    How the hell do I get it displayed on the main window?

    It's called IDD_LEFT_PANEL. I assume I need to use CreateWindowEx with a WS_CHILD parameter. But apart from that I'm stuck. Can anyone point me in the right direction.

    BTW - i've searched everywhere for this.

    Many Regards
    Mark

    (PS - no MFC)

  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Here's one way:

    1. Register your main window with a NULL background brush - this will reduce flicker when redrawing the dialog over the client area.

    2. Ensure your message loop uses IsDialogMessage with the dialog handle to get default keyboard handling (such as TAB) for the dialog.

    3. Create a modeless dialog in the WM_CREATE handler of your main window with either CreateDialog or CreateDialogParam. Store the return value as the handle to your dialog, casting as necessary. The dialog resource should be a 'child' with no border or title bar.

    4. Handle the WM_DESTROY of the main window and use DestroyWindow to kill the dialog, followed by PostQuitMessage to kill the app.

    5. Handle the WM_SIZE msg of your main window and use SetWindowPos with the SWP_SHOWWINDOW flag to position and size the dialog so that it fills the client area of the main wnd.

    6. Handle the WM_COMMAND msg of your dialog and test for 'IDCANCEL' - this will get both the 'ESC' key and any control that you have given that ID to eg. a 'Cancel' button. Use DestroyWindow to kill the parent window (use GetParent to get its handle). This will cause the app to quit as described in 4. above.

    7. If you have any controls on your dialog you should handle the WM_INITDIALOG of the dialog to SetFocus to your preferred 'first' control. If you don't do this the focus will be set to the main window and using the TAB key will not work to 'tab' through the dialog controls.

    Hope that helps.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Script errors - bool unrecognized and struct issues
    By ulillillia in forum Windows Programming
    Replies: 10
    Last Post: 12-18-2006, 04:44 AM
  2. Virtual keys
    By Arkanos in forum Windows Programming
    Replies: 4
    Last Post: 12-12-2005, 10:00 AM
  3. Question..
    By pode in forum Windows Programming
    Replies: 12
    Last Post: 12-19-2004, 07:05 PM
  4. Menu Item Caption - /a for right aligned Accelerator?
    By JasonD in forum Windows Programming
    Replies: 6
    Last Post: 06-25-2003, 11:14 AM
  5. Mingw Dialog Box resources
    By golfinguy4 in forum Windows Programming
    Replies: 3
    Last Post: 07-16-2002, 11:45 PM