Page 1 of 1

How to: Get the current Windows taskbar height

Posted: Sun Jan 03, 2010 1:03 am
by charvista
Every Windows system has a taskbar. The taskbar height can differ on each computer, even set to auto-hide...
I would like to use OpenWindow() with the height of the screen less the height of the taskbar, so that it is always visible and can be reached.
How can I get the current height setting?
Thanks.

Re: How to: Get the current Windows taskbar height

Posted: Sun Jan 03, 2010 1:16 am
by netmaestro
The taskbar can also be in different positions, not necessarily on the bottom of the screen. The way to accomplish your goal is to use SystemParametersInfo_() with #SPI_GETWORKAREA. This will give you the position and size of the desktop excluding the taskbar and you can create your window according to the returned rectangle.

Re: How to: Get the current Windows taskbar height

Posted: Sun Jan 03, 2010 1:29 am
by charvista
Many thanks Netmaestro. I could find it further on the forum by searching for SystemParametersInfo_.
The solution:

Code: Select all

         SystemParametersInfo_(#SPI_GETWORKAREA, 0, @DesktopRect.RECT, 0)
         DesktopX = DesktopRect\left
         DesktopY = DesktopRect\top
         DesktopWidth = DesktopRect\right - DesktopRect\left
         DesktopHeight = DesktopRect\bottom - DesktopRect\top
         Debug "OpenWindow("+Str(DesktopX)+", "+Str(DesktopY)+", "+Str(DesktopWidth)+", "+Str(DesktopHeight)+")"
Have a good day.

Re: How to: Get the current Windows taskbar height

Posted: Sun Jan 03, 2010 2:27 am
by netmaestro
Almost. You have to take into account that a PB window opened to supplied width and height will have a client area with those dimensions. You'll have to subtract the caption and borders to get what you're looking for:

Code: Select all

SystemParametersInfo_(#SPI_GETWORKAREA, 0, @DesktopRect.RECT, 0)
DesktopX = DesktopRect\left
DesktopY = DesktopRect\top
DesktopWidth = DesktopRect\right - DesktopRect\left
DesktopHeight = DesktopRect\bottom - DesktopRect\top
DesktopWidth-GetSystemMetrics_(#SM_CXFIXEDFRAME)*2
DesktopHeight-(GetSystemMetrics_(#SM_CYCAPTION)+GetSystemMetrics_(#SM_CYFIXEDFRAME)*2)

OpenWindow(0,DesktopX,DesktopY,DesktopWidth,DesktopHeight,"",#PB_Window_SystemMenu)

Repeat:Until WaitWindowEvent()=#PB_Event_CloseWindow

Re: How to: Get the current Windows taskbar height

Posted: Sun Jan 03, 2010 2:59 am
by charvista
Indeed, this is more accurate.
I appreciate your help very much.
Richard

Re: How to: Get the current Windows taskbar height

Posted: Sun Jan 03, 2010 9:27 am
by Kwai chang caine
Thanks NETMAESTRO
I use your tips immediately, for my new application 8)

Re: How to: Get the current Windows taskbar height

Posted: Sun Jan 03, 2010 11:22 am
by srod
Kwaï chang caïne wrote:Thanks NETMAESTRO
I use your tips immediately, for my new application 8)
Everyone is advised to take cover, KCC is working on a new application! Lock up your dll's, hide those tips and tricks, and for God's sake don't let him near the drinks cabinet!

:twisted:

(Sorry KCC, I couldn't resist!)

Re: How to: Get the current Windows taskbar height

Posted: Sun Jan 03, 2010 12:54 pm
by charvista
Haha, there we have the good old Kwaï chang caïne :lol:
I'm glad the code will be of use in your new application ! :twisted:
Hopely you will share it with us when finished :wink:

Re: How to: Get the current Windows taskbar height

Posted: Sun Jan 03, 2010 6:29 pm
by Kwai chang caine
My MASTER wrote:Everyone is advised to take cover, KCC is working on a new application! Lock up your dll's, hide those tips and tricks, and for God's sake don't let him near the drinks cabinet!
Oooohh, my master give to me the great honor to insult me :D
It's already a pleasure to read you :P
Even when you take your legs was shot, for go far of KCC 8)
It's a too long time, that i have not "blablabla" with you :?

My dream....you and me alone in a farmhouse :roll:

Image

Me i drunk you with all my question...you like my grandma.... always answer to me, and kind with your little KCC, and in the same time, you knit socks or scarf for KCC against the hard winter :roll:

I'm sure it's also your dream...i'm sure :mrgreen:

@CHARVISTA
Yes ....it's for my tiny "FlowChart" 8)
For be sure the windows is open a maximum
Thanks for your kind message :wink: