Solved

Resetting the Focus

Posted on 1997-05-19
3
249 Views
Last Modified: 2010-04-04
How do you set the focus to a dos program in delphi. The dos program is already running, but minimized.
0
Comment
Question by:Deep Diver
  • 2
3 Comments
 

Author Comment

by:Deep Diver
ID: 1336455
Edited text of question
0
 

Accepted Solution

by:
kangadru earned 20 total points
ID: 1336456
You have to use 2 API calls.  Depending on if you want to deal with Minimized or not, I prefer not to maximize minimized windows as a rule, but there are exceptions.In the Following Ex. The FindWindow Call uses the Title Bar name of the Window to find a Window HAndle and the Show Window to restore it  and give it the focus.  Commented out you'll see SetForeGround Window, that's my preferance as it does not restore the window and does not preempt the keyboard input. it only sets that window active.A third method would be to use SetWindowPos() and you can make it TopMost with out bringin it forward to the top of the ZOrder.var
  theHAndle : HWND;
begin
  theHandle := FindWindow(nil, 'Bash');
//  setForeGroundWindow(theHandle);
  ShowWindow(theHandle, SW_SHOWNORMAL);
end;
Andy
0
 

Author Comment

by:Deep Diver
ID: 1336457
Type the showWindow Command two times...Once is not anough
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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…
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…

756 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