Date: 02-16-2022
Return to Index
created by gbSnippets
'Several standard bitmaps are available from the comctl32.dll file. These
'bitmaps can be used in a Toolbar control as an alternative to using images
'from a resource file (*.pbr). The approach creates an imagelist without
'having to use the DDT imagelist commands.
'Primary Code:
'The TBAddBitmap structure is used to define the bitmap
'used to create an imagelist for the toolbar.
Dim BMP As TBADDBITMAP
BMP.hInst = %HINST_COMMCTRL
BMP.nID = %IDB_STD_SMALL_COLOR
SendMessage hToolbar, %TB_ADDBITMAP, 0, VarPTR(BMP)
'The six bitmaps available in comctl32.dll are:
IDB_VIEW_LARGE_COLOR
IDB_VIEW_SMALL_COLOR
IDB_STD_LARGE_COLOR
IDB_STD_SMALL_COLOR
IDB_HIST_LARGE_COLOR
IDB_HIST_SMALL_COLOR
'PowerBASIC equates describing the individual images in the six bitmaps are:
HIST_BACK, HIST_FORWARD, HIST_FAVORITES, HIST_ADDTOFAVORITES, HIST_VIEWTREE
STD_CUT, STD_COPY, STD_PASTE, STD_UNDO, STD_REDOW, STD_DELETE, STD_FILENEW
STD_FILEOPEN, STD_FILESAVE, STD_PRINTPRE, STD_PROPERTIES, STD_HELP, STD_FIND
STD_REPLACE, STD_PRINT
VIEW_LARGEICONS, VIEW_SMALLICONS, VIEW_LIST, VIEW_DETAILS, VIEW_SORTNAME
VIEW_SORTSIZE, VIEW_SORTDATE, VIEW_SORTTYPE, VIEW_PARENTFOLDER
VIEW_NETCONNECT, VIEW_NETDISCONNECT, VIEW_NEWFOLDER
'Compilable Example: (Jose Includes)
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Dim All
%Unicode=1
#Include "Win32API.inc"
#Include "CommCtrl.inc"
Global hDlg As DWord, hLst As DWord, hToolbar as DWord
%IDC_Toolbar = 700
Function PBMain()
'create dialog
Dialog New Pixels, 0, "Toolbar Test",,, 500,250, %WS_SysMenu, To hDlg
'add toolbar
Control Add Toolbar, hDlg, %IDC_Toolbar,"", 0,0,0,0
Control Handle hDlg, %IDC_Toolbar to hToolbar
'add standard bitmaps to imagelist
Dim BMP As TBADDBITMAP
BMP.hInst = %HINST_COMMCTRL
BMP.nID = %IDB_STD_SMALL_COLOR
Control Send hDlg, %IDC_Toolbar, %TB_ADDBITMAP, 0, VarPTR(BMP)
'create buttons
Toolbar Add Button hDlg, %IDC_Toolbar, %STD_FILENEW+1, 200, %TbStyle_Button, "New"
Toolbar Add Button hDlg, %IDC_Toolbar, %STD_FILEOPEN+1, 201, %TbStyle_Button, "Open"
'show the dialog
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
If CB.Msg = %WM_Command AND CB.Ctl = 200 Then MsgBox "New"
If CB.Msg = %WM_Command AND CB.Ctl = 201 Then MsgBox "Open"
End Function
'gbs_00288
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm