Solved

Detect current form of application?

Posted on 2002-04-17
5
180 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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Delphi TcxGrid group footer summary 3 320
Path  to current project in Delphi. 2 94
How to debug For loops? 3 57
Firemonkey webbrowser scrollbars ? 1 50
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

828 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