Board index » delphi » STAT PROGRAM FROM DELPHI3 WITH WINDOW ALWAYS-ON-TOP ??

STAT PROGRAM FROM DELPHI3 WITH WINDOW ALWAYS-ON-TOP ??

Is it possible (and I think it is because it was possible in WIN3.1)
and how, using DELPHI3,  to start external program and make its window
always on top eve if it has no that feature ?

Arminio.Gr...@USA.Net                     Pozega, Croatia
http://www.geocities.com/SiliconValley/Way/9629/arminio.htm
                                  <father since 07.07.1998>

 

Re:STAT PROGRAM FROM DELPHI3 WITH WINDOW ALWAYS-ON-TOP ??


Arminio Grgic - GrGa wrote in message <367cbe83.1452...@news.tel.hr>...

Quote
>Is it possible (and I think it is because it was possible in WIN3.1)
>and how, using DELPHI3,  to start external program and make its window
>always on top eve if it has no that feature ?

Yes. Here's some code I posted a while ago in response to
a similar question:

procedure TForm1.Button1Click(Sender: TObject);
var
  wndCalc  : HWND;
  sei   : TShellExecuteInfo;
begin
  with sei do begin
    cbSize    := SizeOf(TShellExecuteInfo);
    fMask     := SEE_MASK_NOCLOSEPROCESS;
    Wnd      := Handle;
    lpVerb    := 'open';
    lpFile    := 'calc.exe';
    lpParameters := nil;
    lpDirectory  := nil;
    nShow     := SW_SHOWNORMAL;
  end;

  ShellExecuteEx(@sei);

  if sei.hInstApp > 32 then begin
    { wait for the calculator to load }
    WaitForInputIdle(sei.hProcess, INFINITE);
    { get a handle to its window }
    wndCalc := FindWindow(nil, 'Calculator');

    if wndCalc > 0 then begin
      { make the calc window topmost }
      if not SetWindowPos(wndCalc,
                          HWND_TOPMOST,
                          0,
                          0,
                          0,
                          0,
                          SWP_NOSIZE) then
        RaiseLastWin32Error;
    end
    else
      ShowMessage('Calculator not found');
  end
  else
    RaiseLastWin32Error;
end;

HTH
--
Jeremy Collins

Other Threads