PlanetSquires Forums

Support Forums => Other Software and Code => Topic started by: Stephane Fonteyne on October 22, 2011, 08:50:41 AM

Title: Question : an example of eventcode for one option button
Post by: Stephane Fonteyne on October 22, 2011, 08:50:41 AM
Dear Support,

1.) When I click the button "Read" of the option button the program in running is crashed. What is the reason and how can I an solution for that software problem?
Can somebody help me what I can do?

2.) I would like to need an example that used option buttons in an event procedure.




Function FORM1_BTNREAD_BN_CLICKED ( _
                                  ControlIndex     As Long,  _  ' index in Control Array
                                  hWndForm         As Dword, _  ' handle of Form
                                  hWndControl      As Dword, _  ' handle of Control
                                  idButtonControl  As Long   _  ' identifier of button
                                  ) As Long

      Local read_data As Long : read_data = 0
     
      'read_data = dll_Read(adres)
     
      FF_ListBox_AddString(HWND_FORM1_LSTMOTORBOXSTATUS,"Read: " & Str$(read_data) & $CrLf)
     
      Do While(read_data <> 65)
         FF_ListBox_AddString(HWND_FORM1_LSTMOTORBOXSTATUS,"Read in the loop: " & Str$(read_data) & $CrLf)
         If((FF_Control_GetOption(HWND_FORM1_OPTREADED) = 1)) Then
            FF_Control_SetOption(HWND_FORM1_OPTREADED,IDC_FORM1_OPTREADED,IDC_FORM1_OPTREADED,0)
         Else
            FF_Control_SetOption(HWND_FORM1_OPTREADED,IDC_FORM1_OPTREADED,IDC_FORM1_OPTREADED,1)
         End If
      Loop
End Function


Title: Re: Question : an example of eventcode for one option button
Post by: James Padgett on October 22, 2011, 09:17:22 AM
FF_Control_SetOption  form , firstoptionbutton, lastoptionbutton, optionbutton to set 

Your last param is 0 and should be the option button you want to set .

But you indicate you only have one option button.... option buttons are toggles and one must be selected
so if you only have one then there is no need to set it .. once active it will always be set ..




Title: Re: Question : an example of eventcode for one option button
Post by: Rolf Brandt on October 22, 2011, 11:47:21 AM
Stephane,

you could set the state of an optionbutton with the CheckDlgButton function.
Use the following code:


CheckDlgButton(HWND_FORM1, IDC_FORM1_OPTREADED, 0) 'Unchecked
or
CheckDlgButton(HWND_FORM1, IDC_FORM1_OPTREADED, 1) 'Checked