Date: 02-16-2022
Return to Index
created by gbSnippets
'Compilable Example: (Jose Includes)
#Compiler PBWin 10
#Compile EXE "gbjournal.exe"
#Dim All
%Unicode=1
#Include "win32api.inc"
#Resource Icon bluesave, "bluesave.ico"
#Resource Icon graysave, "graysave.ico"
%IDC_Toolbar = 501
%IDC_Disable = 502
%IDT_Save = 503
Global hDlg,hToolbar,hImageListEnabled,hImageListDisabled As Dword, DisabledState As Long
Function PBMain() As Long
Dialog New Pixels, 0, "Toolbar Test",300,300,400,300, %WS_OverlappedWindow To hDlg
Control Add Button, hDlg, %IDC_Disable, "Disable", 20,60,50,25
CreateToolbar
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Select Case Cb.Msg
Case %WM_Command
Select Case Cb.Ctl
Case %IDC_Disable
DisabledState = DisabledState Xor 1
Toolbar Set State hDlg, %IDC_Toolbar, ByCmd %IDT_Save, IIf(DisabledState,%TBState_Disabled,%TBState_Enabled)
End Select
End Select
End Function
Sub CreateToolbar
'add toolbar
Control Add Toolbar, hDlg, %IDC_Toolbar,"", 0,0,0,0
'create imagelist
ImageList New Icon 24,24,24,1 To hImageListEnabled
ImageList Add Icon hImageListEnabled, "bluesave"
Toolbar Set ImageList hDlg, %IDC_Toolbar, hImageListEnabled, 0
'attach imagelist
ImageList New Icon 24,24,24,1 To hImageListDisabled
ImageList Add Icon hImageListDisabled, "graysave"
Toolbar Set ImageList hDlg, %IDC_Toolbar, hImageListDisabled, 1
'create buttons
Toolbar Add Button hDlg, %IDC_Toolbar, 1, %IDT_Save, %TbStyle_Button, "Save"
End Sub
'gbs_00816
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm