Thread: child windows of group boxes and static controls

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    6

    Question child windows of group boxes and static controls

    i'm creating a program using a tab control. each tab loads a different static control that contains it's own buttons, text boxes, etc. how do i get the events from a button that is a child of a static box or a group box? i'm not using a dialog box, i'm using a regular window.
    any help would be appreciated.

    alandrums

  2. #2
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    You are looking to tell the control where to send its msg's. This is the wndproc function

    If you created the controls on the fly then you will specify the parents HWND, msg's will be sent to its callback.

    If you registered a WNDCLASS then you will specify the wndproc as a member ie

    WinClassMyApp.lpfnWndProc=(WNDPROC)MyAppsCallback;

    Else each will have its own msg handler loop and callback.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  3. #3
    Registered User
    Join Date
    Sep 2001
    Posts
    6

    Question

    do you have any examples of this? i have petzold book, but it doesn't give an explanation of how to use a callback function for a child window such as a groupbox.
    also, i have another question. i created radio buttons and text boxes as children of my groupbox controls... will the events of these radio buttons and text boxes be sent to their parent (the groupbox) or can a group box do that sort of thing. i pretty much just need to know if it's possible to do it the way i am and if i should be going about it another way. another way that i thought of would be to just create the child window controls as children of my main window and just position them over the tab control and have them all created and destroyed on the fly. right now, i have them as children of a static control and am only creating and destroying the static controls on the fly.

  4. #4
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    If I understand you have a main dlg / window with a TAB ctrl on it.
    You want to change to different sets of ctls as the user changes TAB's.

    Is each set of ctrls the same each time? So if the user clicks the 1st TAB will they always see the same ctrls?

    If so create them as seperate dialogs in the resource editor. Create them on init of the main window with CreateDialog(). You can specify where the msg's are sent with the DLGPROC param.

    the msg loop is
    Code:
    if (FALSE == IsDialogMessage(hDlg, &msg))
    {
            TranslateMessage(&msg) ;
    	DispatchMessage(&msg) ;
    }
    Use ShowWindow() to hide the ones not needed and SetWindowPos() to 'paste' the active dlg over the top of the TAB ctrl. (Find its client rect on the main window / dlg)
    If the TAB ctrl moves then use SetWindowPos() again.
    If the user changes TAB's hide the active dlg and show the new one. ShowWindow()
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Few Questions (Styles, Static Control)
    By Zeusbwr in forum Windows Programming
    Replies: 11
    Last Post: 04-15-2005, 04:13 AM
  2. input/output
    By dogbert234 in forum Windows Programming
    Replies: 11
    Last Post: 01-26-2005, 06:57 AM
  3. how to set the background colour of a static box?
    By Cobras2 in forum Windows Programming
    Replies: 2
    Last Post: 08-01-2002, 04:57 PM
  4. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM
  5. Problem with static text in dialog boxes
    By Clyde in forum Windows Programming
    Replies: 11
    Last Post: 05-28-2002, 12:51 PM