Solved

Detect current form of application?

Posted on 2002-04-17
5
181 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi Spellcheck in Webbrowser 1 77
Delphi selector screen 2 97
URL for downloading Google Chrome for Win XP 2 284
how to send memory stream from ics Client To ics server ? 11 211
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

752 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