@Danilo RE: ToolBarPro Lib and Dropdown Buttons...

Everything else that doesn't fall into one of the other PB categories.
Kale
PureBasic Expert
PureBasic Expert
Posts: 3000
Joined: Fri Apr 25, 2003 6:03 pm
Location: Lincoln, UK
Contact:

@Danilo RE: ToolBarPro Lib and Dropdown Buttons...

Post by Kale »

From the ToolBarPro help:
The ´normal part´ of the Button acts like a standard button, but when you press the little arrow, the Toolbar sends a #TBN_DROPDOWN notification to the main-window. If you get this message you can display a popup-menu with options etc..
I am writting an app which uses dropdown buttons, but when used, the little side button which produces the '#TBN_DROPDOWN' message can not be pressed. Also the '#TBN_DROPDOWN' constant does not seem to be declared. Any ideas?

Code i am using:

Code: Select all

CreateTB(0, WindowID(#WINDOW_ROOT), 40, 30, #TBpro_FLAT | #TBpro_BORDER)
Buttons = CatchImage(#IMAGE_BUTTONS, ?Buttons)
Mask = CatchImage(#IMAGE_MASK, ?Mask)

SetTBimage(Buttons, Mask, #TBpro_NORMAL)

AddTBbutton(#TOOLBAR_NEW, 1, #TBpro_Button) : SetTBbuttonText(#TOOLBAR_NEW, "New")
AddTBbutton(#TOOLBAR_REPLY, 2, #TBpro_Button) : SetTBbuttonText(#TOOLBAR_REPLY, "Reply")
AddTBbutton(#TOOLBAR_FORWARD, 3, #TBpro_Button) : SetTBbuttonText(#TOOLBAR_FORWARD, "Forward")
AddTBseparator()
AddTBbutton(#TOOLBAR_DELETE, 4, #TBpro_Button) : SetTBbuttonText(#TOOLBAR_DELETE, "Delete")
AddTBseparator()
AddTBbutton(#TOOLBAR_SENDRECEIVE, 5, #TBpro_DropdownButton) : SetTBbuttonText(#TOOLBAR_SENDRECEIVE, "Send/Recv")
AddTBseparator()
AddTBbutton(#TOOLBAR_ADDRESSES, 6, #TBpro_Button) : SetTBbuttonText(#TOOLBAR_ADDRESSES, "Addresses")
AddTBbutton(#TOOLBAR_FIND, 7, #TBpro_DropdownButton) : SetTBbuttonText(#TOOLBAR_FIND, "Find")
--Kale

Image
User avatar
fsw
Addict
Addict
Posts: 1603
Joined: Tue Apr 29, 2003 9:18 pm
Location: North by Northwest

Post by fsw »

TBN_DROPDOWN is a WinAPI constant.

Code: Select all

#define 	TBN_FIRST   (0U-700U)
#define 	TBN_DROPDOWN   (TBN_FIRST - 10)
TBN_FIRST is in the Windows.res file.
so if you do

Code: Select all

#TBN_DROPDOWN = #TBN_FIRST - 10
it should work...

I don't use Danilo's library - so if this doesn't work out ........sorry.

I am to provide the public with beneficial shocks.
Alfred Hitshock
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Post by Danilo »

Code: Select all

#TBDDRET_DEFAULT      = 0 ; The drop-down was handled. 
#TBDDRET_NODEFAULT    = 1 ; The drop-down was not handled. 
#TBDDRET_TREATPRESSED = 2 ; The drop-down was handled, but treat the button like a regular button. 
#TBN_DROPDOWN         = #TBN_FIRST - 10

Procedure WindowProc(hWnd,Msg,wParam,lParam)
  WindowProc = #PB_ProcessPureBasicEvents
  Select Msg
    Case #WM_SIZE
      UpdateTB(0)
    Case #WM_NOTIFY
      *nmTB.NMTOOLBAR = lParam
      Select *nmTB\hdr\code
        Case #TBN_DROPDOWN
          ;Beep_(800,10)
          GetTBbuttonRect(*nmTB\iItem,rect.RECT)
          DisplayPopupMenu(1,hWnd,rect\left,rect\bottom)
          WindowProc = #TBDDRET_DEFAULT
      EndSelect
  EndSelect

  ;UpdateTB(0)
  ProcedureReturn WindowProc
EndProcedure

If CreatePopupMenu(1)
  MenuItem(1, "Aliases...")
  MenuItem(2, "Popups...")
  MenuItem(3, "Remote...")
  MenuBar()
  MenuItem(4, "Addresses...")
  MenuBar()
  MenuItem(5, "Finger...")
  MenuItem(6, "Timer...")
  MenuBar()
  MenuItem(7, "Colors...")
  MenuItem(8, "Font...")
EndIf

hWnd = OpenWindow(0,0,0,200,200,#PB_Window_SystemMenu|#PB_Window_ScreenCentered,"DropDown")
  CreateTB(0,hWnd,24,24,#TBpro_TRANSPARENT|#TBpro_FLAT)
    SetTBimage(0,0,#TBpro_NORMAL)
    SetTBimage(0,0,#TBpro_Hot)
    SetTBimage(0,0,#TBpro_Disabled)
    AddTBsysIcons()

  SetWindowCallback(@WindowProc())

  For a = 1 To 32
      AddTBbutton(599+a,#TBpro_CUT+a-1,#TBpro_DropdownButton)
      If a % 10 = 0 : AddTBbreak()
      Else          : AddTBseparator() : EndIf
      SetTBbuttonTooltip(599+a,"DropDown Button "+Str(a))
  Next a

  ResizeWindow(TBwidth(),TBheight())
  UpdateTB()

Repeat
  Select WaitWindowEvent()
    Case #PB_EventCloseWindow : End
    Case #PB_EventGadget
      GadgetID = EventGadgetID()
      If GadgetID >= 600 And GadgetID <= 631
        MessageRequester("INFO","You pressed the Toolbar button "+Chr(13)+"with the ID: "+Str(GadgetID),#MB_ICONINFORMATION)
      EndIf
    Case #PB_Event_Menu
      MessageRequester("INFO","MenuID: "+Str(EventMenuID()),#MB_ICONINFORMATION)
  EndSelect
ForEver
As you can see, you need to handle it in the window callback,
but its easy to do.

PureBasic didnt have the '#PB_ProcessPureBasicEvents' return
value check at the time i wrote the library, so it wasnt possible
to use the DropDown buttons. No problem now. :wink:

*nmTB\iItem in the callback is your #ButtonID.
cya,
...Danilo
...:-=< http://codedan.net/work >=-:...
-= FaceBook.com/DaniloKrahn =-
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

Good to see you're still lurking here, Danilo. ;)
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Post by Danilo »

Kale wrote me a private message, so i got eMail.

I read your forum only when somebody writes me a private message
or when somebody in the PureBasic-Chat tells me that there is a topic for me.

I just dont have the time to read 1.000 (mostly) beginner messages
every day. I read and moderate the german PB forum... thats enough.

The PB community is too big now... :D
cya,
...Danilo
...:-=< http://codedan.net/work >=-:...
-= FaceBook.com/DaniloKrahn =-
Kale
PureBasic Expert
PureBasic Expert
Posts: 3000
Joined: Fri Apr 25, 2003 6:03 pm
Location: Lincoln, UK
Contact:

Post by Kale »

Thanks Danilo that works perfectly :D
--Kale

Image
Post Reply