Thread: Receiving messages from child of a child.

  1. #1
    Registered User
    Join Date
    Jan 2002
    Posts
    11

    Receiving messages from child of a child.

    I currently have program that has a couple of child windows:

    MAIN WINDOW - The main app window (HWND g_main)

    TAB WINDOW - Child Window containing Tab controls, parent window is MAIN WINDOW (HWND g_tab)

    STATIC WINDOW - Child Window to hold a button window, parent window is MAIN WINDOW (HWND g_static)

    BUTTON WINDOW - Child Window thats a button, you push it. Parent window is STATIC WINDOW, (id of IDC_BUTTON stated in HMENU)

    Now all the windows appear, line up and all that, but I can't get seem to process any messages from the button in my Window Procedure for WM_COMMAND, I dunno if I am doing something wrong or if WM_COMMAND can't receive messages from the child of a child.

    Any help or suggestions would be appreciated.

  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    You might be better off creating a dialog template to use as the 'page' of your tab cntrl - that way you can process WM_COMMAND messages within its dialog procedure for any controls that you care to place on it. Or you can define your own wnd class (just like a 'main' wnd) and use that in an analagous fashion.

    If you insist on using a child control as a container for other controls then you will have to subclass it ie provide your own wndproc for it. Use SetWindowLong (or SetWindowLongPtr) to set and reset the wndproc. Use CallWindowProc for default msg handling.

  3. #3
    Registered User
    Join Date
    Jan 2002
    Posts
    11
    I originally tried to use dialogs as my pages, but after too many issues with lining them up and what not I went with regular windows, I never thought to subclass them tho, thanks, I'll give it a try.

  4. #4
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    For positioning of dialogs in tab cntrl:

    1. In parent's WM_SIZE position the tab cntrl so that it is the required dimensions - I usually leave an 'edge' of a few pixels all around. If the parent is of fixed size, or the tab cntrl is, then you can just set the tab's size explicitly on creation.

    2. In the WM_INITDIALOG of each dialog box used use MoveWiindow (or SetWindowPos if you prefer) to position the
    dialog within the control.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. CTabCtrl not receiving messages
    By VirtualAce in forum Windows Programming
    Replies: 3
    Last Post: 07-23-2009, 09:37 AM
  2. Replies: 3
    Last Post: 10-15-2008, 09:24 AM
  3. process programming
    By St0rM-MaN in forum Linux Programming
    Replies: 2
    Last Post: 09-15-2007, 07:53 AM
  4. Child Windows and Messages
    By Terrell in forum Windows Programming
    Replies: 10
    Last Post: 09-05-2002, 06:39 AM
  5. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM