I noticed that the ToolBar_SetState/ToolBar_GetState don't work as expected.
For example, ToolBar_SetState( hDlg, %tToolbar, 2, %TBSTATE_CHECKED) does not check the second button in %tToolbar, but disables it instead.
' Basic Template for custom dialog
' Start Date 02-19-2012
' Created by Petr Schreiber
Uses "UI"
' -- ID numbers of controls
Begin ControlID
%tToolbar
%bA
%bB
%bC
%bCheckState
End ControlID
Begin Const
%MAIN_WIDTH = 320
%MAIN_HEIGHT = 240
End Const
' -- Create dialog here
Function TBMain()
Local hDlg As DWord
Dialog New Pixels, 0, "<Enter title here>",-1,-1, %MAIN_WIDTH, %MAIN_HEIGHT, _
%WS_POPUP Or %WS_VISIBLE Or %WS_CAPTION Or %WS_SYSMENU Or %WS_MINIMIZEBOX To hDlg
' -- Place controls here
Control Add TOOLBAR, hDlg, %tToolbar, "", , , , , %WS_VISIBLE Or %WS_TABSTOP Or %CCS_TOP Or %TBSTYLE_FLAT
ToolBar_AddButton hDlg, %tToolbar, 0, %bA , %TBSTYLE_CHECK Or %TBSTYLE_GROUP, "A"
ToolBar_AddButton hDlg, %tToolbar, 0, %bB , %TBSTYLE_CHECK Or %TBSTYLE_GROUP, "B"
ToolBar_AddButton hDlg, %tToolbar, 0, %bC , %TBSTYLE_CHECK Or %TBSTYLE_GROUP, "C"
' -- DOES NOT WORK
'ToolBar_SetState( hDlg, %tToolbar, 2, %TBSTATE_CHECKED) ' -- I would expect to check the second button (B)
' -- DOES WORK
ToolBar_SetState( hDlg, %tToolbar, 2, 5) ' -- This checks the second button, but it should be done by value instead
Control Add Button, hDlg, %bCheckState, "Check state", 5, 100, 100, 25, Call cbCheckButton
Dialog Show Modal hDlg, Call cbDialog
End Function
' -- Callback for dialog
CallBack Function cbDialog()
' -- Test for messages
Select Case CBMSG
Case %WM_INITDIALOG
' -- Put code to be executed after dialog creation here
Case %WM_COMMAND
' -- You can handle controls here
Case %WM_CLOSE
' -- Put code to be executed before dialog end here
End Select
End Function
CallBack Function cbCheckButton()
If CBMSG = %WM_COMMAND Then
If CBCTLMSG = %BN_CLICKED Then
MsgBox 0, "Expected return values:"+$CRLF+
"%TBSTATE_CHECKED"+$TAB+%TBSTATE_CHECKED+$CRLF+
"%TBSTATE_PRESSED"+$TAB(2)+%TBSTATE_PRESSED+$CRLF+
"%TBSTATE_ENABLED"+$TAB+%TBSTATE_ENABLED+$CRLF+
"%TBSTATE_HIDDEN"+$TAB(2)+%TBSTATE_HIDDEN+$CRLF+
"%TBSTATE_INDETERMINATE"+$TAB+%TBSTATE_INDETERMINATE+$CRLF+
"%TBSTATE_MARKED"+$TAB(2)+%TBSTATE_MARKED+$CRLF(2)+
"Buttons report (notice the checked property is reported as 5 instead of 1):"+$CRLF+
"A"+$TAB+ToolBar_GetState(CBHNDL, %tToolbar, 1)+$CRLF+
"B"+$TAB+ToolBar_GetState(CBHNDL, %tToolbar, 2)+$CRLF+
"C"+$TAB+ToolBar_GetState(CBHNDL, %tToolbar, 3)+$CRLF
End If
End If
End Function
Maybe the problem is in the equates, and not the commands, I am not really sure.