Results 1 to 4 of 4

Thread: Dialog Resource vs. Window creation

  1. #1
    Sc0rp
    Guest

    Thumbs up Dialog Resource vs. Window creation

    I'm working on some project now, and I'm using dialog-type resources to create the windows for the project.

    Besides the fact that I didn't find a way to create MDI windows (or is just the VB term for it?) using the dialog resource, are there any disadvantages in using the resoucre instead of creating the window using CreateWindow*CreateWindowEx?


    BTW, can anyone instruct me on how to create MDI windows using Win32 API?


    Thanks.

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    It is not possible to create MDI windows using dialog resources. I'm not sure if there are any general disadvantages of dialogs vs. normal windows. After all, they are windows. So you could maybe even create a MDI window out of a dialog resource, but it would require custom code and would not be easier than just creating it from scratch.
    Here's how to create MDI apps, as teached in the Petzold:
    You need to register several window classes: one for the main window and one for each child window. You should choose
    (HBRUSH)(COLOR_APPWORKSPACE + 1)
    as HBRUSH member of the WNDCLASS of the frame window.

    You first create the frame window like you would do with any other window. It is important that you specify the WS_CLIPCHILDREN style. In the window's WM_CREATE handler you create a new window of the class "MDICLIENT". It should have the styles WS_CHILD, WS_VISIBLE and WS_CLIPCHILDREN. The position and size do not matter. You must pass the address of a completly filled out CLIENTCREATESTRUCT as lParam.

    This window is the key to all MDI business. You send messages to it to control the child windows. The most important is WM_MDICREATE, which tells the client to create another child. You pass the address of a MDICREATESTRUCT as lParam.

    These are the main parts of creating a MDI app. For more information, see
    Platform SDK -> User Interface Services -> Windowing -> Multiple Document Interface
    in MSDN.
    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
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Oh, and I forgot, you also need to change your message loop:
    Code:
    while(GetMessage(&msg, NULL, 0, 0) > 0)
    }
      if(!TranslateMDISysAccel(hwndMDIClient, &msg))
      {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
      }
    }

    Also, you don't call DefWindowProc anymore. Call DefFrameProc for the frame window and DefMDIChildProc for the child windows instead. MSDN also lists some messages that must be passed on whether you handle them or not.
    Also there are alternatives (necessary ones in multithreaded apps) to the WM_MDICREATE message: CreateMDIWindow and CreateWindowEx with the WS_EX_MDICHILD extended style.
    Last edited by CornedBee; Dec 15th, 2001 at 08:42 AM.
    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.

  4. #4
    Sc0rp
    Guest

    Thumbs up

    Thanks, that's exactly what I needed!

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