Page 1 of 1

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

Posted: Mon Nov 03, 2003 10:30 pm
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")

Posted: Mon Nov 03, 2003 11:40 pm
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.

Posted: Wed Nov 05, 2003 7:33 am
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.

Posted: Wed Nov 05, 2003 7:36 am
by PB
Good to see you're still lurking here, Danilo. ;)

Posted: Wed Nov 05, 2003 8:57 am
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

Posted: Wed Nov 05, 2003 7:11 pm
by Kale
Thanks Danilo that works perfectly :D