Get the index of the selected radio buttons - c++

I have 4 radio buttons on my dialog and all are under one group.
In order to group them i have set the group option to TRUE for the first radio button and FALSE for the rest of them.
I have given the tab order accordingly.
As i grouped them together, i can only create one member variable for the entire group lets say it is m_RadioGroup.
I have "Ok" button on my dialog. Now on click of OK button i wanted to know which radio button is selected out of 4 of them.
How do we achieve this?

You can't use only 1 variable for 4 item.
Every item should have its own variable. Then witch a switch-case or something else find the radio button selected.

Related

Apex: 22.1.1 - Based on the selection of the radio groups the form must be displayed dynamically

I am a newbie to APEX. I am currently working on radio buttons.. There are radio button groups in my page 1. For example :Radio 1 and Radio 2.Based on the selection of the radio button in these 2 groups , I need to dynamically show a Page items of the region in the same page. For a particular selection of the radio button groups, certain page items will be visible and certain will be hidden.
Also based on the values entered in the page items, on submit,the next page must display all the values which I entered in the region of the page elements.
What should be my approach to this. Please guide.
enter image description here
The way you described it, you'd use dynamic actions (Show / Hide) because they let you "dynamically" (and immediately) manipulate other items on the page.
You could use Server-side conditions as well, but they require page to be submitted first so - I guess that's not what you're after.
Therefore: initially hide all items you don't need (that's the same dynamic action, just set it to fire on initialization, i.e. when page is first rendered), and then show them as radio buttons' values change.
As of your next question: if you navigate to the next page using a button (so its action is to "Redirect to page in this application"), you can set next page's items' to values of items on this page. To do that, use Target - Link builder property (right below "Action").

SetFocus and KillFocus

I have a CMFCTabCtrl in my dialog and my CMFCTabCTrl has two tabs.
The first tab has a CComboBox and the second tab also has a CComboBox.
Whatever item newly added in ComboBox in first tab will reflect in ComboBox in second tab. Similarly, whatever item newly added in ComboBox in second tab will reflect in ComboBox in first tab.
For this, I have all ComboBox items in a vector and in each dialog's WM_SETFOCUS event I am adding items to ComboBox.
When user typing something in ComboBox but then user selects another control or dialog/tab also I am adding that item to ComboBox. For that I am tracking CBN_KILLFOCUS in parent's dialog OnCommand and adding the item to ComboBox.
Now my problem is when user type something in ComboBox and clicking on second tab, the SetFocus of second tab is called first and then only OnCommand with CBN_KILLFOCUS() message is getting called. So the second tab is not having newly added item by the first tab whereas the first tab is having that item.
How to make the ComboBox item available to the second tab before it is getting displayed.
If I do necessary operation(whatever operation I am doing on killfocus) on AFX_WM_CHANGING_ACTIVE_TAB, I am able to achieve my requirement.

Apex button to insert new rows

I'm using Application Express to build a page with a form that shows all the rows in Table A. Table A has to contain all the values from Table B that have a specific "Status".
I'm looking for a way to update Table A so that new rows with the correct status from Table B are added to Table A.
Is there a way to add a button to the page that inserts into Table A those rows? I have no problems with coding the query itself, but on Apex' Page Designer, when I add a button (which I called Refresh) to the page, I can't find a place to add the Insert Query.
Any tips?
there are several ways to do what you need, the simplest one would be to bind a dynamic action to the click event on the button.
On the button definition go to "Action when button clicked" region and on the action field select "Defined by dynamic action"
On execute validations choose "No"
Then, back on the page definition, create a dynamic action, on Event choose "Click", on Selection type choose "Button" this will make a field named button appear whit a list of the available buttons to choose.
In condition you can define a true/false evaluation. if so then you would be able to define actions to execute in both cases, if you leave it empty ("No condition") then all the actions defined will be executed.
Once defined click next and here you decide the action type, the one you need is "Execute PL/SQL Code", which will show a text field on which you can paste your code, and the parameters needed from the page.
finally you can specify if the action will have a repercussion on any kind of visual component on the page, this is for efficiency, but is not necessary.
That would be all, once created, when you click the button the code will be executed on the server.

making a QToolButton checked with a QMenu

I am designing a widget which has a grid of buttons. When clicked I want these buttons to present the user with 3 choices (ideally in a small drop down menu) that they can select from. When they select 1 of the 3 choices, I want that button to be selected (i.e., remain depressed). I want the QAction that is associated with each of the 3 choices to be able to know which button was clicked so that I can log which button in the grid was clicked. Each button in the grid needs to be exclusive, and when selected. The 3 choices presented are the same for all buttons.
I first started with a QButtonGroup and QPushButtons in a QGridLayout. I was able to get the buttons to be exclusive as I wanted. When I changed the buttons from QPushButton to QToolButton, and added a drop down menu, two things happened:
When they select an item from the menu, the button doesn't stay depressed like I want it to.
I can't seem to see a way for the menu action to be informed about which button was selected, so I am unable to log which button is selected.
Any thoughts on how I can achieve the functionality I am looking for?
EDIT:
A few clarifying points:
Each button in the m x n grid represents a person.
The drop down list on each button lets you select what action that person is currently doing.
Only one person can be doing something at a time. Hence, only one button in the entire grid can be depressed at a time.
The items in the button drop down menu should become checked when they are selected, and these items need to be exclusive, so if a button is clicked twice, the a new checked menu item in the drop down menu should uncheck the previous one.
When an item in the button drop down menu is selected, the menu should go away and the button should appear depressed.
I need to log the button (i.e., the row and column) that was clicked as well as the choice selected from the button drop down menu. So somehow menu item signal/slot needs to know about which button was clicked. However, QToolButton::setMenu() doesn't transfer ownership of the Menu to the QToolButton, so I'm not sure how to make the signals/slots in the QActions of the QMenu aware of which button was selected.
QObject::sender will tell you what QObject emitted the signal

Deselecting radio buttons

I am creating an application in which i use different group box for different categories which contains radio buttons for items.But if i select an item from one group box and then from another group box,the item in previous group box remains checked. But i want that whenever i select an item from different group box all other item must get deselected.
Can anyone help me with this regard??
Thank you.
Radio buttons with different parents will behave as separate groups so the radio buttons will all need to have the same parent. You could overlay group boxes by positioning group boxes over the radio buttons but this will be problematic if you are using layouts. An alternative is to just separate the groups of radio buttons you want to distinguish by using labels or line separators.
Group all the buttons together with either 1 group as parent or something else like the form, just have them in the group boxes visually.
By default, radio buttons will only be exlusive between those with the same parent. However, there is a simple solution to this. A QButtonGroup can be used to specify which buttons are related. Your solution would be to create your own button group, then set that group on each of the radio buttons you would like to be mutually exclusive.