PureBasic Forum
http://forums.purebasic.com/english/

Toolbar...DropDownButton... How to
http://forums.purebasic.com/english/viewtopic.php?f=13&t=73106
Page 1 of 1

Author:  morosh [ Sat Jun 29, 2019 3:27 pm ]
Post subject:  Toolbar...DropDownButton... How to

Hello:
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:
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


Author:  RSBasic [ Sat Jun 29, 2019 3:40 pm ]
Post subject:  Re: Toolbar...DropDownButton... How to

viewtopic.php?p=367476#p367476

Author:  Thorsten1867 [ Sat Jun 29, 2019 5:12 pm ]
Post subject:  Re: Toolbar...DropDownButton... How to

ToolBarExModule.pbi

Page 1 of 1 All times are UTC + 1 hour
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/