Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

grouping radio buttons

John_B__Walter
Beginner
1,310 Views

Is there a way to use the group feature with radio buttons in Intel Visual Fortran?

I've achieved the effect by using call backs for each of the buttons, but is that the only way? I'm using MS Dev. Env. 2003 Ver. 7.1.3008, and the help describes how to do it, setting the group property to TRUE for the first radio button, right clicking on that button and selecting "add variable...", but it's grayed. Does anyone have a clue? Apparently the "add variable..." wizard works with "classes", and apparently FORTRAN projects have no classes.

help

0 Kudos
4 Replies
Paul_Curtis
Valued Contributor I
1,310 Views
Grouping of radiobuttons is easy to do using the VS Resource Editor, wherein IIRC one sets a sequential tab ordering for all the radiobuttons to be grouped, and then indicates that the 1st in the sequence is the start of a group. This setup is entirely a VS feature, has absolutely nothing to do with IVF, and will magically appear and work as it was defined when the resource file is linked with your executable.

In the Fortran code, however, you still have to process the message loop for the dialog, set the initial status of the group when the dialog opens (set which button is initially selected) and then read the buttons either as they are toggled, or when the dialog exits.

My experience (not that you asked) from doing this a lot, is that it is preferable to do the logic for your controls explicitly in the Fortran dialog code, rather than have it be an implicit part of the VS dialog setup where you can't see the code or the logic.
0 Kudos
Jugoslav_Dujic
Valued Contributor II
1,310 Views
"Add class" and "add variable" are C++ MFC features. All you have to do is to set up the "Group" styles and ensure the correct tab order (Format/Tab order) from the resource editor. From then on, follow the instructions on

* Using Check Boxes and Radio Buttons and
* Using Dialog Boxes for Application Controls Overview

in the Intel Visual Compiler documentation (rather than Visual studio online help).

0 Kudos
John_B__Walter
Beginner
1,310 Views

Thanks to you both for your replies. As I now understand, to sum up, IVF itself does not support MFC, and so the resource file would have to be in a second project, a C++ project which supported MFC (an option in the C++ project). So the easiest route is to process the buttons in my own callback routine which saved a button specific value in a global variable whenever any of the buttons in the group was selected. Having the group property selected for the first in the group, having it set to false for the rest, and having the tab order correct, will ensure that only one of the buttons is selected at a time. So my callback will not have to handle that detail. After the dialog is dismissed, my global variable will indicate which of the buttons was selected at the time, so if that is all I need the callback is very simple.

Thanks again.

0 Kudos
Jugoslav_Dujic
Valued Contributor II
1,310 Views
john.walter@inl.gov:

Thanks to you both for your replies. As I now understand, to sum up, IVF itself does not support MFC, and so the resource file would have to be in a second project, a C++ project which supported MFC (an option in the C++ project).

Now you got me thoroughly confused. You don't need MFC to deal with the dialogs at all; if I may drop a 2c, handling dialogs with MFC is probably one of most contrived ways to do so. You can use dialogs from an all-fortran solution, if you take a look at the help pages I referred to. Or are you saying that you're already using MFC and mixing it with Fortran code? Or...?

A purely Fortran code with a dialog containing 3 radio buttons, OK and cancel button will look as simple as:

USE DFLOGM
INCLUDE "resource.fd"
LOGICAL:: ret, bRadio1, bRadio2, bRadio3
TYPE(Dialog):: Dlg

ret = DlgInit(IDD_DIALOG1, Dlg)
!Initialize e.g. radio2 to checked:
ret = DlgSet(Dlg, IDC_RADIO2, .TRUE.)
!Display the dialog:
IF (DlgModal(Dlg)==IDOK) THEN
 ret = DlgGet(Dlg, IDC_RADIO1, bRadio1)
 ret = DlgGet(Dlg, IDC_RADIO2, bRadio2)
 ret = DlgGet(Dlg, IDC_RADIO3, bRadio3)
 IF (bRadio1) THEN
 ...
 ELSE IF (bRadio2) THEN
 ...
 ELSE IF (bRadio3) THEN
 ...
 END IF
END IF
call DlgUnInit(Dlg)

0 Kudos
Reply