MenuHeight(), StatusBarHeight(), ToolBarHeight() returns 0?

Just starting out? Need help? Post your questions and find answers here.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4946
Joined: Sun Apr 12, 2009 6:27 am

Re: MenuHeight(), StatusBarHeight(), ToolBarHeight() returns

Post by RASHAD »

OK ,be happy

Code: Select all

 ;ToolBar Height
  SendMessage_(ToolBarID(0), #TB_GETRECT, 0,r.RECT)
  tbHeight = r\bottom-r\top

Code: Select all

 ;StatusBar Height
 SendMessage_(StatusBarID(0), #SB_GETRECT, 0,r.RECT)
 sbHeight = r\bottom-r\top
Egypt my love
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: MenuHeight(), StatusBarHeight(), ToolBarHeight() returns

Post by Dude »

RASHAD wrote:OK ,be happy
But I'm not, because the results don't match. :(

Code: Select all

; Run this on 5.51

hWnd=OpenWindow(0,200,200,400,195,"test",#PB_Window_SystemMenu)

CreateToolBar(0,hWnd)
CreateStatusBar(0,hWnd)

Debug MenuHeight() ; 20
Debug GetSystemMetrics_(#SM_CYMENU) ; 20
Debug ""

Debug ToolBarHeight(0) ; 28
SendMessage_(ToolBarID(0),#TB_GETRECT,0,r.RECT)
Debug r\bottom-r\top ; 0
Debug ""

Debug StatusBarHeight(0) ; 23
SendMessage_(StatusBarID(0),#SB_GETRECT,0,r.RECT)
Debug r\bottom-r\top ; 21
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4946
Joined: Sun Apr 12, 2009 6:27 am

Re: MenuHeight(), StatusBarHeight(), ToolBarHeight() returns

Post by RASHAD »

You must populate the ToolBar
- Add vertical padding for ToolBar as 6 or exact as per the next code
- Add vertical padding for StatusBar as 2 or exact as per the next code
That is if you changed padding by yourself :)

Code: Select all

hWnd=OpenWindow(0,200,200,400,195,"test",#PB_Window_SystemMenu)

TB = CreateToolBar(0,hWnd)
ToolBarStandardButton(0, #PB_ToolBarIcon_New)

SB = CreateStatusBar(0,hWnd)

Debug MenuHeight() ; 20
Debug GetSystemMetrics_(#SM_CYMENU) ; 20
Debug ""

Debug ToolBarHeight(0) ; 28
SendMessage_(TB,#TB_GETRECT,0,r.RECT)
pad = SendMessage_(TB,#TB_GETPADDING,0,0)
Debug r\bottom-r\top + pad >> 16
Debug ""

Debug StatusBarHeight(0) ; 23
SendMessage_(SB,#SB_GETRECT,0,r.RECT)
Dim pad(2)
SendMessage_(SB,#SB_GETBORDERS,0,@pad())
Debug r\bottom-r\top + pad(1)
Egypt my love
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: MenuHeight(), StatusBarHeight(), ToolBarHeight() returns

Post by Dude »

Thank you, RASHAD! :D
Post Reply