Question : an example of eventcode for one option button

Started by Stephane Fonteyne, October 22, 2011, 08:50:41 AM

Previous topic - Next topic

Stephane Fonteyne

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


Stephane Fonteyne
Ba. Elektronica - ICT
GSM : +32-xxxxxxxxxx
PowerBasic Developer & Hardware Support

James Padgett

#1
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 ..





Rolf Brandt

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

Rolf Brandt
http://www.rbsoft.eu
http://www.taxifreeware.com
I cook with wine, sometimes I even add it to the food.
(W. C. Fields)