How can I initialize the combox if I start my project with default value

Started by Stephane Fonteyne, September 24, 2013, 08:16:38 AM

Previous topic - Next topic

Stephane Fonteyne

Dear support,

I don't find the FF function for ComboBox for initialize the value with an highlight default when start the application

I see now when start the application all the four combobox are empty. I want to see that when I started the application default values highlight in the combobox

cboBaud  = 9600
cboParity = N
cboData  = 8
cboStop  = 1

I see this :

cboBaud  = " "
cboParity = " "
cboData  = " "
cboStop  = " "



'--------------------------------------------------------------------------------
Function FORM1_CBOBAUDRATE_CBN_SELCHANGE ( _
                                         ControlIndex  As Long,  _  ' index in Control Array
                                         hWndForm      As Dword, _  ' handle of Form
                                         hWndControl   As Dword, _  ' handle of Control
                                         idComboBox    As Dword  _  ' identifier of combobox
                                         ) As Long
    Local index As Long
   
    index = FF_ComboBox_GetCurSel(HWND_FORM1_CBOBAUDRATE)
    g_strBaud = FF_ComboBox_GetText(HWND_FORM1_CBOBAUDRATE, index)
    MsgBox g_strBaud
End Function


'--------------------------------------------------------------------------------
Function FORM1_CBOPARITY_CBN_SELCHANGE ( _
                                       ControlIndex  As Long,  _  ' index in Control Array
                                       hWndForm      As Dword, _  ' handle of Form
                                       hWndControl   As Dword, _  ' handle of Control
                                       idComboBox    As Dword  _  ' identifier of combobox
                                       ) As Long
    Local index As Long
   
    index = FF_ComboBox_GetCurSel(HWND_FORM1_CBOPARITY)
    g_strParity = FF_ComboBox_GetText(HWND_FORM1_CBOPARITY, index)

End Function


'--------------------------------------------------------------------------------
Function FORM1_CBODATABITS_CBN_SELCHANGE ( _
                                         ControlIndex  As Long,  _  ' index in Control Array
                                         hWndForm      As Dword, _  ' handle of Form
                                         hWndControl   As Dword, _  ' handle of Control
                                         idComboBox    As Dword  _  ' identifier of combobox
                                         ) As Long
    Local index As Long
   
    index = FF_ComboBox_GetCurSel(HWND_FORM1_CBODATABITS)
    g_strDataBits = FF_ComboBox_GetText(HWND_FORM1_CBODATABITS, index)
End Function


'--------------------------------------------------------------------------------
Function FORM1_CBOSTOPBITS_CBN_SELCHANGE ( _
                                         ControlIndex  As Long,  _  ' index in Control Array
                                         hWndForm      As Dword, _  ' handle of Form
                                         hWndControl   As Dword, _  ' handle of Control
                                         idComboBox    As Dword  _  ' identifier of combobox
                                         ) As Long
    Local index As Long
   
    index = FF_ComboBox_GetCurSel(HWND_FORM1_CBOSTOPBITS)
    g_strStopBits = FF_ComboBox_GetText(HWND_FORM1_CBOSTOPBITS, index)
End Function




Global g_strBaud        As String
Global g_strParity      As String
Global g_strDataBits    As String
Global g_strStopBits    As String

Function FORM1_WM_CREATE ( _
                         hWndForm As Dword, _      ' handle of Form
                         ByVal UserData As Long _  ' optional user defined Long value
                         ) As Long
    'Private Sub form_load()
    '    Dim String_Comm As String
    '    Dim i As Integer
    '
    '    Call init_com_param
    '    String_Comm = "," & Vitesse.Text & "," & Parite.Text & "," & Taille.Text & "," & BitStop.Text
    '    i = OPENCOM("COM2" & String_Comm) ' OPENCOM("COM2,2400,N,8,1")
    '   
    '    If i = 0 Then
    '        i = OPENCOM("COM1" & String_Comm) ' OPENCOM("COM1,2400,N,8,1")
    '        Option1.Value = True
    '    End If
    '
    '    If i = 0 Then MsgBox ("COM Interface Error")
    '
    '    'init
    '
    '    TXD 1
    '    RTS 1
    '    DTR 1
    '    TIMEINIT
    'End Sub
   
    Local strCom As String
    Local i As Integer
       
       
    KillTimer(HWND_FORM1,IDC_FORM1_TIMER1)
    KillTimer(HWND_FORM1,IDC_FORM1_TIMER2)
    KillTimer(HWND_FORM1,IDC_FORM1_TIMER3)
   
    'Init_Com_Param()
    StrCom = "," & g_strBaud  & "," & g_strParity & "," & g_strDatabits & "," & g_strStopBits
    'i = Open_SerialPort("COM2" & strCom)
   
    If i = 0 Then
        FF_Control_SetOption(HWND_FORM1_OPTCOM1, IDC_FORM1_OPTCOM1, IDC_FORM1_OPTCOM2, IDC_FORM1_OPTCOM1)
        'i = Open_SerialPort("COM1" & strCom)
    End If
   
    If(i = 0) Then MsgBox("COM Interface Error")
   
    'TXD_out(1)
    'RTS_out(1)
    'DTR_out(1)
    'Time_Init()
End Function



I try this for init but doesn't work

Sub Init_Com()
    FF_ComboBox_SetCurSel(HWND_FORM1_CBOBAUDRATE, 6)
End Sub


Can someone help me in the right direction?
Stephane Fonteyne
Ba. Elektronica - ICT
GSM : +32-xxxxxxxxxx
PowerBasic Developer & Hardware Support

Paul Squires

If you add your combobox strings using the "(Custom)" property in the "Properties" tab, then in order to set the default selected item you can change the value of the "InitialSelection" value also found on the "Properties" tab. By default, the "InitialSelection" property is -1 wheich means that nothing is selected.

To set the initial selection via code you would use the FF_ComboBox_SetCurSel function most likely in the WM_CREATE message handler.
Paul Squires
PlanetSquires Software

Stephane Fonteyne

Quote from: TechSupport on September 24, 2013, 03:37:51 PM
If you add your combobox strings using the "(Custom)" property in the "Properties" tab, then in order to set the default selected item you can change the value of the "InitialSelection" value also found on the "Properties" tab. By default, the "InitialSelection" property is -1 wheich means that nothing is selected.

To set the initial selection via code you would use the FF_ComboBox_SetCurSel function most likely in the WM_CREATE message handler.

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