Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Making external program stay on top? 1

Status
Not open for further replies.

Ante0

Programmer
Apr 19, 2007
98
SE
Is it possible to send stayontop to another program using FindWindow and that?
It's a game, and I play it in windowed mode and I dont like when it gets minimized when clicking outside of the window.
It has no -stayontop parameter or anything like that.
 
Hi Ante0,

I don't think that you can set another application to permanently stay on top (someone correct me if I am wrong).

You can set a window to be the top most window by using SetForegroundWindow. What you need to do is find the Handle of the Window then use SetForegroundWindow to make this window on top again.

Code:
procedure FocusWindow(WindowName : String)
var
  hWnd: DWORD;
begin
  hWnd := FindWindow(nil, PChar(WindowName));
  if hWnd <> 0 then
  begin
    ShowWindow(hwnd, 1);
    SetForegroundWindow(hWnd);
    SetFocus(hWnd);
  end;
end;
 
Oh nice!
This will work great.
Just hoping a 1ms timer wont overload my system. Hehe
Oh, and SetFocus(hWnd); must be changed to just SetFocus;
or else it complains about too many actual parameters :)
 
must be changed to just SetFocus;
That's not really what you want it to do. Doing that changes it to Forms.SetFocus;

You want Windows.SetFocus();

Roo
Delphi Rules!
 
Yeah, my bad...

Change it to

Code:
    windows.ShowWindow(hwnd, 1);
    windows.SetForegroundWindow(hWnd);
    windows.SetFocus(hWnd);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top