It is currently Fri Dec 13, 2019 5:37 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Toolbar...DropDownButton... How to
PostPosted: Sat Jun 29, 2019 3:27 pm 
Offline
Enthusiast
Enthusiast

Joined: Wed Aug 03, 2011 4:52 am
Posts: 215
Location: Beirut, Lebanon
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


_________________
PureBasic: Surprisingly simple, diabolically powerful


Top
 Profile  
Reply with quote  
 Post subject: Re: Toolbar...DropDownButton... How to
PostPosted: Sat Jun 29, 2019 3:40 pm 
Offline
Moderator
Moderator
User avatar

Joined: Thu Dec 31, 2009 11:05 pm
Posts: 1108
Location: Berlin (Germany)
viewtopic.php?p=367476#p367476

_________________
ImageImageImageImage Image


Top
 Profile  
Reply with quote  
 Post subject: Re: Toolbar...DropDownButton... How to
PostPosted: Sat Jun 29, 2019 5:12 pm 
Offline
Addict
Addict
User avatar

Joined: Wed Aug 24, 2005 4:02 pm
Posts: 1031
Location: Germany
ToolBarExModule.pbi

_________________
Sorry for my English. My language is German.
(Translated with http://www.DeepL.com/Translator)

Download of PureBasic - Modules

[Windows 10 x64] [PB V5.7x]


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: oreopa and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye