detecting the taskbar

BlitzPlus Forums/BlitzPlus Programming/detecting the taskbar

Mr Brine(Posted 2004) [#1]
Is is possible to detect the taskbars position and dimensions (in pixels) on the desktop?

Thanx

Mr Brine


soja(Posted 2004) [#2]
Something like this should do it:
;.lib "user32.dll"
; SystemParametersInfo%(uiAction%, uiParam%, pvParam*, fWinIni%):"SystemParametersInfoA"

Const SPI_GETWORKAREA = $30

Type Rectangle
	Field l, t, r, b ; Left, top, right, bottom
End Type
r.rectangle = New rectangle

SystemParametersInfo(SPI_GETWORKAREA, 0, r, 0)
Select True
	Case r\l <> 0
		size% = GadgetWidth(Desktop()) - r\l
		s$="left"
	Case r\t <> 0
		size% = GadgetHeight(Desktop()) - r\t
		s$="top"
	Case r\r - GadgetWidth(Desktop()) <> 0
		size% = GadgetWidth(Desktop()) - r\r
		s$="right"
	Case r\b - GadgetHeight(Desktop()) <> 0
		size% = GadgetHeight(Desktop()) - r\b
		s$="bottom"
End Select

Notify "The taskbar is on the "+s$+" and is "+size+" pixels high/wide"



Mr Brine(Posted 2004) [#3]
Thanks Soja, That works a treat!

Mr Brine


Mr Brine(Posted 2004) [#4]
Hey Soja,

I dont suppose you know if its possible to hide and show the taskbar?

Mr Brine


soja(Posted 2004) [#5]
Well do you want to make sure your window covers the taskbar or do you want to explicitly hide it?


Mr Brine(Posted 2004) [#6]
well either would do the job, having the window displayed over the taskbar would probably be the better solution. So long as its reverseable!

Mr Brine


soja(Posted 2004) [#7]
See MSDN on "The Taskbar"
(User Interface->Windows Shell->Shell Programmer's Guide->Intermediate Shell Techniques->Programming->The Taskbar

...especially:
It is possible to cover the taskbar by explicitly setting the size of the window rectangle equal to the size of the screen with SetWindowPos. For Windows 2000 systems or later, the window must lack either WS_CAPTION or WS_THICKFRAME, or else the window must be sized so that the client area covers the entire screen. Also particular to those systems, if the taskbar is set to Always On Top, it will remain hidden only while the application is the foreground application.

...which gives some clues. I've never done it but I might be able to give you a hand if you run into something.


Eikon(Posted 2004) [#8]
Heres what I use to get a "full screen" window:

Hit space and it will go full and above the taskbar.


Mr Brine(Posted 2004) [#9]
Thanks guys! Your help is well appricaited!

Mr Brine


Mr Brine(Posted 2004) [#10]
Ok, Ive been playing around with Eikons code, and it aint suitable for the task in mind, the reasons being: it forces the window to full screen and it changes the windows style to a tool window.

Anyhow I went on MSDN followed up Sojas link above and found out some potential useful information, unfortunatly i'm 100% uneducated in the ways of windows dll's and the like so puting this information into practice is turning into somat of a nightmare!! Here is what Ive found out:

Relating to the code Soja posted I found another contant called 'SPI_SETWORKAREA' the description for it reads like it allows you to resize the desktop work area. I added the following lines of code to sojas example

<code>

r\l = 0
r\t = 0
r\r = 1024
r\b = 768
SystemParametersInfo(SPI_SETWORKAREA, 0, r, 0)
r\l = 0
r\t = 0
r\r = 0
r\b = 0
SystemParametersInfo(SPI_GETWORKAREA, 0, r, 0)

</code>

the SystemParametersInfo(SPI_GETWORKAREA, 0, r, 0) returns the expected values, but the taskbar is still in front of any windows I create before or after. when I maximize the window, its maximized to the full size of the screen not taking into account the taskbar.

What I want to achieve is to be able to copy a window to canvas, the problem is when the window overlaps the taskbar the image copied to the canvas is not correct.