Solved

Detect current form of application?

Posted on 2002-04-17
5
177 Views
Last Modified: 2010-04-04
There must be a simple solution to this...

I want to know the currently active form of my application (returned as a TForm).  The API function GetActiveWindow looks hopeful, but the HWnd it returns doesn't match any handle of forms in Delphi.  The only other way I can think of is to set a global variable in every OnActivate event of all forms.

Is there a better way?  Something like TApplication.ActiveForm would be nice!

Thanks,

Rob
0
Comment
Question by:robnorthcott
  • 2
  • 2
5 Comments
 
LVL 27

Accepted Solution

by:
kretzschmar earned 100 total points
ID: 6947214
?screen.activeform

well don't now if this exits,
but look about the screen-properties

meikl ;-)
0
 
LVL 17

Expert Comment

by:geobul
ID: 6947317
Hi,
Meikl is right. That's the easiest way I know.

procedure TForm1.Button1Click(Sender: TObject);
begin
  if Screen.ActiveForm <> nil then
    ShowMessage(Screen.ActiveForm.Name);
end;

Regards, Geo
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6947324
thanks geo, for validation,
was'nt sure, because just from head
0
 

Author Comment

by:robnorthcott
ID: 6947338
Err... thanks for that!  I noticed that myself a couple of minutes after posting the question (I knew there must be an easy way!)

Rob
0
 
LVL 17

Expert Comment

by:geobul
ID: 6947404
Hi meikl, my pleasure.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This video discusses moving either the default database or any database to a new volume.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now