Interesting Fact about Screen()

| | Comments (1)

So while working on RB 6 today, I noticed a slightly odd behavior with the Screen function. I was working on my Windows box (running Windows XP), which has a screen resolution of 1024x768, and I was noticing that the initial size and position of the main IDE window was too large. What's odd is that I was using the Screen.AvailableHeight property, and that should mean that my window wasn't going to be going under the taskbar (which is placed at the bottom of my screen). And yet the running application would make the window too tall.

So I started stepping thru the code in the debugger, and what I found was that Screen.AvailableHeight was returning 768 -- which would make sense aside from the fact that we claim it's the screen height less the taskbar height. You'd think this was a bug -- right?

Well, it was and it wasn't. I had my taskbar set to auto-hide, which means that I really do have the entire screen as available height. So the RB function to get the available screen height had no bug in it. The bug is the fact that Windows is refusing to hide my taskbar, even though it's set to auto-hide!

Consquently, the Mac always takes the dock into account, regardless of whether it's set to auto-hide or not. But it was good to know that the bug I was seeing was a Microsoft problem. Sadly, it took me almost an entire hour to figure it out, including all the time I spent with Joe tracking down his code and discussing things with him. Looks like today is shaping up to be rather unproductive.

Here's the interesting thing to know about Screen -- on Windows, it takes the taskbar into account. It also takes the hidden state into account. However, on the Mac, it always takes the dock into account, regardless of whether it's hidden or not.

1 Comments

Actually, the Mac changes between 4 pixels for the dock (which is when it's on auto-hide) and the dock height when it's set to be visible. You're most likely just noticing the MenuBar being taken into account.

Leave a comment

Disclaimer

I'm currently an employee of REAL Software. My blog is mine. The opinions represented in this blog are mine as well and may not represent my employer's opinions. All original material is copyrighted and property of the author.

REALbasic® is a registered trademark of REAL Software, Inc. REAL SQL Server™ and Lingua™ are pending trademarks of REAL Software, Inc. All rights reserved.