I tried to implement a dropdown button in a toolbar, I tried to use an example from old PBOSL, it didn't run in 64 bits mode. It seems that I need to translate some functions to win api (UpdateTB(), GetTBbuttonRect ).
Any help is appreciated.
thank you
Code: Select all
UsePNGImageDecoder()
Define sizex.a, sizey.a, TB.l, TBIL.l
CatchImage(0,?but1)
CatchImage(1,?but2)
sizex = 4*ImageWidth(0)
sizey= 2*ImageHeight(0)
If CreatePopupMenu(100)
MenuItem(10, "MenuID 10")
MenuItem(20, "MenuID 20")
EndIf
Procedure mycallback(hWnd, Msg, wParam, lParam)
Define Result.l, *nmTB.NMTOOLBAR, rect.RECT
Result = #PB_ProcessPureBasicEvents
Select Msg
Case #WM_SIZE
UpdateTB(0)
Case #WM_NOTIFY
*nmTB.NMTOOLBAR = lParam
Select *nmTB\hdr\code
Case #TBN_DROPDOWN
GetTBbuttonRect(*nmTB\iItem,rect.RECT)
If *nmTB\iItem = 11
DisplayPopupMenu(100,hWnd,rect\left,rect\bottom)
EndIf
Result = #TBDDRET_DEFAULT
EndSelect
EndSelect
;UpdateTB(0)
ProcedureReturn Result
EndProcedure
OpenWindow(0,0,0,600,200,"ToolBar",#PB_Window_SystemMenu | #PB_Window_ScreenCentered)
TB = CreateToolBar(1,WindowID(0))
TBIL = SendMessage_(TB, #TB_GETIMAGELIST , 0, 0)
ImageList_SetIconSize_(TBIL,sizex,sizey)
SendMessage_(TB, #TB_SETBUTTONSIZE, 0, (sizex|sizey << 16))
SendMessage_(TB, #TB_AUTOSIZE, 0, 0)
ToolBarImageButton(10,ImageID(0))
ToolBarImageButton(11,ImageID(1))
SetWindowCallback(@mycallback(), 0)
While WaitWindowEvent() ! #PB_Event_CloseWindow : Wend
DataSection
but1:
IncludeBinary #PB_Compiler_Home+"Examples\Sources\Data\ToolBar\new.png"
but2:
IncludeBinary #PB_Compiler_Home+"Examples\Sources\Data\ToolBar\open.png"
EndDataSection