Programmatically select an MFC radio button - winapi

When I'm initializing a dialog, I'd like to select one of the radio buttons on the form. I don't see a way to associate a Control variable using the Class Wizard, like you would typically do with CButtons, CComboBoxes, etc...
Further, it doesn't like a CRadioButton class even exists.
How can I select one of the several radio buttons?

Use CWnd::CheckRadioButton to set select one button in a group and CWnd::GetCheckedRadioButton to retrieve the ID of the selected button. Be sure to call these methods on your dialog object, and not any of the radio button objects.

Radio buttons and check buttons are just buttons. Use a CButton control and use GetCheck/SetCheck.

Going on what mos said, the following worked did the trick:
CButton* pButton = (CButton*)GetDlgItem(IDC_RADIOBUTTON);
pButton->SetCheck(true);

void CMyDlg::DoDataExchange(CDataExchange* pDX)
{
...
DDX_Radio(pDX, IDC_RADIO1, m_Radio);
...
}
but it is the same thing Wizard generates

You can use this one-liner:
::SendMessage(GetDlgItem(IDC_RADIO1)->m_hWnd, BM_SETCHECK, BST_CHECKED, NULL);

Related

Custom drop-down as an item in a kendo tree

I am trying to create an item that is a button "show more" and when you press on it you can show a kind of context menu / drop down that all of the items in that drop down are with checkboxes and there is a search component in it too, so you can search some items in the dropdown by their name. For example: (instead of "c++,c#,Object c" it's should show "show more", i.e. static text)
I tried to use kendoContextMenu. But I don't know if it's could work because the problem with context menu is that when I will click on a checkbox the menu will close. Please advise me of a way to do that or if you have an example of code. Thanks!
The MultiSelect component might be a good starting point
https://docs.telerik.com/kendo-ui/api/javascript/ui/multiselect.
My understanding is that MultiSelect does not have a "select more than one at a time in dropdown" feature.
You might consider using a pop up window and within that implement your own custom ui that features everything you want
search term box
scrolling list of selected and selectable items
accept or cancel changes in selection
Regarding your dojo that extends drop down list, I can't code the extension for you. However, changing the dataSource assignment to a setDataSource call will populate the extension component according to the template.
// kendo.ui.DropDownList.fn.dataSource = options.testItemSource;
me.setDataSource(options.testItemSource);

Replace custom menu with Oracle Forms 11g default menu

In my main form window, I have the following menu bar which is used for traversing. Its inherited from .mmb file.
Now, when I select any form on the menu, lets suppose I selected the highlighted "Purchase Order", then I don't want the same menu to be shown. I want the Oracle Form 11g's default menu to be shown instead, picture added below for reference.
I changed form's property of Inherit menu to No and the menu from image 1 isn't shown in "Purchase Order" but I still am not getting the default&smartbar menu.
How can I achieve that?
Thank you.
So I figured out a way how to disable .mmx menu and enable DEFAULT&SMARTBAR menu when I go to another form through the menu.
From the first screenshot above, the on-click-trigger had the following code
call_form(:global.path||'pc');
I replaced it with
call_form(:global.path||'pc',hide,do_replace);
So the addition of
,hide,do_replace
worked.
Side note: Also, make sure Inherit Menu property of Window property is "YES" and Menu Module of form property is set to "DEFAULT&SMARTBAR"
I think in the properties window from the form you got the property "menu module"
If you make a new form it gets the default: DEFAULT&SMARTBAR
So I think it is now filled with your mmb filename.

Multiselect option with remove item

I'm looking for a Qt/QML multiselect control that have a remove button.
I want to add a filter builder and I didn't find a good example or control for this purpose.
I can design token by myself. I'm just curious if someone already did that and can share it.
Multi filter selector
Thanks
A simple radio button for each option can do the job. If you do not include all these radio buttons under an exclusive group, a second click on these buttons deselects the option.
A click on the radio button includes selected option in the search results and second selection removes the option from the results.
An extra button which deselects all the radio buttons can also be added.
I don't intend to insult or disrespect you, but i think with radio buttons the task takes less time than posting this question.

How to make a check-box in a dynamic MFC dialog?

I have to create a dynamic dialog and used therefor the procedure described in the article Creating a Template in Memory. I already created buttons and edits but I don't know how I can make check-box. Do you know how?
In the DLGITEMTEMPLATE article there are only following types defined:
0x0080 Button
0x0081 Edit
0x0082 Static
0x0083 List box
0x0084 Scroll bar
0x0085 Combo box
Thanks!
A checkbox is a Button with the BS_CHECKBOX or BS_AUTOCHECKBOX style
for more information, see http://msdn.microsoft.com/en-us/library/bb775951(VS.85).aspx
A checkbox is a button with the BS_CHECKBOX style.

MFC separate groups of radio controls

I have added 8 radio buttons in my dialog layout in the resource manager, but I am having trouble separating them into 2 groups of 4 buttons. I have attempted to add a control variable, but I don't see the option of CButton available in the drop-down menu in the wizard. What would be the easiest method to accomplish this goal?
Make sure the first control in each group has the "Group" and "Tab Stop" attribute set.
Make sure that the control following the last radio button in each group has the "Group" attribute set.
Make sure that all the radio button IDs in each group are consecutive integers.
Create an integer member variable for each group
In the DoDataExchange method for the dialog add a DDX_Radio statement for each group linking the integer variable to the first ID in the group.
The integer variables will be set from the radio buttons whenever UpdateData(true) is called (called automatically by the default OnOk() handler) and the radio buttons can be set from the variables by calling UpdateData(false) (happens automatically in the default handling of OnInitDialog)
This problem is not a MFC problem, but a WIN32 radio button problem.
When creating the groups, the tab order (creation order) matters. You have to create them in order of the first group then the second group. The fist radio button control in each group has to have the "group" style selected.
You should be able to create the radio buttons in the Visual Studio dialog editor and run the Test Dialog and it radio groups should work ok within the two groups without any code at all. If they don't then you have done something wrong.
I found this using google which may help you.

Resources