parent window and messages

This is a discussion on parent window and messages within the Windows Programming forums, part of the Platform Specific Boards category; Hi everyone, I needed to group controls in a static control. I used WS_EX_CONTROLPARENT for this and used CreateWindowEx function ...

  1. #1
    Registered User
    Join Date
    Dec 2002
    Posts
    35

    parent window and messages

    Hi everyone,
    I needed to group controls in a static control. I used WS_EX_CONTROLPARENT for this and used CreateWindowEx function for each. Now I have a problem, my controls, buttons, only accepts enter key, pressing space or mouse clicking doesn't get WM_COMMAND messages. I have attached this example, it is a Dev-Cpp v4.7 project. But I think this is not related to compiler.

    Happy new year
    Attached Files Attached Files
    Want to learn? Then try to teach...

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    You set the button to have the static control as its parent...therefore all messages created by the button will go to the static (which is a window in its own right, albeit with a very simple WndProc that is implemented by the system). If you make the following change to youe WM_CREATE handler it will work

    Code:
            case WM_CREATE:
                Label1 = CreateWindowEx(WS_EX_CONTROLPARENT, "static", 
                            "Label1", WS_VISIBLE|WS_CHILD, 
                            12, 17, 361, 165, hWnd, 
                            (HMENU) ID_Label1, hInst, NULL);
                SendMessage(Label1, (UINT) WM_SETFONT,
                            (WPARAM) GetStockObject(DEFAULT_GUI_FONT),
                            (LPARAM) MAKELPARAM(FALSE, 0));
    
                Button1 = CreateWindowEx(0, "Button", "Button1", 
                            WS_VISIBLE|WS_CHILD|BS_PUSHLIKE|WS_TABSTOP, 
                            33, 113, 86, 27, hWnd, 
                            (HMENU) ID_Button1, hInst, NULL);
                SendMessage(Button1, (UINT) WM_SETFONT, 
                            (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 
                            (LPARAM) MAKELPARAM(FALSE, 0));
                break;

  3. #3
    Registered User
    Join Date
    Dec 2002
    Posts
    35
    Thank you Mr. Fordy,

    I have just get your reply. I will try it ASAP. However, I needed to do the "label1" as parent for grouping purpose. Say all controls show or hide over it.

    Now, I subclassed the static, so I can catch space-bar and mouse clicks in new proc. But already needs WM_COMMAND to catch enter keys separately in WndProc (main proc). How can I catch all in subclassed proc?
    Here, in example I created one more subclassed static for test purpose.

    Regards
    Attached Files Attached Files
    Want to learn? Then try to teach...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C or C++
    By AcerN30 in forum Game Programming
    Replies: 41
    Last Post: 05-30-2008, 07:57 PM
  2. Just starting Windows Programming, School me!
    By Shamino in forum Windows Programming
    Replies: 17
    Last Post: 02-22-2008, 08:14 AM
  3. 6 measly errors
    By beene in forum Game Programming
    Replies: 11
    Last Post: 11-14-2006, 11:06 AM
  4. OpenGL Window
    By Morgul in forum Game Programming
    Replies: 1
    Last Post: 05-15-2005, 01:34 PM
  5. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 10:44 AM

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