I'm not exactly sure how PB creates the ToolBar and it's ImageList, so if there is a better way, I'm all ears.
I first tried by using
Code: Select all
SendMessage_(hTB, #TB_SETBITMAPSIZE, 0, MakeLong(32,32))
SendMessage_(hTB, #TB_SETBUTTONSIZE, 0, MakeLong(36,36))
but that didin't work. I'm guessing this is because the ImageList is created along with the ToolBar, thus disallowing the changes in size. That led me to this, where I replace the original ImageList with a resized copy of itself.
Code: Select all
#TB_SETIMAGELIST = #WM_USER + 48
#TB_GETIMAGELIST = #WM_USER + 49
Procedure MakeLong(lo.w, hi.w)
ProcedureReturn (hi * $10000) | (lo & $FFFF)
EndProcedure
;--> create some cheesy images to use for toolbar
hFont = LoadFont(0, "Wingdings", 22)
CreateImage(0, 32, 32)
StartDrawing(ImageOutput())
FrontColor(50, 200, 50)
BackColor(228, 228, 228)
DrawingFont(hFont)
DrawText(Chr(34))
StopDrawing()
CreateImage(1, 32, 32)
StartDrawing(ImageOutput())
FrontColor(50, 200, 50)
BackColor(228, 228, 228)
DrawingFont(hFont)
DrawText(Chr(48))
StopDrawing()
CreateImage(2, 32, 32)
StartDrawing(ImageOutput())
FrontColor(50, 200, 50)
BackColor(228, 228, 228)
DrawingFont(hFont)
DrawText(Chr(42))
StopDrawing()
If OpenWindow(0, 0, 0, 350, 250, #PB_Window_SystemMenu |#PB_Window_SizeGadget | #PB_Window_ScreenCentered, "Vertical ToolBar")
hTB = CreateToolBar(0, WindowID())
hOldIList = SendMessage_(hTB, #TB_GETIMAGELIST, 0, 0);
hNewIList = ImageList_Duplicate_(hOldIList)
ImageList_Destroy_(hOldIList)
ImageList_SetIconSize_(hNewIList, 32, 32)
SendMessage_(hTB, #TB_SETIMAGELIST, 0, hNewIList)
SendMessage_(hTB, #TB_SETBITMAPSIZE, 0, MakeLong(32,32))
SendMessage_(hTB, #TB_SETBUTTONSIZE, 0, MakeLong(36,36))
SendMessage_(hTB, #TB_AUTOSIZE, 0, 0)
ToolBarImageButton(0, UseImage(0))
ToolBarImageButton(1, UseImage(1))
ToolBarImageButton(2, UseImage(2))
Repeat
EventID = WaitWindowEvent()
If EventID = #PB_Event_Menu
Debug "ToolBar ID: "+Str(EventMenuID())
EndIf
Until EventID = #PB_Event_CloseWindow
ImageList_Destroy_(hNewIList)
EndIf