ToolBar height ?

Windows specific forum
User avatar
Flype
Addict
Addict
Posts: 1542
Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy

ToolBar height ?

Post by Flype »

hello, how can i get the height of the toolbar in my window ?
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
Denis
Enthusiast
Enthusiast
Posts: 779
Joined: Fri Apr 25, 2003 5:10 pm
Location: Doubs - France

Post by Denis »

Salut Flype,

send a message with TB_GETMETRICS value.

It retrives all Toolbar parameters.


A+

Denis
A+
Denis
User avatar
Flype
Addict
Addict
Posts: 1542
Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy

Post by Flype »

thanks denis, but that's not all folk !

Structure TBMETRICS not in purebasic includes, so here is :

Code: Select all

Structure TBMETRICS
  cbSize.l
  dwMask.l
  cxPad.l
  cyPad.l
  cxBarPad.l
  cyBarPad.l
  cxButtonSpacing.l
  cyButtonSpacing.l
EndStructure
And the constante #TB_GETMETRICS isn't defined so what's its value ?

Code: Select all

ptbMetrics.TBMETRICS
ptbMetrics\cbSize = Sizeof( TBMETRICS )
SendMessage_( toolbar, #TB_GETMETRICS, 0, @ptbMetrics )
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
ebs
Enthusiast
Enthusiast
Posts: 564
Joined: Fri Apr 25, 2003 11:08 pm

Post by ebs »

Flype,

#TB_GETMETRICS = #WM_USER + 101

Eric
User avatar
Flype
Addict
Addict
Posts: 1542
Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy

Post by Flype »

very thank you ebs :wink:
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
User avatar
Flype
Addict
Addict
Posts: 1542
Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy

Post by Flype »

arrrg, in order to make it working i need those 3 API constantes :

#TBMF_PAD
#TBMF_BARPAD
#TBMF_BUTTONSPACING

as specified in MSDN documentation http://msdn.microsoft.com/library/defau ... etrics.asp
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
User avatar
Flype
Addict
Addict
Posts: 1542
Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy

Post by Flype »

this is how i coded it :
but it doesn't work (perhaps it works only with winXP )

Code: Select all

Structure TBMETRICS
  cbSize.l
  dwMask.l
  cxPad.l
  cyPad.l
  cxBarPad.l
  cyBarPad.l
  cxButtonSpacing.l
  cyButtonSpacing.l
EndStructure

#TBMF_PAD = 1
#TBMF_BARPAD = 2
#TBMF_BUTTONSPACING = 4
#TB_GETMETRICS = #WM_USER + 101

;=================================

If OpenWindow(0,0,0,400,300,#PB_Window_ScreenCentered|#PB_Window_SystemMenu,"Toolbar")
  
  toolbar = CreateToolBar( 0, WindowID() )
  ToolBarStandardButton( 0, #PB_ToolBarIcon_Save )
  ToolBarStandardButton( 1, #PB_ToolBarIcon_Delete )
  
  CreateGadgetList( WindowID() )
    
  ptbMetrics.TBMETRICS 
  ptbMetrics\cbSize = SizeOf( TBMETRICS )
  ptbMetrics\dwMask = #TBMF_PAD
  SendMessage_( toolbar, #TB_GETMETRICS, 0, @ptbMetrics )
  Debug ptbMetrics\cxPad
  Debug ptbMetrics\cyPad
  
  ComboBoxGadget( 3, 5, ptbMetrics\cyPad+10, 200, 120 )
  
  Repeat : Until WaitWindowEvent() = #WM_CLOSE

EndIf
Last edited by Flype on Sat Jul 26, 2003 5:56 pm, edited 1 time in total.
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
DominiqueB
Enthusiast
Enthusiast
Posts: 103
Joined: Fri Apr 25, 2003 4:00 pm
Location: France

Hello

Post by DominiqueB »

Just try:

#TBMF_BARPAD = 2
#TBMF_BUTTONSPACING = 4
#TBMF_PAD = 1

Dominique
Dominique

Windows 10 64bits. Pure basic 32bits
User avatar
Flype
Addict
Addict
Posts: 1542
Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy

Post by Flype »

i tried and it doesn't work on my win2000 :cry:
If someone can try it under winXP
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
DominiqueB
Enthusiast
Enthusiast
Posts: 103
Joined: Fri Apr 25, 2003 4:00 pm
Location: France

It works .

Post by DominiqueB »

In fact it can't works for you under w2000 !
Minimum is xp for the structure TBMETRICS.

Said into wsdk.

I've XP pro and your sample code works well for me.

So sad .

Dominique.
Dominique

Windows 10 64bits. Pure basic 32bits
Pupil
Enthusiast
Enthusiast
Posts: 715
Joined: Fri Apr 25, 2003 3:56 pm

Post by Pupil »

Maybe you can use API GetClientRect_() instead to get the height of the toolbar.
Edwin Knoppert
Addict
Addict
Posts: 1073
Joined: Fri Apr 25, 2003 11:13 pm
Location: Netherlands
Contact:

Post by Edwin Knoppert »

On each size of the window it usually updates it's size by passing WM_SIZE to the tb.

After this is done, you can obtain height by using GetWindowRect_()
Subtract top from bottom = height
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Post by GPI »

Little snap out of jaPBe:

Code: Select all

ToolBarId=CreateToolBar(#tool_MainWindow,MainWin)
GetClientRect_(ToolBarId,rect.RECT)
ToolBarHeight=rect\bottom

Should work on all system.

Edit: on GetClientRect_() is rect\left rect\top always 0!

GPI
Last edited by GPI on Sat Jul 26, 2003 8:20 pm, edited 1 time in total.
User avatar
Flype
Addict
Addict
Posts: 1542
Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy

Post by Flype »

yes, that's exactely what i want :D
and now it's so simple :oops: :

Code: Select all

If OpenWindow(0,0,0,300,100,#PB_Window_ScreenCentered|#PB_Window_SystemMenu,"Toolbar") 
  
  toolbar = CreateToolBar( 0, WindowID() ) 
  ToolBarStandardButton( 0, #PB_ToolBarIcon_Save ) 
  ToolBarStandardButton( 1, #PB_ToolBarIcon_Delete ) 
  
  CreateGadgetList( WindowID() ) 
  GetClientRect_( toolbar,rect.RECT) 
  ComboBoxGadget( 3, 5, rect\bottom, 200, 120 ) 
  
  Repeat : Until WaitWindowEvent() = #WM_CLOSE 

EndIf
and, so, the previous example works only on XP :? I should forget it ...
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
Edwin Knoppert
Addict
Addict
Posts: 1073
Joined: Fri Apr 25, 2003 11:13 pm
Location: Netherlands
Contact:

Post by Edwin Knoppert »

GetClientRect is not the way to do it..
Unless you want the client area's height.

You where asking the toolbar's height.
This might result in the similar value for now but what if billy changes windows again?
Post Reply