Showing results for 
Search instead for 
Do you mean 
Reply
Solved! Go to solution

How to run routines clicking in Option Buttons in Dialog Box of a Femap's API?''

Hello, everybody!

 

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()

                Do something... 

End Sub

 

 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?

 

Fabiano.

 

2 REPLIES
Solution
Solution
Accepted by topic author Fabiano
‎08-26-2015 04:32 AM

Re: How to run routines clicking in Option Buttons in Dialog Box of a Femap's API?''

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).

 

AP

 

 

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

Re: How to run routines clicking in Option Buttons in Dialog Box of a Femap's API?''

astrium_tls,

 

I employed the DialogFunc in the DialobBox and it worked exactly as I needed. Thank you very much!

 

Fabiano