PlanetSquires Forums

Support Forums => Other Software and Code => Topic started by: Eddy Van Esch on November 05, 2013, 10:04:17 AM

Title: Setting one option button in a group of 4
Post by: Eddy Van Esch on November 05, 2013, 10:04:17 AM
I had a question, but I solved it myself composing this thread   ;D
I will leave the code snippets here as an example of how to get and set the option buttons status.

I have a group of 4 option buttons.
I retrieve the IDC of the set button when the form is destroyed.
If the form is created I set the same button again.
It works like this:
In WM_DESTROY:

            '-- Optionbuttons
    'Check which option button is set and store its ID
    If FF_Control_GetOption( HWND_TBBACKTEST_OPTSORTONDRAWDOWN      ) Then i = IDC_TBBACKTEST_OPTSORTONDRAWDOWN
    If FF_Control_GetOption( HWND_TBBACKTEST_OPTSORTONPROFDRAWDOWN  ) Then i = IDC_TBBACKTEST_OPTSORTONPROFDRAWDOWN
    If FF_Control_GetOption( HWND_TBBACKTEST_OPTSORTONPROFIT        ) Then i = IDC_TBBACKTEST_OPTSORTONPROFIT
    If FF_Control_GetOption( HWND_TBBACKTEST_OPTSORTONWINNINGTRADES ) Then i = IDC_TBBACKTEST_OPTSORTONWINNINGTRADES
    i = FF_INI_SetKey(gsIniFileName, $IniSec_Backtester, $IniKey_SortResultsFor , Str$(i) )

In WM_CREATE:

            '--- Restore the option button state
    i = Val(FF_INI_GetKey(gsIniFileName, $IniSec_Backtester, $IniKey_SortResultsFor, "0"))
    If  (i = IDC_TBBACKTEST_OPTSORTONPROFIT       ) Or _
        (i = IDC_TBBACKTEST_OPTSORTONPROFDRAWDOWN ) Or _
        (i = IDC_TBBACKTEST_OPTSORTONDRAWDOWN     ) Or _
        (i = IDC_TBBACKTEST_OPTSORTONWINNINGTRADES) Then
            FF_Control_SetOption( hWndForm, IDC_TBBACKTEST_OPTSORTONPROFIT, IDC_TBBACKTEST_OPTSORTONWINNINGTRADES, i )
    End If