Solved

Set Focus

Posted on 2000-03-24
3
254 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
[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
3 Comments
 
LVL 6

Accepted Solution

by:
Jaymol earned 50 total points
ID: 2652500
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
ID: 2652643
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
ID: 2652691
Go to my web site and download it from there.

  www.geocities.com/jaymol

Thanks,

John.
0

Featured Post

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Intraweb download file link ? 1 184
how to update exe applicatio from internet ? 6 108
Delphi...Split view - idea? 1 146
Firemonkey Tcameracomponent resultion 1 48
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

738 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