Please enable JavaScript to view this site.

Checked and radio button menu items are created using the Mtype flags MBF_CHKMNU and MBF_RADIOMNU, as shown in this example from the sample program ASMNU2 in EXLIB:[908,35].

ashref_img166

To initialize the state of a checked or radio button menu item to checked (or selected), add the MBST_CHECKED flag to the Mstate parameter, as shown in the example below:

xcall AUI, AUI_MENU, MNUOP_ADD, id'optmnu, "Option 1", MBST_ENABLE+MBST_CHECKED, &

MBF_CHKMNU,"","",mstatus, dlgid, id’option1     ! checked item

xcall AUI, AUI_MENU, MNUOP_ADD, id’optmnu, "Option 2", MBST_ENABLE, &

MBF_CHKMNU,"","",mstatus, dlgid, id’option2     ! unchecked item

xcall AUI, AUI_MENU, MNUOP_ADD, id’optmnu, "Radio 1", MBST_ENABLE+MBST_CHECKED, &

MBF_RADIOMNU,"","",mstatus, dlgid, id’radio1    ! selected radio item

xcall AUI, AUI_MENU, MNUOP_ADD, id’optmnu, "Radio 2", MBST_ENABLE, &

MBF_RADIOMNU,"","",mstatus, dlgid, id’radio2    ! unselected radio item

In the above code sample, note that the Itemid is used to assign unique identifiers to each of the items, and to associate the items with the parent menu id’optmnu. Also note that since we didn’t specify anything in the Cmd parameter, the items do not do anything on their own when clicked, other than change their state.  The application will have to query the items to determine their states as needed (see next). Alternatively, if we wanted to respond immediately with an action corresponding to the change in state of such a menu item, we could have had them generate exitcodes (as in the Menu Icons example above).  They can also execute command lines or launch documents (using MBF_CMDLIN or MBF_SHLEXC) just like other normal menu items.

Querying item state: To query the current state of a checked or radio menu item, use MNUOP_CHK, identifying the item to query via the parent Menuid, Dlgid, and Itemid. The current state flags will be returned in the Mstatus parameter, as shown below:

xcall AUI, AUI_MENU, MNUOP_CHK, id’optmnu, "", 0, 0, "","", mstatus, dlgid, id’option1

If (mstatus and MBST_CHECKED) ? "Option 1 is checked"

xcall AUI, AUI_MENU, MNUOP_CHK, id’optmnu, "", 0, 0, "","", mstatus, dlgid, id’radio1

If (mstatus and MBST_CHECKED) ? "Radio 1 is selected"

Changing item state:  The states of checked and radio menu items change automatically when clicked.  You may also change the state under application control, using MNUOP_STA.  For example, to select the "Radio 2" item in the menu shown above (which will automatically deselect the "Radio 1" item):

xcall AUI, AUI_MENU, MNUOP_STA, id’optmnu, "Radio 2", MBST_ENABLE+MBST_CHECKED, 0, "","", &

mstatus, dlgid, id’radio2

Created with Help+Manual 9 and styled with Premium Pack Version 5 © by EC Software