Group box with a heading as a check box.

I am using Visual Studio 6.0 (VC ++ with MFC) on a Windows XP platform. I am trying to create a group field with the name of the group field as a checkbox. My intention is this: if the checkbox is enabled, the controls inside the group field should be included; or disconnected.

Can this be done? If yes, please give me some advice.

Thanks.

+4
source share
3 answers

There are several things you can try, depending on how truly you want to stay in your idea and how much work you are willing to put into work:

Simple method

Use a normal group box, and then inside this check the box in the first item. This is easy to do, but you lose the goal of having the checkbox as the title.

Funny drawing method 1

Use a normal group block, and then in the space where you know the header should go, put your flag. You will need to perform some tricky calculation so that it fits well and draws well without flickering.

Funny drawing method 2

Use superclass or subclass / subclass in group field. You can override the WM_PAINT handler to draw only a border for a group field. Check the normal box where you know the title should go. This should work better because you will have more control over the drawing, but it will most likely be difficult to get the right. In my experience, subclassification is lower than for superclassification.

+5
source

Are you using the Dialog editor? If yes, put the group field. Then, on top of it, select the check box in the group field row. Edit the resource to set the order of Z, or do it in code. You want the flag to be above the group field. Add a handler for the flag and enable / disable the controls depending on the state of the flag.

+2
source

I wrote one of them called CGroupCheck a few years ago, and it is available from CodeProject: http://www.codeproject.com/KB/buttons/groupcheck123.aspx

0
source

Source: https://habr.com/ru/post/1286798/


All Articles