msg loop/child window

This is a discussion on msg loop/child window within the Windows Programming forums, part of the Platform Specific Boards category; Just starting learning the win32 API last night and I was wondering if I wanted to create a child window... ...

  1. #1
    Registered User
    Join Date
    Sep 2008
    Posts
    9

    msg loop/child window

    Just starting learning the win32 API last night and I was wondering if I wanted to create a child window... like the one you'd get if you went to Help->About if I need to create a new class style. That would only be if I wanted to new class style traits for it right? I should be able to use the global variable which has the class name right?

    Basically, what I think I need to do is create a new window, and a new WinProc for that window but I can still use the old window class? If I do that will my message loop in WinMain get the messages coming from that window too?

  2. #2
    Registered User
    Join Date
    Mar 2011
    Posts
    23
    you are right, you only should need a separate class for windows that require different class styles n such, not window styles. However for simple windows like about boxes, you can use a modal dialog box to save a lot of extra code. If using msvs the dialog editor makes it a simple process ).

    DialogBox Function

  3. #3
    Registered User
    Join Date
    Sep 2008
    Posts
    9
    Ok, well I'm trying to create a child window without using .rc just to get to know somethings a bit better. MSDN says

    HWND WINAPI CreateDialog(
    __in_opt HINSTANCE hInstance,
    __in LPCTSTR lpTemplate,
    __in_opt HWND hWndParent,
    __in_opt DLGPROC lpDialogFunc
    );

    Now, if using .rc I could MAKEINTRESOURCE(ID_HABOUT) my the lpTemplate parameter.

    My question is can I create my template some other way? I found structs called DLGTEMPLATE and DLGITEMTEMPLATE but my problem is how to pass them in as LPCTSTR after filling them out.

    Also how do I handle the messages in my message loop?

    After some googling I found

    IsDialogMessage(HWND,MSG)

    Is that all I need to check for in my message loop?

    Does DialogBox() handle the message loop automatically?

  4. #4
    Registered User
    Join Date
    Mar 2011
    Posts
    23
    the message loop is provided by the DialogBox function, if you use CreateDialog ( modeless ) you will be using your own message loop. yes you can create a memory block and put a DLGTEMPLATE first then DLGITEMTEMPLATE members all in one contigious block, then pass the pointer of the block into the template paramater as


    Code:
    CreateDialog( myinst, ( LPDLGTEMPLATE ) myalloc, hwnd, dlgproc );

    Creating a non-resource template has its own advantages, but a waste of time for simple dialogs. an unfinished resource can quickly be loaded, then in the WM_INITDIALOG message, creation of variable controls can be done with a few CreateWindow calls
    Last edited by pYro; 05-12-2011 at 10:12 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Access Function in Child Window From Parent Window
    By Welder in forum Windows Programming
    Replies: 3
    Last Post: 05-20-2008, 03:06 AM
  2. parent window minimizing on child window destruction
    By Yarin in forum Windows Programming
    Replies: 1
    Last Post: 03-02-2008, 08:34 AM
  3. Creating a child window in a parent window
    By vopo in forum Windows Programming
    Replies: 8
    Last Post: 10-06-2007, 04:15 PM
  4. Child window inside child window
    By Magos in forum Windows Programming
    Replies: 13
    Last Post: 04-20-2004, 06:51 AM
  5. Child Window Help
    By beem in forum Windows Programming
    Replies: 1
    Last Post: 03-30-2002, 08:15 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21