Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 189
  • Last Modified:

Detect current form of application?

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
robnorthcott
Asked:
robnorthcott
  • 2
  • 2
1 Solution
 
kretzschmarCommented:
?screen.activeform

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

meikl ;-)
0
 
geobulCommented:
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
 
kretzschmarCommented:
thanks geo, for validation,
was'nt sure, because just from head
0
 
robnorthcottAuthor Commented:
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
 
geobulCommented:
Hi meikl, my pleasure.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now