Date: 02-16-2022
Return to Index
created by gbSnippets
'An online Toolbar control tutorial may be found at:
'http://www.garybeene.com/power/pb-tutor-controls.htm
'Primary Code:
'Syntax: Control Add Toolbar, hDlg, id&, txt$, x, y, xx, yy [, [style&] [, [exstyle&]]] [[,] Call CallBack]
Control Add Toolbar, hDlg, 500,"", 0,0,0,0
'Compilable Example: (Jose Includes)
'The following compilable code demonstrates a dialog with a Toolbar control.
'A resource file, imagelist, and toolbar buttons are used.
'Changing a button image is also demonstrated.
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Dim All
%Unicode=1
#Include "Win32API.inc"
#Resource "gbsnippets.pbr" 'misc icons
Global hDlg As DWord 'main dialog handle
Global hLst As DWord 'imagelist handke
Function PBMain()
'create dialog
Dialog New Pixels, 0, "Toolbar Test",,, 500,250, %WS_SysMenu, To hDlg
Dialog Set Color hDlg, %White, %White
Dialog Set Icon hDlg, "x"
Control Add Button, hDLg, 300, "x image in 3rd Pos", 10,100,150,25
Control Add Button, hDLg, 400, "z image in 3rd Pos", 10,140,150,25
'add toolbar
Control Add Toolbar, hDlg, 500,"", 0,0,0,0, %CCS_NoMoveY
'create imagelist
ImageList New Icon 16,16,32,3 To hLst
ImageList Add Icon hLst, "x" '1
ImageList Add Icon hLst, "y" '2
ImageList Add Icon hLst, "z" '3
'attach imagelist
Toolbar Set ImageList hDlg, 500, hLst, 0
'create buttons
Toolbar Add Button hDlg, 500, 1, 200, %TbStyle_Button, "x"
Toolbar Add Button hDlg, 500, 2, 201, %TbStyle_Button, "y"
Toolbar Add Button hDlg, 500, 3, 202, %TbStyle_Button, "z"
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
If CB.Msg = %WM_Command AND CB.Ctl = 300 Then
Toolbar Delete Button hDlg, 500, 3
Toolbar Add Button hDlg, 500, 1, 202, %TbStyle_Button, "z"
Dialog Redraw hDlg
End If
If CB.Msg = %WM_Command AND CB.Ctl = 400 Then
Toolbar Delete Button hDlg, 500, 3
Toolbar Add Button hDlg, 500, 3, 202, %TbStyle_Button, "z"
Dialog Redraw hDlg
End If
End Function
'gbs_00104
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm