Win32 controls inside a groupbox

Started by
4 comments, last by GameDev.net 19 years, 4 months ago
I have a MDI child form with a groupbox control inside, inside the groupbox is a standard button. How do i handle the button click event for this button? Using WM_COMMAND as normal doesnt seem to work and im guessing its because the buttons a child of the groupbox and not of the mdi child window. How do i do this? Thanks
Advertisement
You can set the owner of the button to the dialog where you want to process WM_COMMAND. It should get sent there then.

I'm not sure, but i think PreTranslateMessage might also catch that one.

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

How do you set the parent to be the Groupbox and the owner to be the mdi child?
SetParent() is what you want.
In MFC you use SetOwner to set the (virtual) owner of the CWnd. This is NOT the same as the owner in pure Win32.

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

group boxes are just another type of button and should never be the parent or the owner of other controls that are considered to be on the same level as them. just make the MDI child window the parent and owner of the group box when it's created, just like the rest of the controls.

This topic is closed to new replies.

Advertisement