Tristate CheckBoxes as labels for GroupBox elements in MFC dialog - checkbox

I am working on this popup dialog and I am at the design stage:
I have three tristate checkboxes at the top and three group boxes with 4 checkboxes in each. The concept is simple:
If all 4 check boxes are ticked then the master checkbox is ticked.
If none of them are ticked then the master one is untickd.
If only 1 to 3 of them are ticked then the master one is set to intermediatery.
The user will be able to tick the master check box to bulk switch on all off all the associated checkboxes.
My question relates to the 3 static group boxes. I want those three lables changed into the 3 tri-state checkboxes as it will look nicer. When I played with WPF i had full control over how the labels looked for groupboxes but whatabout here in a MFC project?
This is the resource in my test project:
IDD_MFCAPPLICATION4_DIALOG DIALOGEX 0, 0, 309, 184
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_APPWINDOW
CAPTION "Assignment Slips"
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
DEFPUSHBUTTON "OK",IDOK,199,163,50,14
PUSHBUTTON "Cancel",IDCANCEL,252,163,50,14
CONTROL "Main hall",IDC_CHECK1,"Button",BS_AUTO3STATE | WS_TABSTOP,18,7,43,10
GROUPBOX "Main hall",IDC_STATIC,7,23,94,82
CONTROL "Bible Reading",IDC_CHECK2,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,38,59,10
CONTROL "Initial Call",IDC_CHECK3,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,53,47,10
CONTROL "First Return Visit",IDC_CHECK4,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,67,69,10
CONTROL "Bible Study",IDC_CHECK5,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,82,51,10
GROUPBOX "Aux. Class 1",IDC_STATIC,107,23,94,82
CONTROL "Bible Reading",IDC_CHECK6,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,117,38,59,10
CONTROL "Initial Call",IDC_CHECK7,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,117,53,47,10
CONTROL "First Return Visit",IDC_CHECK8,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,117,67,69,10
CONTROL "Bible Study",IDC_CHECK9,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,117,82,51,10
GROUPBOX "Aux. Class 2",IDC_STATIC,207,23,94,82
CONTROL "Bible Reading",IDC_CHECK10,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,217,39,59,10
CONTROL "Initial Call",IDC_CHECK11,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,217,53,47,10
CONTROL "First Return Visit",IDC_CHECK12,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,217,68,69,10
CONTROL "Bible Study",IDC_CHECK13,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,217,82,51,10
GROUPBOX "Other",IDC_STATIC,7,108,94,69
CONTROL "Opening Prayer",IDC_CHECK14,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,126,66,10
CONTROL "Closing Prayer",IDC_CHECK15,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,141,62,10
CONTROL "Aux. Class 1",IDC_CHECK18,"Button",BS_AUTO3STATE | WS_TABSTOP,117,7,56,10
CONTROL "Aux. Class 2",IDC_CHECK19,"Button",BS_AUTO3STATE | WS_TABSTOP,217,7,56,10
CONTROL "Congregation Bible Study",IDC_CHECK16,"Button",BS_AUTOCHECKBOX | BS_TOP | BS_MULTILINE | WS_TABSTOP,17,156,76,17
END
Update
One posibility is to adjust the design style like this:
That is quite clear and avoids the need for a checkbox as the label of the group box. But I would prefer the original approach if at all possible.
Update
Looking at this answer I cameup with a solution:

Related

Wpf align content in different containers

Whats the best way to align controls vertically that exist in different containers, in WPF/XAML?
In my case i have several Expander Controls with a Grid inside. In the grid there are Labels and Textboxes.
The grid row/column is setup as "Auto"
The Expanders is placed in a MainGrid in a usercontrol
It looks like this:
-Expander---------------
| Foo | BarBarBarBar |
| Hello | Hi |
------------------------
-Expander2-------------
| SomeText | More text|
| Aaaaa | Bbbbb |
-----------------------
What i tried to describ with the above figure is that the rows in the different expanders aren't aligned (the "|" symbolizes the grid border), and that is because the column width is set to Auto in the grid.
Is there a way to align the gridcolumn in the different Expanders without hardcoding the width of the columns in the different grids?
SharedSizeGroup on grid like here

Can I have win32 C checkboxes in a listbox control?

I have the following dialog:
IDD_REMINDERS DIALOGEX 20, 20, 102, 166
STYLE DS_SETFONT | WS_POPUP | WS_SYSMENU | WS_THICKFRAME
FONT 7, "Small Fonts", 0, 0, 0x0
BEGIN
LISTBOX IDC_REMINDERS_LIST, 1,12,100,152, LBS_OWNERDRAWVARIABLE | LBS_HASSTRINGS | LBS_USETABSTOPS | LBS_NOINTEGRALHEIGHT | LBS_DISABLENOSCROLL | WS_VSCROLL | WS_TABSTOP
PUSHBUTTON "×",IDC_CLOSE,90,-1,12,11,WS_GROUP | NOT WS_TABSTOP
LTEXT "...", IDC_REMINDERS_CAP, 1,1,75,8
PUSHBUTTON "+", IDC_REMINDERS_NEW, 78,-1,12,11, WS_GROUP | NOT WS_TABSTOP
END
In this dialog I'd like to display checkboxes on the right side.
I was under the impression that calling the following code should add checkboxes to the listbox:
ListView_SetExtendedListViewStyleEx(hWndListView, LVS_EX_CHECKBOXES, LVS_EX_CHECKBOXES);
Though, I now suspect I may be mixing up listboxes and listviews. Either way, I tried the same ListView_SetExtended call on a listview with the following code in the RC:
CONTROL "",IDC_KEYS,"SysListView32", LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_OWNERDRAWFIXED | LVS_OWNERDATA | LVS_NOCOLUMNHEADER | WS_TABSTOP,4,64,250,136
Sadly, this listview refused to show checkboxes as well.
Is it possible to have checkboxes in a listbox? (Without going ahead and drawing them yourself. Which will work fine short term, but seems more of a hassle in terms of longer term OS compatibility.)
Can this work if the listbox is set to "owner draw"? (I'm using that due to custom text coloring.)

WPF WrapPanel, GroupBox height

I've got a few GroupBoxes containing different number of controls, mostly TextBlocks and TextBoxes, and thereby of different heights.
I generate these GroupBoxes dynamically.
When the WrapPanel is quite narrow you could easily see that the GroupBoxes is of different heights but when the WrapPanel is resized, wider, the layout is rearranged (as it should) but at the same time the GroupBox rearranged gets the same height as the one to its left.
Is there a way to prevent this?
What i want to achieve.
------------ ------------
| BLOCK #1 | | BLOCK #1 |
------------ | |
------------ | |
| BLOCK #2 | | |
| | | |
------------ ------------
Thanks!
//Robert

Display a windowless Forms PictureBox, always on top

How can I write an windows forms app that displays (multiple) windowless picture boxes, that are always shown 'on top' i.e. always visible?
The idea is for the app to be run at the same time as main application so that the picture boxes 'appear' as though they belong to main application but exist in a separate process. And, preferably the space between the displays remains clickable to the main app e.g.:
---------------------
| -- |
| | | <---------|------App.exe
| -- | |
| -- | |
| | | <- |
| -- |
| |
| | <--- App2.exe
---------------------
Motivation is the picture boxes are used display the output of a 3rd party activex video control that is known to sometimes deadlock. By having it in a separate process the deadlocked video control will not deadlock the entire application.
FormBorderStyle=None and TopMost=true will bring you close. And when showing them Non-Dialog just .Show() they won't stop the ui thread from executing. Also provide some functionality to close them as well. You should make something custom (button) for it because you don't have standard controlbox visible anymore ;) Think of a customcontrol with a picturebox and a little toolbar (close, minimize) underneath it or on top of it.

Relative control position in .NET / Visual Studio Editor

I am editing custom control in control editor of Visual Studio 2008
My custom control has datagrid view on the left and buttons on the right. I want my control when resized to keep button size constant always and keep them aligned to right border and only my datagrid control to be resized so that horizontal distances between borders and control remained the same. (See illustration below) I remember there was some feature in WinForms and Editor like anchors or other that would me to do that automatically. I just cannot find it in MSVS.
==============================
| **************** *button* |
| * datagridview * *button* |
| * * *button* |
| **************** |
==============================
=================================
| ******************* *button* |
| * datagridview * *button* |
| * * *button* |
| ******************* |
================================
Anchor the buttons right, top. Then anchor the datagrid left, right and top.
That should do it.
Have a look at
Control.Anchor Property
and
Form Anchor

Resources