Solved

Set Focus

Posted on 2000-03-24
3
249 Views
Last Modified: 2010-04-04
How can i give focus to other application ?
ex:
Running Application :
1. IE
2. Windows Explorer
3. My Application

Now Focus in My Application, How can i set the focus to IE or Windows Explorer from my application ?
0
Comment
Question by:crazydragonx
  • 2
3 Comments
 
LVL 6

Accepted Solution

by:
Jaymol earned 50 total points
Comment Utility
If you know the window title (caption bar text) you can use the following

Function SetWindowFocused(wTitle: String): Boolean;
var
  Hndl : Boolean;
begin
  Result:=False;
  Hndl:=FindWindow(nil, PChar(wTitle));
  If Hndl>0 then begin
    SetForegroundWindow(Hndl);
    Result:=True;
  end;
end;

....
....
....
  if not SetWindowFocused('Microsoft Internet Explorer') then
    ShowMessage('Couldn't find window.');

or, if you don't know the Window Title, you'll have to enumerate the open windows to find the closest.  (This can be done using a unit I wrote - GetApps.  If you need it, let me know your email and I'll send it.)  It's a bit easier to get the titles and find one with your selected text within one of them.  (Internet explorer always says something like "web site you're on - microsoft internet explorer".  FindWindow will not find that if you ask it to find "Internet Explorer".  See what I mean?)

Hope this helps,

John.
0
 

Author Comment

by:crazydragonx
Comment Utility
Thank You, I got the point now...

May you send me the getapps code, so i can compare it with my app. Thx before
0
 
LVL 6

Expert Comment

by:Jaymol
Comment Utility
Go to my web site and download it from there.

  www.geocities.com/jaymol

Thanks,

John.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
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: …

772 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

16 Experts available now in Live!

Get 1:1 Help Now