Sunday, June 20, 2010

Is Application Object a window in Delphi?

Often sometimes while working in Delphi I wondered whether the Application object itself is a window or not.. and if so then where exactly is this window and why is it not visible? Going through Marco Cantu's Mastering Delphi book I found that yes infact Application object in delphi is infact a window but than this fact drove me into curiosity to just see this window visibly and hence I thought of programming a bit on this fact. Though Marco suggested that the best way to see that "Application object is infact a window" is to run Delphi, select "New Application" which creates a new windows application and gives Form1 as a default form and then simply press the Run button. Now on looking into the task bar we are see that the title for our new application is getting displayed as Project1 and not Form1 which clearly suggests that there is infact a hidden window in our newly created windows application. This hidden window is none other than very own Application window but still if we could see the window well stretched on our desktop then it would be a better confirmation to this fact after all to see it clearly is better than mearly realising a fact... Am I Correct? So here we go..

Now to start with - first here is a bit of delphi lecture - If we will look at how TApplication has been defined in Delphi then we find that the class has been inherited from TComponent class but than on going through the class definition we find that Application object infact allows programmer to have access to its handle value.. Handle in itself is a unique 32bit (for 32 bit systems) number that windows OS assigns to each window that will be handling any sort of windows messaging.
Once while I was going through some VC++ lessons and VB programming I once read that if we have access to the handle value fo a window we can manipulate that window to the maximum extent via the windows API's and hence I plan here to do the same to make the "Application Object" show its coordinates and make itself visible...