Page 1 of 1

Give ToolBarHeight() a brother named ToolBarWidth()

Posted: Sun Jun 14, 2009 3:21 pm
by Michael Vogel
I would like to have that function :lol:

Posted: Sun Jun 14, 2009 4:19 pm
by blueznl
Euh, why? Isn't that the same as WindowWidth()?

Posted: Sun Jun 14, 2009 5:08 pm
by Fluid Byte
It is unless you change the auto sizing via API. So this request is rather pointless :D

Posted: Sun Jun 14, 2009 10:14 pm
by Michael Vogel
It would make things easier...

Code: Select all

Procedure ToolbarButtonSize(Toolbar,*S.SIZE)
	SendMessage_(ToolBarID(Toolbar),#TB_GETITEMRECT,0,@R.RECT)
	*S\cx=R\right-r\left
	*S\cy=R\bottom-r\top
EndProcedure
Procedure StopToolbarAutoAlign(Toolbar)
	T=ToolBarID(Toolbar)
	SetWindowLong_(T,#GWL_STYLE,GetWindowLong_(T,#GWL_STYLE) | #CCS_NODIVIDER)
	SetWindowLong_(T,#GWL_STYLE,GetWindowLong_(T,#GWL_STYLE) | #CCS_NOPARENTALIGN)
	SetWindowLong_(T,#GWL_STYLE,GetWindowLong_(T,#GWL_STYLE) | #CCS_NORESIZE)
EndProcedure

OpenWindow(0,0,0,512,140,"",#PB_Window_ScreenCentered | #PB_Window_SystemMenu)
ListIconGadget(17,20,20,200,200,"Just for testing",99)
DisableGadget(17,1)

CreateToolBar(0,WindowID(0))
ToolBarStandardButton(0,0,#PB_ToolBar_Toggle)
ToolBarSeparator()
ToolBarStandardButton(1,1,#PB_ToolBar_Toggle)
ToolBarStandardButton(2,2,#PB_ToolBar_Toggle)
ToolBarStandardButton(3,3,#PB_ToolBar_Toggle)

If #True
	T=ToolBarID(0)
	Global s.SIZE
	ToolbarButtonSize(0,@s)
	height=s\cy
	width=s\cx*4
Else
	height=ToolBarHeight(0)
	width=ToolBarWidth(0)
EndIf

ButtonGadget(18,26,6,width+4,height+4,"")
DisableGadget(18,1)
StopToolbarAutoAlign(0)

modus=#SW_SHOW
SetWindowPos_(ToolBarID(0),GadgetID(18),28,8,width,height,#SWP_DRAWFRAME)

Repeat
	Select WaitWindowEvent()

	Case #PB_Event_CloseWindow
		Break

	Case #WM_CHAR
		modus=#SW_SHOW-modus
		ShowWindow_(GadgetID(18),modus)
		ShowWindow_(ToolBarID(0),modus)

	Default
		Debug GetToolBarButtonState(0,1)

	EndSelect
ForEver

Posted: Mon Jun 15, 2009 12:07 pm
by Fluid Byte
You don't quite understand. You are mixing native PB commands with API. You use the API to modify the behaviour of the toolbar. By default PB toolbars always are as wide as the width of it's parent window. That is why there is no such command.

Posted: Mon Jun 15, 2009 7:05 pm
by Michael Vogel
Fluid Byte wrote:You don't quite understand. You are mixing native PB commands with API. You use the API to modify the behaviour of the toolbar. By default PB toolbars always are as wide as the width of it's parent window. That is why there is no such command.
You're right, of course... maybe I've thought to start to get just one simple command for now and then I can try to get some other functions (SetToolBarPosition() etc.) implemented to get floating toolbars also :lol: