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:
box1=gtk_box_new(GTK_ORIENTATION_HORIZONTAL,3);
align=gtk_alignment_new(1,0,0,0);
my=gtk_button_new_with_label("HELLO");
gtk_container_add(GTK_CONTAINER(frame),my);
gtk_container_add(GTK_CONTAINER(box1),frame);
gtk_container_add(GTK_CONTAINER(window),box1);
I must write all this code to align a button on the left up of the window or is a easier way.If someone can give me more information about containers of GTK because I understand hard the reference .
Before using Glade I want to see how things works. Sorry about my english.
As the documentation for GtkAlignment notes in Gtk3 there is usually no need to use it as the same effect can be achieved by setting the halign and margin, hexpand properties of the widget that you wish to align.
To have the button in the top left you would set halign and valign to GTK_ALIGN_START.
UPDATE: As noted by jku, GtkHBox, GtkVBox, and GtkTable are now deprecated, and GtkGrid should be used instead. GtkAlignment is also deprecated, and the properties given in the answer by Phillip Wood should be used instead.
I think you meant gtk_alignment_new(0,0,0,0) to align to the left. But without knowing about the other widgets within the window, that looks good to me. That's how you align.
The basic layout containers in GTK are:
GtkFixed which allows widgets to be absolutely positioned.
+----------------------------+
| Widget 3 |
| Widget 2 |
| Widget 1 |
| |
+----------------------------+
GtkHBox allows widgets the be positioned horizontally:
+--------+-----+
| Widget | ... |
+--------+-----+
GtkVBox allows widgets to be positioned vertically:
+--------+
| Widget |
+--------+
| ... |
+--------+
GtkTable allows for a grid or table layout.
+--------+-----+
| Widget | ... |
+--------+-----+
| ... | ... |
+--------+-----+
In addition to those containers, there's also GtkAlignment which allows you to control the alignment of a widget within its allotted space.
GTK+ layout management is a decent tutorial providing working examples of the different layout containers.
ScrollViewer can automatically add horizontal/vertical scrollbars for a given element. Now, I have an image wrapped inside zooming/panning control. I want to add scrollbars to the view containing this zooming control. When the image is fully visible, the scrollbars should be invisible. When 10% of the image is visible, the scrollbar thumb should occopy 1/10 of the scrollbar (standard behavior).
The problem here is that I want the ScrollViewer to occupy the area of the zooming control, and adapt its values using the image inside this control. Perhaps this can be done using some kind of binding to the child of the zooming control? Or maybe using two ScrollBar instances instead?
Zoomed out
+----------------+
| |
| +-------+ |
| | image | |
| +-------+ |
| |
+----------------+
Zoomed in
+----------------+
| |
| image sc <- adapting to visibleHeight/imageHeight
| ro
| ll
| |
+---- scroll ----+ <- adapting to visibleWidth/imageWidth
Sigh. Solved it using a ScrollViewer. I had to set the CanContentScroll to True...
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.