try
WordApp.Activate
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
> Behalf Of Jason Coley
> Sent: Thursday, 2 November 2000 23:11
> To: Multiple recipients of list delphi
> Subject: RE: Re: [DUG]: Bring an App to the front
>
>
> Thanks for that code, but how do I get the HWND, when I create
> the Word App
> by
>
> WordApp := CreateOLEObject('Word.Application');
>
> Regards
> Jason Coley
> Manawatu Software Solutions
> http://www.software-solutions.co.nz/
>
>
> -----Original Message-----
> From: Corey Murtagh [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, 1 November 2000 8:36 p.m.
> To: Multiple recipients of list delphi
> Subject: Re: [DUG]: Bring an App to the front
>
> > Jason Coley wrote:
> >
> > Is there a way to bring an Apps window to the front, I have an
> OLE handle
> > to a window (Word) and I want to bring that window to the front, what's
> > the best way to do this?
>
> As Patrick mentioned, BringWindowToFront is the official method, but it
> won't work as expected on Win98/2K/ME. On those platforms when a process
> which is not the current owner of the forground window calls
> BringWindowToFront it just flashes the icon on the task bar. To
> get around
> that you have to run the code in the context of the current foreground
> process. Here's some C++ code that I've been using which does it:
>
> bool ForceWindowToFront(HWND hWnd)
> {
> bool Result;
> DWORD ForegroundWindowThreadID;
> DWORD WindowThreadID;
> if (hWnd == GetForegroundWindow())
> Result = true;
> else
> {
> ForegroundWindowThreadID =
> GetWindowThreadProcessId(GetForegroundWindow(), NULL);
> WindowThreadID = GetWindowThreadProcessId(hWnd, NULL);
> if (ForegroundWindowThreadID != WindowThreadID)
> {
> AttachThreadInput(ForegroundWindowThreadID, WindowThreadID, true);
> Result = SetForegroundWindow(hWnd);
> AttachThreadInput(ForegroundWindowThreadID, WindowThreadID, false);
> }
> else
> Result = SetForegroundWindow(hWnd);
> ShowWindow(hWnd, SW_RESTORE);
> }
> return Result;
> }
>
> --
> Corey Murtagh
> The Electric Monk
> "Quidquid latine dictum sit, altum viditur!"
> ------------------------------------------------------------------
> ---------
> New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
> Website: http://www.delphi.org.nz
> To UnSub, send email to: [EMAIL PROTECTED]
> with body of "unsubscribe delphi"
>
> ------------------------------------------------------------------
> ---------
> New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
> Website: http://www.delphi.org.nz
> To UnSub, send email to: [EMAIL PROTECTED]
> with body of "unsubscribe delphi"
>
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED]
with body of "unsubscribe delphi"