Cool, v56 final fixes my toolbar code. Windows only. Note, an empty image is not required to create a same size separator.
EDIT: removed link to bug url per Fred's note below.
Code: Select all
EnableExplicit
Global.i evWW, evM, tbn
Global.l tb_maxSize = 16
Macro Min(x, y)
(Bool((x) <= (y)) * (x) + Bool((y) < (x)) * (y))
EndMacro
Macro Max(x, y)
(Bool((x) >= (y)) * (x) + Bool((y) > (x)) * (y))
EndMacro
Macro MAKELONG(wLo, wHi)
((wLo) & $FFFF) | (wHi) << 16
EndMacro
Procedure tb_images(tb_maxSize)
CreateImage(0, tb_maxSize, tb_maxSize)
StartDrawing(ImageOutput(0))
Box(0, 0, tb_maxSize, tb_maxSize, #Red)
DrawText(2,0,"-")
StopDrawing()
CreateImage(2, tb_maxSize, tb_maxSize)
StartDrawing(ImageOutput(2))
Box(0, 0, tb_maxSize, tb_maxSize, #Blue)
DrawText(2,0,"+")
StopDrawing()
EndProcedure
Procedure tb_scale(tb_maxSize)
If tb_maxSize > 16
tbn = CreateToolBar(#PB_Any, WindowID(0), #PB_ToolBar_Large)
Protected.i tbh = ToolBarID(tbn)
If tbh
ResizeImage(0,tb_maxSize,tb_maxSize,#PB_Image_Smooth)
ResizeImage(2,tb_maxSize,tb_maxSize,#PB_Image_Smooth)
If 0
Protected.i hTBimgList, hTBimgList2
hTBimgList = SendMessage_(tbh, #TB_GETIMAGELIST, 0, 0)
hTBimgList2 = ImageList_Duplicate_(hTBimgList)
ImageList_Destroy_(hTBimgList)
Swap hTBimgList, hTBimgList2
ImageList_SetIconSize_(hTBimgList, tb_maxSize, tb_maxSize)
SendMessage_(tbh, #TB_SETIMAGELIST, 0, hTBimgList)
SendMessage_(tbh, #TB_SETBITMAPSIZE, 0, MAKELONG(tb_maxSize,tb_maxSize))
SendMessage_(tbh, #TB_SETBITMAPSIZE, 0, MAKELONG(tb_maxSize,tb_maxSize))
SendMessage_(tbh, #TB_SETBUTTONSIZE, 0, MAKELONG(tb_maxSize,tb_maxSize))
SendMessage_(tbh, #TB_AUTOSIZE, 0, 0)
SendMessage_(tbh, #TB_AUTOSIZE, 0, 0)
Else
hTBimgList = SendMessage_(tbh, #TB_GETIMAGELIST, 0, 0)
ImageList_SetIconSize_(hTBimgList, tb_maxSize, tb_maxSize)
SendMessage_(tbh, #TB_SETBITMAPSIZE, 0, MAKELONG(tb_maxSize,tb_maxSize))
SendMessage_(tbh, #TB_AUTOSIZE, 0, 0)
EndIf
ToolBarImageButton(0, ImageID(0))
ToolBarSeparator()
ToolBarImageButton(1, 0) ; same size separator using empty image.
ToolBarImageButton(2, ImageID(2))
EndIf
Else
tbn = CreateToolBar(#PB_Any, WindowID(0), #PB_ToolBar_Small)
tbh = ToolBarID(tbn)
If tbh
ToolBarImageButton(0, ImageID(0))
ToolBarSeparator()
ToolBarImageButton(1, 0) ; same size separator using empty image.
ToolBarImageButton(2, ImageID(2))
EndIf
EndIf
EndProcedure
If OpenWindow(0, 0, 0, 500, 500, "v56 - Scaled Toolbar & Wide Separator(Windows only)", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
tb_images(16)
tb_scale(16)
StartDrawing(WindowOutput(0))
Box(0,0,500,500,#White)
DrawText(5,280,"Click the '+' image tool bar.")
StopDrawing()
SmartWindowRefresh(0,1)
Repeat
evWW = WaitWindowEvent()
If evWW = #PB_Event_Menu
evM = EventMenu()
FreeToolBar(#PB_All)
If evM = 0
tb_maxSize = max(tb_maxSize - 16, 16)
Debug "tb#" + evM + ", " + Str(tb_maxSize)
ElseIf evM = 2
tb_maxSize = max(tb_maxSize + 16, 16)
Debug "tb#" + evM + ", " + Str(tb_maxSize)
EndIf
tb_scale(tb_maxSize)
StartDrawing(WindowOutput(0))
Box(0,0,500,500,#White)
If tb_maxSize > 16
DrawText(5,280,"Click image tool bars.")
DrawText(5,310,"Toolbar resized to " + Str(tb_maxSize) + " pixels.")
Else
DrawText(5,280,"Click image '+' tool bar.")
EndIf
DrawImage(ImageID(0), 100, 350)
DrawImage(ImageID(2), 300, 350)
StopDrawing()
ElseIf evWW = #PB_Event_CloseWindow
Break
EndIf
ForEver
EndIf