troubleshooting Question

[Challenge] The annoying Application Window...

Avatar of Wim ten Brink
Wim ten BrinkFlag for Netherlands asked on
17 Comments1 Solution353 ViewsLast Modified:
Okay, I finally got too annoyed by the following problem. Please follow my instructions and then help me solve this... :-)

1) Start your Delphi version. (Doesn't matter which one.)
2) Create a new application.
3) Save the new application. (Make whatever modifications that you like.)
4) Compile the new application.
5) Close Delphi.
6) Close all other applications you're running.
7) Start the application you just created. (Start/Run...)
8) Right-click on the taskbar.
9) From the popup menu, click on 'Tile Windows Vertically" or the other tile option.

After these 9 steps, your newly created application will occupy half the screen...

10) Close your application.
11) Start Notepad (Start/Run...)
12) Right-click on the taskbar.
13) From the popup menu, click on 'Tile Windows Vertically" or the other tile option.

After these additional 4 steps, you'll see Notepad filling your whole screen, just as all Windows applications are supposed to behave...

Now, about the why... This happens because every Delphi application which uses the VCL will actually create two forms. One is your mainform and this one should be visible of course. The other is a form of class TApplication. Yeah, that's right! TApplication is also a very special kind of form. It has a width and height of 0 but it is still visible. (But smaller than a pixel so you won't see it. Delphi needs this window to be visible so it can handle all kinds of Windows messages. In other programming languages, such behaviour would be linked to the mainform instead but not with Delphi. So when the Delphi application gets ordered to tile it's windows, it knows it has two windows which both need to fill the screen. So each window will occupy half the screen. Since TApplication maintains it's size of 0x0, it's still not visible yet you will see the mainform on half your screen.

This annoys me and today it just bugged me too much. So here's the challenge...

Write a simple application using the VCL which will work just like all other Windows applications. Thus, when tiling it fills the whole screen instead of half the screen but also, TApplication must still be able to process all messages. (Which means you can't make TApplication invisible, except for a very, very short time!!!)

400 points plus A-grade for the best solution! And 100 points for the second-best...
(The best solution would be implemented as a component that you can drop on your form...)
Russell Libby
Software Engineer, Advisory
Join our community to see this answer!
Unlock 1 Answer and 17 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 17 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros