Toolbar+ dropdown arrow, popupmenu, toggle buttons, gadgets
Very nice work. Thanks
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
On my WinXP (PB 4.30 final, XP Classic Skin) in the upper toolbar it shows only "Toolbar Plus" text,, icons for "New" and "Save" and no other gadgets, only separators. In the lower toolbar anything works okay.
Edit: tested it with standard XP design, but still the same problem.
Edit: tested it with standard XP design, but still the same problem.
My PC
Ryzen 9 5950, 64 GB RAM, nVidia RTX A4000, Win 10
Ryzen 7 1700, 32 GB RAM, nVidia RTX A2000, Win 10
Ryzen 9 5950, 64 GB RAM, nVidia RTX A4000, Win 10
Ryzen 7 1700, 32 GB RAM, nVidia RTX A2000, Win 10
Re: Toolbar+ dropdown arrow, popupmenu, toggle buttons, gadgets
Hi,
There is a problem with the height of the bar with PB 4.40.
Regards
There is a problem with the height of the bar with PB 4.40.
Regards
Re: Toolbar+ dropdown arrow, popupmenu, toggle buttons, gadgets
a screenshot could help me to understand your problem.
win10 x64 5.72 | IDE | PB plugin | Tools | Sprite | JSON | visual tool
Re: Toolbar+ dropdown arrow, popupmenu, toggle buttons, gadgets
Nice! The only thing I've noticed is that the url is invisible until I click on it. (Windows XP, SP3, classic theme).
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )
- Rook Zimbabwe
- Addict
- Posts: 4326
- Joined: Tue Jan 02, 2007 8:16 pm
- Location: Cypress TX
- Contact:
Re: Toolbar+ dropdown arrow, popupmenu, toggle buttons, gadgets
Eddy's Toolbar Pro!!! I love it. Gotta read it better now and see if I can make it work in my applications... maybe dash off a word processor or something...
Excellent work buddy!
Excellent work buddy!
Re: Toolbar+ dropdown arrow, popupmenu, toggle buttons, gadg
Simply excellent!
FYI, it works fine in PB v4.50 too.
FYI, it works fine in PB v4.50 too.
Re: Toolbar+ dropdown arrow, popupmenu, toggle buttons, gadg
I came across this thread while I was looking for a way to enhance PBs ToolBar-Functions.
Thanks a lot eddy, for this really nice and helpful peace of code.
Because your last update was around 2 years ago, made for for PB 4.30 and does not support EnableExplicit, I've made some slight changes (I hope that's OK for you).
So, here is a PB 4.51 tested Version, which works fine with EnableExplicit.
The Include (just save as "Lib_ToolBarPlus.pbi") :
A Template for the needed CallBack (Lib_ToolBarPlus_CallBack-Template.pb)
And last but not least, the slightly changed Example to test the ToolBarPlus (ToolBarPlus_Demo.pb) :
Thanks again for the great work eddy.
Thanks a lot eddy, for this really nice and helpful peace of code.
Because your last update was around 2 years ago, made for for PB 4.30 and does not support EnableExplicit, I've made some slight changes (I hope that's OK for you).
So, here is a PB 4.51 tested Version, which works fine with EnableExplicit.
The Include (just save as "Lib_ToolBarPlus.pbi") :
Code: Select all
;/// ToolbarPlus for PB 4.XX (open source)
CompilerIf Defined(INCLUDE_TOOLBARPLUS, #PB_Constant) = #False
#INCLUDE_TOOLBARPLUS = #True
;{ ----- Utils / Macros
Macro ValidateGadgetID(Result, ID, gadget)
If ID=#PB_Any
ID=Result
gadget=GadgetID(ID)
Else
gadget=Result
EndIf
EndMacro
;}
;{ ----- Structures, Constants and Variables
Structure ToolbarPlusMenu
ToolbarPlusParent.l
ToolbarPlus.l
ToolbarPlusID.l
ButtonID.l
ButtonArrow.l
MenuID.l
EndStructure
Global NewList ToolbarPlusMenu.ToolbarPlusMenu()
Define ToolbarPlus
Define ToolbarPlusParent
Define ToolbarPlusID
Define ToolbarPlus_Toolbar.l
Define ToolbarPlus_ToolbarParent.l
Define ToolbarPlus_ButtonID.l
Define ToolbarPlus_PressedArrow.b
Define ToolbarPlus_PopupX.l
Define ToolbarPlus_PopupY.l
CompilerIf Defined(TBN_DROPDOWN, #PB_Constant)=#False
#TBN_DROPDOWN=-710
#TBSTYLE_DROPDOWN=$8
#BTNS_WHOLEDROPDOWN=$80
CompilerEndIf
;}
;{ ----- ToolbarPlus Functions
ProcedureDLL ToolbarContainerHeight () ;Get default height for toolbar gadget
Shared ToolbarPlus
Protected sz.RECT
If ToolbarPlus
GetClientRect_(ToolbarPlus, sz)
ProcedureReturn sz\bottom-sz\top
EndIf
EndProcedure
ProcedureDLL ToolbarCenterGadget (ID) ;Center gadget vertically inside ToolbarContainer
ResizeGadget(ID, #PB_Ignore, GadgetY(ID)+(ToolbarContainerHeight()-GadgetHeight(ID))/2, #PB_Ignore, #PB_Ignore)
EndProcedure
ProcedureDLL SetToolBarArrow (SimpleArrow.b=#False) ;Creates a drop-down style button
Shared ToolbarPlusParent
Shared ToolbarPlus
Shared ToolbarPlusID
;----- get button
Protected pos.l=SendMessage_(ToolbarPlus, #TB_BUTTONCOUNT, 0, 0)-1
Protected button.TBBUTTON
SendMessage_(ToolbarPlus, #TB_GETBUTTON, pos, @button)
If (button\fsStyle & #TBSTYLE_SEP) : ProcedureReturn 0 : EndIf
;----- change button style
If SimpleArrow
button\fsStyle=button\fsStyle | #TBSTYLE_DROPDOWN | #BTNS_WHOLEDROPDOWN
Else
button\fsStyle=button\fsStyle | #TBSTYLE_DROPDOWN
EndIf
SendMessage_(ToolbarPlus, #TB_DELETEBUTTON, pos, 0)
SendMessage_(ToolbarPlus, #TB_INSERTBUTTON, pos+1, button)
EndProcedure
ProcedureDLL SetToolBarMenu (MenuID) ;Specifies that the button will display a popup menu.
Shared ToolbarPlusParent
Shared ToolbarPlus
Shared ToolbarPlusID
;----- get button
Protected pos.l=SendMessage_(ToolbarPlus, #TB_BUTTONCOUNT, 0, 0)-1
Protected button.TBBUTTON
SendMessage_(ToolbarPlus, #TB_GETBUTTON, pos, @button)
If (button\fsStyle & #TBSTYLE_SEP) : ProcedureReturn 0 : EndIf
;----- get dropdown-arrow mode
Protected ButtonArrow=0
If (button\fsStyle & #TBSTYLE_DROPDOWN) : ButtonArrow=1 : EndIf
AddElement(ToolbarPlusMenu())
ToolbarPlusMenu()\ToolbarPlusParent = ToolbarPlusParent
ToolbarPlusMenu()\ToolbarPlus = ToolbarPlus
ToolbarPlusMenu()\ToolbarPlusID = ToolbarPlusID
ToolbarPlusMenu()\ButtonArrow = ButtonArrow
ToolbarPlusMenu()\ButtonID = button\idCommand
ToolbarPlusMenu()\MenuID = MenuID
EndProcedure
ProcedureDLL SetToolBarToggle (Grouped)
Shared ToolbarPlusParent
Shared ToolbarPlus
Shared ToolbarPlusID
;get button info
Protected pos.l=SendMessage_(ToolbarPlus, #TB_BUTTONCOUNT, 0, 0)-1
Protected button.TBBUTTON
SendMessage_(ToolbarPlus, #TB_GETBUTTON, pos, @button)
If (button\fsStyle & #TBSTYLE_SEP) : ProcedureReturn 0 : EndIf
;change button
If Grouped
button\fsStyle=button\fsStyle | #TBSTYLE_CHECKGROUP
Else
button\fsStyle=button\fsStyle | #TBSTYLE_CHECK
EndIf
SendMessage_(ToolbarPlus, #TB_DELETEBUTTON, pos, 0)
SendMessage_(ToolbarPlus, #TB_INSERTBUTTON, pos+1, button)
EndProcedure
ProcedureDLL ToolBarPlusCB (Window.l, message.l, wParam.l, lParam.l, Result.l) ;ToolbarPlus callback procedure.
Shared ToolbarPlus_Toolbar.l
Shared ToolbarPlus_ToolbarParent.l
Shared ToolbarPlus_ButtonID.l
Shared ToolbarPlus_PressedArrow.b
Shared ToolbarPlus_PopupX.l
Shared ToolbarPlus_PopupY.l
Protected *msgTB.NMTOOLBAR
Protected rc.RECT
ToolbarPlus_Toolbar = 0
ToolbarPlus_ButtonID = 0
ToolbarPlus_PressedArrow = 0
ToolbarPlus_PopupX = 0
ToolbarPlus_PopupY = 0
If Result<>#PB_ProcessPureBasicEvents : ProcedureReturn Result : EndIf
;----- detect toolbar events
Select message
Case #WM_COMMAND
ToolbarPlus_Toolbar=lParam
ToolbarPlus_ButtonID=wParam ;(wParam -> high word = 0)
ToolbarPlus_PressedArrow=0
Case #WM_NOTIFY
*msgTB = lParam
If *msgTB\hdr\code=#TBN_DROPDOWN
ToolbarPlus_Toolbar = *msgTB\hdr\hwndFrom
ToolbarPlus_ButtonID = *msgTB\iItem
ToolbarPlus_PressedArrow = 1
EndIf
EndSelect
;----- validate found results
If ToolbarPlus_Toolbar
Protected classname.s=Space(1000)
Protected lg=GetClassName_(ToolbarPlus_Toolbar, @classname, Len(classname))
classname = LCase(Left(classname, lg))
If classname = "toolbarwindow32"
SendMessage_(ToolbarPlus_Toolbar, #TB_GETRECT, ToolbarPlus_ButtonID, @rc)
MapWindowPoints_(ToolbarPlus_Toolbar, 0, @rc, 2)
ToolbarPlus_PopupX = rc\left
ToolbarPlus_PopupY = rc\bottom
ToolbarPlus_ToolbarParent = GetParent_(ToolbarPlus_Toolbar)
Else
ToolbarPlus_Toolbar = 0
ToolbarPlus_ButtonID = 0
ToolbarPlus_PressedArrow = 0
ToolbarPlus_PopupX = 0
ToolbarPlus_PopupY = 0
EndIf
EndIf
; ===================
; toolbar popup menu
; ===================
If ToolbarPlus_Toolbar
ForEach ToolbarPlusMenu()
Protected ButtonID = ToolbarPlusMenu()\ButtonID
Protected ButtonArrow = ToolbarPlusMenu()\ButtonArrow
Protected ToolbarPlusParent = ToolbarPlusMenu()\ToolbarPlusParent
Protected ToolbarPlus = ToolbarPlusMenu()\ToolbarPlus
Protected MenuID = ToolbarPlusMenu()\MenuID
If ToolbarPlus=ToolbarPlus_Toolbar And ButtonID=ToolbarPlus_ButtonID
If IsMenu(MenuID) And ButtonArrow=ToolbarPlus_PressedArrow
DisplayPopupMenu(MenuID, ToolbarPlus, ToolbarPlus_PopupX, ToolbarPlus_PopupY)
ProcedureReturn 0
EndIf
EndIf
Next
EndIf
ProcedureReturn Result
EndProcedure
ProcedureDLL ToolbarPlusCB_Toolbar () ;ToolbarPlusCB() -> active toolbar
Shared ToolbarPlus_Toolbar
ProcedureReturn ToolbarPlus_Toolbar
EndProcedure
ProcedureDLL ToolbarPlusCB_ButtonID () ;ToolbarPlusCB() -> pressed button ID
Shared ToolbarPlus_ButtonID
ProcedureReturn ToolbarPlus_ButtonID
EndProcedure
ProcedureDLL ToolbarPlusCB_PressedArrow () ;ToolbarPlusCB() -> pressed button arrow
Shared ToolbarPlus_PressedArrow
ProcedureReturn ToolbarPlus_PressedArrow
EndProcedure
ProcedureDLL ToolbarPlusCB_PopupX () ;ToolbarPlusCB() -> popup position X
Shared ToolbarPlus_PopupX
ProcedureReturn ToolbarPlus_PopupX
EndProcedure
ProcedureDLL ToolbarPlusCB_PopupY () ;ToolbarPlusCB() -> popup position Y
Shared ToolbarPlus_PopupY
ProcedureReturn ToolbarPlus_PopupY
EndProcedure
;}
;{ ----- ToolbarPlus Gadgets
ProcedureDLL CreateToolBarPlus ( ID , parent) ;Create toolbar plus
; ====================
; Create
; ====================
Shared ToolbarPlusParent
Shared ToolbarPlus
Shared ToolbarPlusID
Protected Result
Result=CreateToolBar(ID, parent)
ToolbarPlusID=ID
ToolbarPlusParent=parent
ValidateGadgetID(Result, ToolbarPlusID, ToolbarPlus)
; ====================
; Change Style
; ====================
#TB_SETEXTENDEDSTYLE = $400+84
#TB_GETEXTENDEDSTYLE = $400+85
#TBSTYLE_EX_DRAWDDARROWS = $1
Protected s=SendMessage_(ToolbarPlus, #TB_GETEXTENDEDSTYLE, 0, 0) | #TBSTYLE_EX_DRAWDDARROWS
SendMessage_(ToolbarPlus, #TB_SETEXTENDEDSTYLE, 0, s)
ProcedureReturn Result
EndProcedure
ProcedureDLL ToolbarContainer (ID , offsetX, width, flag=0) ;Add toolbar container
Shared ToolbarPlusParent
Shared ToolbarPlus
Shared ToolbarPlusID
Protected Result
; ====================
; Prepare
; ====================
Protected pos.l=SendMessage_(ToolbarPlus, #TB_BUTTONCOUNT, 0, 0)
Protected separator.TBBUTTON
Protected rc.RECT
ToolBarSeparator()
;set separator width
SendMessage_(ToolbarPlus, #TB_GETBUTTON, pos, @separator)
separator\iBitmap=width+offsetX
SendMessage_(ToolbarPlus, #TB_DELETEBUTTON, pos, 0)
SendMessage_(ToolbarPlus, #TB_INSERTBUTTON, pos, separator)
;get separator position
SendMessage_(ToolbarPlus, #TB_GETITEMRECT, pos, @rc)
; ====================
; Create
; ====================
Protected x.l=rc\left
Protected y.l=0
Protected h.l=ToolbarContainerHeight()
Protected w.l=width+offsetX
CompilerIf #PB_Compiler_Version<430
CreateGadgetList(ToolbarPlus)
CompilerElse
UseGadgetList(ToolbarPlus)
CompilerEndIf
Result=ContainerGadget(ID, x, y, w, h, flag)
ProcedureReturn Result
EndProcedure
ProcedureDLL ToolBarSpace (width=5) ;Add toolbar space
Protected Result
Result=ToolbarContainer(#PB_Any, width, 0)
CloseGadgetList()
ProcedureReturn result
EndProcedure
ProcedureDLL ToolbarComboBox (ID , offsetX, offsetY, width, height, flags=0) ;Add toolbar ComboboxGadget
Protected Result, gadget
If ToolbarContainer(#PB_Any, offsetX, width)
Result=ComboBoxGadget(ID, offsetX, offsetY, width, height, flags)
ValidateGadgetID(Result, ID, gadget)
ToolbarCenterGadget(ID)
CloseGadgetList()
ProcedureReturn Result
EndIf
EndProcedure
ProcedureDLL ToolbarCheckBox (ID , offsetX, offsetY, width, height, text$, flags=0) ;Add toolbar CheckBoxGadget
Protected Result, gadget
If ToolbarContainer(#PB_Any, offsetX, width)
Result=CheckBoxGadget(ID, offsetX, offsetY, width, height, text$, flags)
ValidateGadgetID(Result, ID, gadget)
ToolbarCenterGadget(ID)
CloseGadgetList()
ProcedureReturn Result
EndIf
EndProcedure
ProcedureDLL ToolbarOption (ID , offsetX, offsetY, width, height, text$, close.b=#False) ;Add toolbar OptionGadget (with close flag)
Static ToolbarOptionContainerID
Protected Result, gadget
If ToolbarOptionContainerID=0
; ====================
; open option list
; ====================
ToolbarOptionContainerID=ToolbarContainer(#PB_Any, offsetX, width)
Else
Shared ToolbarPlus
Protected pos.l=SendMessage_(ToolbarPlus, #TB_BUTTONCOUNT, 0, 0)
Protected separator.TBBUTTON
ToolBarSeparator()
;set separator width
SendMessage_(ToolbarPlus, #TB_GETBUTTON, pos, @separator)
separator\iBitmap=width+offsetX
SendMessage_(ToolbarPlus, #TB_DELETEBUTTON, pos, 0)
SendMessage_(ToolbarPlus, #TB_INSERTBUTTON, pos, separator)
;set container width
offsetX+GadgetWidth(ToolbarOptionContainerID)
ResizeGadget(ToolbarOptionContainerID, #PB_Ignore, #PB_Ignore, offsetX+width, #PB_Ignore)
EndIf
If ToolbarOptionContainerID
; ====================
; creation new option
; ====================
Result=OptionGadget(ID, offsetX, offsetY, width, height, text$)
ValidateGadgetID(Result, ID, gadget)
ToolbarCenterGadget(ID)
; ====================
; close option list
; ====================
If close
CloseGadgetList()
ToolbarOptionContainerID=0
EndIf
ProcedureReturn Result
EndIf
EndProcedure
ProcedureDLL ToolbarButton (ID , offsetX, offsetY, width, height, text$, flags=0) ;Add toolbar ButtonGadget
Protected Result, gadget
If ToolbarContainer(#PB_Any, offsetX, width)
Result=ButtonGadget(ID, offsetX, offsetY, width, height, text$, flags)
ValidateGadgetID(Result, ID, gadget)
ToolbarCenterGadget(ID)
CloseGadgetList()
ProcedureReturn Result
EndIf
EndProcedure
ProcedureDLL ToolbarButtonImage (ID , offsetX, offsetY, width, height, imageID, flags=0) ;Add toolbar ButtonImage
Protected Result, gadget
If ToolbarContainer(#PB_Any, offsetX, width)
CompilerIf #PB_Compiler_Version<420
Result=ButtonImageGadget(ID, offsetX, offsetY, width, height, imageID)
CompilerElse
Result=ButtonImageGadget(ID, offsetX, offsetY, width, height, imageID, flags)
CompilerEndIf
ValidateGadgetID(Result, ID, gadget)
ToolbarCenterGadget(ID)
CloseGadgetList()
ProcedureReturn Result
EndIf
EndProcedure
ProcedureDLL ToolbarString (ID , offsetX, offsetY, width, height, content$, flags=0) ;Add toolbar StringGadget
Protected Result, gadget
If ToolbarContainer(#PB_Any, offsetX, width)
Result=StringGadget(ID, offsetX, offsetY, width, height, content$, flags)
ValidateGadgetID(Result, ID, gadget)
ToolbarCenterGadget(ID)
CloseGadgetList()
ProcedureReturn Result
EndIf
EndProcedure
ProcedureDLL ToolbarIPAddress (ID , offsetX, offsetY, width, height) ;Add toolbar IPAddressGadget
Protected Result, gadget
If ToolbarContainer(#PB_Any, offsetX, width)
Result=IPAddressGadget(ID, offsetX, offsetY, width, height)
ValidateGadgetID(Result, ID, gadget)
ToolbarCenterGadget(ID)
CloseGadgetList()
ProcedureReturn Result
EndIf
EndProcedure
ProcedureDLL ToolbarHyperlink (ID , offsetX, offsetY, width, height, text$, color, flags=0) ;Add toolbar HyperLinkGadget
Protected Result, gadget
If ToolbarContainer(#PB_Any, offsetX, width)
Result=HyperLinkGadget(ID, offsetX, offsetY, width, height, text$, color, flags)
ValidateGadgetID(Result, ID, gadget)
ToolbarCenterGadget(ID)
CloseGadgetList()
ProcedureReturn Result
EndIf
EndProcedure
ProcedureDLL ToolbarDate (ID , offsetX, offsetY, width, height, formatDate$="", date=0, flags=0) ;Add toolbar DateGadget
Protected Result, gadget
If ToolbarContainer(#PB_Any, offsetX, width)
Result=DateGadget(ID, offsetX, offsetY, width, height, formatDate$, date, flags)
ValidateGadgetID(Result, ID, gadget)
ToolbarCenterGadget(ID)
CloseGadgetList()
ProcedureReturn Result
EndIf
EndProcedure
ProcedureDLL ToolbarProgressBar (ID , offsetX, offsetY, width, height, min, max, flags=0) ;Add toolbar ProgressBarGadget
Protected Result, gadget
If ToolbarContainer(#PB_Any, offsetX, width)
Result=ProgressBarGadget(ID, offsetX, offsetY, width, height, min, max, flags)
ValidateGadgetID(Result, ID, gadget)
ToolbarCenterGadget(ID)
CloseGadgetList()
ProcedureReturn Result
EndIf
EndProcedure
ProcedureDLL ToolbarSpin (ID , offsetX, offsetY, width, height, min, max, flags=0) ;Add toolbar SpinGadget
Protected Result, gadget
If ToolbarContainer(#PB_Any, offsetX, width)
Result=SpinGadget(ID, offsetX, offsetY, width, height, min, max, flags)
ValidateGadgetID(Result, ID, gadget)
ToolbarCenterGadget(ID)
CloseGadgetList()
ProcedureReturn Result
EndIf
EndProcedure
ProcedureDLL ToolbarTrackBar (ID , offsetX, offsetY, width, height, min, max, flags=0) ;Add toolbar TrackBarGadget
Protected Result, gadget
If ToolbarContainer(#PB_Any, offsetX, width)
Result=TrackBarGadget(ID, offsetX, offsetY, width, height, min, max, flags)
ValidateGadgetID(Result, ID, gadget)
ToolbarCenterGadget(ID)
CloseGadgetList()
ProcedureReturn Result
EndIf
EndProcedure
ProcedureDLL ToolbarScrollbar (ID , offsetX, offsetY, width, height, min, max, pageLegnth, flags=0) ;Add toolbar ScrollBarGadget
Protected Result, gadget
If ToolbarContainer(#PB_Any, offsetX, width)
Result=ScrollBarGadget(ID, offsetX, offsetY, width, height, min, max, pageLegnth, flags)
ValidateGadgetID(Result, ID, gadget)
ToolbarCenterGadget(ID)
CloseGadgetList()
ProcedureReturn Result
EndIf
EndProcedure
ProcedureDLL ToolbarImage (ID , offsetX, offsetY, width, height, imageID, flags=0) ;Add toolbar ImageGadget
Protected Result, gadget
If ToolbarContainer(#PB_Any, offsetX, width)
Result=ImageGadget(ID, offsetX, offsetY, width, height, imageID, flags)
ValidateGadgetID(Result, ID, gadget)
ToolbarCenterGadget(ID)
CloseGadgetList()
ProcedureReturn Result
EndIf
EndProcedure
ProcedureDLL ToolbarText (ID , offsetX, offsetY, width, height, text$, flags=0) ;Add toolbar TextGadget
Protected Result, gadget
If ToolbarContainer(#PB_Any, offsetX, width)
Result=TextGadget(ID, offsetX, offsetY, width, height, text$, flags)
ValidateGadgetID(Result, ID, gadget)
ToolbarCenterGadget(ID)
CloseGadgetList()
ProcedureReturn Result
EndIf
EndProcedure
;}
CompilerEndIf
; IDE Options = PureBasic 4.51 (Windows - x86)
; CursorPosition = 4
; Folding = QAQAAg
; EnableXP
Code: Select all
Procedure ToolBarPlusCallback(Window, message, wParam, lParam)
Protected Result=#PB_ProcessPureBasicEvents
;
;
; your code
;
; ===============================================
; Enable automatic popup menu
; ===============================================
Result=ToolBarPlusCB(Window, message, wParam, lParam, Result)
; ===============================================
; custom popup menu (without using SetToolbarMenu)
; ===============================================
If ToolbarPlusCB_Toolbar()=ToolBarID(#TOOLBAR)
If ToolbarPlusCB_ButtonID()=11 And ToolbarPlusCB_PressedArrow()=#False
Protected owner=ToolbarPlusCB_Toolbar()
Protected x=ToolbarPlusCB_PopupX()
Protected y=ToolbarPlusCB_PopupY()
DisplayPopupMenu(100, owner, x, y)
ProcedureReturn 1
EndIf
EndIf
;
;
; your code
;
ProcedureReturn Result
EndProcedure
Code: Select all
; ====================
; ToolbarPlus EXAMPLE
; ====================
EnableExplicit
XIncludeFile "..\Includes\Lib_ToolBarPlus.pbi"
Enumeration ;{ ----- Gadgets
#WIN=0
#TOOLBAR
#BUTTON
#COMBO
#STRINGS
#CHECK
#BAR
#BAR2
#TEXT
#CONTAINER_BOTTOM
#TOOLBAR_BOTTOM
#SPIN
#IPADRESS
EndEnumeration ;}
Procedure ToolBarPlusCallback(Window, message, wParam, lParam)
Protected Result=#PB_ProcessPureBasicEvents
;
;
; your code
;
; ===============================================
; Enable automatic popup menu
; ===============================================
Result=ToolBarPlusCB(Window, message, wParam, lParam, Result)
; ===============================================
; custom popup menu (without using SetToolbarMenu)
; ===============================================
If ToolbarPlusCB_Toolbar()=ToolBarID(#TOOLBAR)
If ToolbarPlusCB_ButtonID()=11 And ToolbarPlusCB_PressedArrow()=#False
Protected owner=ToolbarPlusCB_Toolbar()
Protected x=ToolbarPlusCB_PopupX()
Protected y=ToolbarPlusCB_PopupY()
DisplayPopupMenu(100, owner, x, y)
ProcedureReturn 1
EndIf
EndIf
;
;
; your code
;
ProcedureReturn Result
EndProcedure
Procedure CreateMainWindow()
If OpenWindow(#WIN, 100, 100, 700, 200, "Toolbar Plus For PB 4.X", #PB_Window_SystemMenu | #PB_Window_SizeGadget)
;{ ----- CREATE TOOLBAR TOP
CreateToolBarPlus(#TOOLBAR, WindowID(#WIN))
ToolbarText(#TEXT, 0, 0, 60, 14, "ToolbarPlus")
ToolBarSpace(40)
ToolBarStandardButton(10, #PB_ToolBarIcon_New, #PB_ToolBar_Toggle)
ToolBarStandardButton(11, #PB_ToolBarIcon_Save)
ToolBarSeparator()
CompilerIf #PB_Compiler_Version < 430
ToolbarCombobox(#COMBO, 0, 0, 40, 500)
CompilerElse
ToolbarCombobox(#COMBO, 0, 0, 40, #PB_Ignore)
CompilerEndIf
ToolBarSeparator()
ToolbarButton(#BUTTON, 0, 0, 40, ToolbarContainerHeight()-2, "OK", #PB_Button_Toggle)
ToolBarSeparator()
ToolbarString(#STRINGS, 0, 0, 50, 20, "String", #PB_String_UpperCase)
ToolbarCheckBox(#CHECK, 5, 0, 70, 20, "CheckMe")
ToolBarSeparator()
ToolbarOption(#PB_Any, 0, 0, 30, 20, "1")
ToolbarOption(#PB_Any, 0, 0, 30, 20, "2")
ToolbarOption(#PB_Any, 0, 0, 30, 20, "3", #True)
ToolBarSeparator()
ToolbarProgressBar(#BAR, 0, 0, 20, 20, 0, 100, #PB_ProgressBar_Vertical)
ToolbarProgressBar(#BAR2, 5, 0, 40, 20, 0, 100)
ToolBarSeparator()
ToolbarHyperlink(#PB_Any, 0, 0, 150, 14, "http://www.purebasic.com", $0000FF, #PB_HyperLink_Underline)
AddGadgetItem(#COMBO, -1, "A")
AddGadgetItem(#COMBO, -1, "B")
SetToolBarButtonState(#TOOLBAR, 10, 1)
SetGadgetState(#CHECK, 1)
SetGadgetState(#BAR, 20)
SetGadgetState(#BAR2, 60)
ToolBarToolTip(#TOOLBAR, 10, "New document")
GadgetToolTip(#BAR, "veritcal progressbar")
SetGadgetColor(#TEXT, #PB_Gadget_BackColor, RGB(255, 0, 0))
SetGadgetColor(#TEXT, #PB_Gadget_FrontColor, RGB(255, 255, 255))
;}
;{ ----- CREATE TOOLBAR BOTTOM (inside ContainerGadget)
CreateImage(0, 32, 16)
StartDrawing(ImageOutput(0))
Box(0, 0, 32, 16, RGB(10, 152, 100))
Box(8, 4, 16, 8, RGB(255, 0, 0))
StopDrawing()
CreatePopupMenu(100)
MenuItem(10, "MenuID 10")
MenuItem(20, "MenuID 20")
CompilerIf #PB_Compiler_Version<430
CreateGadgetList(WindowID(#WIN))
CompilerElse
UseGadgetList(WindowID(#WIN))
CompilerEndIf
ContainerGadget(#CONTAINER_BOTTOM, 0, ToolBarHeight(#TOOLBAR), WindowWidth(#WIN), 32, #PB_Container_Double)
CreateToolBarPlus(#TOOLBAR_BOTTOM, GadgetID(#CONTAINER_BOTTOM))
ToolBarSeparator()
ToolbarIPAddress(#IPADRESS, 0, 0, 120, 20)
ToolbarDate(#PB_Any, 5, 0, 100, 20)
ToolBarSeparator()
ToolbarSpin(#SPIN, 0, 0, 40, 20, 0, 100, #PB_Spin_ReadOnly)
ToolbarTrackBar(#PB_Any, 5, 0, 60, 20, 0, 10, #PB_TrackBar_Ticks)
ToolBarSeparator()
ToolbarScrollbar(#PB_Any, 0, 0, 64, 20, 0, 100, 10)
ToolbarButtonImage(#PB_Any, 5, 0, 64, ToolbarContainerHeight(), ImageID(0))
ToolBarSeparator()
ToolBarImageButton(20, ImageID(0))
ToolBarStandardButton(15, #PB_ToolBarIcon_Find)
SetToolBarArrow()
SetToolBarMenu(100)
ToolBarStandardButton(16, #PB_ToolBarIcon_Print)
SetToolBarArrow(#True)
SetToolBarMenu(100)
ToolBarStandardButton(17, #PB_ToolBarIcon_Paste)
SetToolBarMenu(100)
ToolBarSeparator()
ToolBarStandardButton(100, #PB_ToolBarIcon_Help)
SetToolBarToggle(#True)
ToolBarStandardButton(101, #PB_ToolBarIcon_Help)
SetToolBarToggle(#True)
ToolBarStandardButton(102, #PB_ToolBarIcon_Help)
SetToolBarToggle(#True)
SetGadgetColor(#SPIN, #PB_Gadget_BackColor, RGB(255, 225, 10))
SetGadgetFont(#SPIN, LoadFont(1, "Arial", 12, #PB_Font_Bold))
SetGadgetText(#SPIN, "1")
;}
SetWindowCallback(@ToolBarPlusCallback(), #WIN)
ProcedureReturn #True
EndIf
EndProcedure
If CreateMainWindow()
Define Event, m, g, t
Repeat ;{ ----- EVENT LOOP
Event = WaitWindowEvent()
Select Event
Case #PB_Event_ActivateWindow
;----- update ipadress
SetGadgetState(#IPADRESS, MakeIPAddress(127, 0, 0, Random(255)))
Case #PB_Event_Menu
m = EventMenu()
Debug "menuID="+Str(m)
Case #PB_Event_Gadget
g = EventGadget()
t = EventType()
Debug "gadgetID=" + Str(g) + " eventType=" + Str(t) + " state=" + Str(GetGadgetState(g))
;----- update spin
SetGadgetText(#SPIN, Str(GetGadgetState(#SPIN)))
EndSelect
Until Event = #PB_Event_CloseWindow ;}
EndIf
; IDE Options = PureBasic 4.51 (Windows - x86)
; CursorPosition = 7
; Folding = g-
; EnableXP
[Dynamic-Dialogs] - create complex GUIs the easy way
[DeFlicker] - easily deflicker your resizeable Windows
[WinFX] - Window Effects (incl. 'click-through' Window)
[DeFlicker] - easily deflicker your resizeable Windows
[WinFX] - Window Effects (incl. 'click-through' Window)