Resetting the Focus

How do you set the focus to a dos program in delphi. The dos program is already running, but minimized.
Deep DiverAsked:
Who is Participating?
kangadruConnect With a Mentor Commented:
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;
  theHandle := FindWindow(nil, 'Bash');
//  setForeGroundWindow(theHandle);
  ShowWindow(theHandle, SW_SHOWNORMAL);
Deep DiverAuthor Commented:
Edited text of question
Deep DiverAuthor Commented:
Type the showWindow Command two times...Once is not anough
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.

All Courses

From novice to tech pro — start learning today.