Solved

Detect current form of application?

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

770 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