I created a Dialog Box using FEMAP API, that has several Option Buttons. I've needed that when I clicked in a certain Option Button an action was performed (in this case, for each Option Button a different picture should be shown). In the VBA I do such thing without any difficulty writing a routine for each Option Button, as follows:
Private Sub OptionButton1_Click()
Writing such routine for each Option Button, the VBA is able to recognize the mouse click in a particular Option Button and runs the routine associated to it. Does somebody know if is possible to do something like this using Dialog Box in FEMAP API?
Solved! Go to Solution.
Yep this uses the "DialogFunc"
Go to Help > Basic Languauge and search for DialogFunc, you'll find all the associated functions and explanations: dlgitem, dlgvalue...etc...
Here's a little example to help you start (below).
Sub Main Dim App As femap.model Set App = feFemap() 'HMI Begin Dialog myDialog 220,70,"Are you happy?",.DialogFunc OptionGroup .yesorno OptionButton 30,10,50,20,"Yes" OptionButton 110,10,50,20,"No" OKButton 10,40,80,20 CancelButton 100,40,80,20 End Dialog Dim dlg As myDialog 'show dialog box. if cancel is pressed, end If Dialog(dlg) = 0 Then End End Sub 'standard dialog function. checkout all the Dlg... functions in the Basic Language help Function DialogFunc(DlgItem As String, Action As Integer, SuppValue As Long) As Boolean Select Case Action Case 1 ' Dialog box initialization Case 2 ' Value changing or button pressed If DlgItem = "yesorno" Then If DlgValue("yesorno") = 0 Then MsgBox "Me too!" Else MsgBox "Cheer up!" End If DialogFunc = True 'do not exit dialog End If Case 3 ' TextBox or ComboBox text changed Case 4 ' Focus changed Case 5 ' Idle Case 6 ' Function key End Select End Function
I employed the DialogFunc in the DialobBox and it worked exactly as I needed. Thank you very much!