I have an e-mail address field on a form whose right-click event will open
up a new Outlook message to that recipient. The automation part of it works
like a charm. However, there are times when the new Untitled message window
will flash in the taskbar and not be the foreground window and other times
when the new message will indeed get the foreground (which is the desired
result).

Using both the mail item's Display() and Activate() methods produces the
same results. Is there a way to make sure that the new message window always
hits the foreground and has focus? I'm assuming that the WinAPI has to come
into play for this..

Jon

Re: Trying to force Outlook msg window to foreground by Neil

Neil
Fri Jan 30 15:00:49 CST 2004

This might work. Try opening a new message in Outlook, then from VFP command
window..

ox = createobject("WScript.Shell")
? ox.AppActivate("Untitled - Message (Plain Text)") && must be the title of
the new message Window

Regards,
Neil

"Jon Rosenbaum" <nobody@home.com> wrote in message
news:%230U0%23505DHA.2348@TK2MSFTNGP10.phx.gbl...
> I have an e-mail address field on a form whose right-click event will open
> up a new Outlook message to that recipient. The automation part of it
works
> like a charm. However, there are times when the new Untitled message
window
> will flash in the taskbar and not be the foreground window and other times
> when the new message will indeed get the foreground (which is the desired
> result).
>
> Using both the mail item's Display() and Activate() methods produces the
> same results. Is there a way to make sure that the new message window
always
> hits the foreground and has focus? I'm assuming that the WinAPI has to
come
> into play for this..
>
> Jon
>
>



Re: Trying to force Outlook msg window to foreground by Jon

Jon
Fri Jan 30 16:12:55 CST 2004

Neil,

Thank you for the response. In the meantime, I had delved through some
WinAPI functions and examples and found what I needed. I used FindWindow to
locate the right one (obviously don't know beforehand if the title will
contain "Rich Text" or "Plain Text" or "HTML") and then BringWindowToTop /
ShowWindow to get it up there.

One interesting thing to note - FindWindow would only work if there was an
extra space padded at the end of the title.

Jon

"Neil Waterworth" <nospam-or-nwaterworth@lineone.net> wrote in message
news:uaWWkQ35DHA.504@TK2MSFTNGP11.phx.gbl...
> This might work. Try opening a new message in Outlook, then from VFP
command
> window..
>
> ox = createobject("WScript.Shell")
> ? ox.AppActivate("Untitled - Message (Plain Text)") && must be the title
of
> the new message Window
>
> Regards,
> Neil
>
> "Jon Rosenbaum" <nobody@home.com> wrote in message
> news:%230U0%23505DHA.2348@TK2MSFTNGP10.phx.gbl...
> > I have an e-mail address field on a form whose right-click event will
open
> > up a new Outlook message to that recipient. The automation part of it
> works
> > like a charm. However, there are times when the new Untitled message
> window
> > will flash in the taskbar and not be the foreground window and other
times
> > when the new message will indeed get the foreground (which is the
desired
> > result).
> >
> > Using both the mail item's Display() and Activate() methods produces the
> > same results. Is there a way to make sure that the new message window
> always
> > hits the foreground and has focus? I'm assuming that the WinAPI has to
> come
> > into play for this..
> >
> > Jon
> >
> >
>
>



Re: Trying to force Outlook msg window to foreground by Neil

Neil
Fri Jan 30 16:44:35 CST 2004

Jon,

Glad you sorted it. I'd be interested in some code samples or links for
this. If you have any, could you please post them.

Thanks,
Neil

"Jon Rosenbaum" <nobody@home.com> wrote in message
news:%23Nae4435DHA.696@tk2msftngp13.phx.gbl...
> Neil,
>
> Thank you for the response. In the meantime, I had delved through some
> WinAPI functions and examples and found what I needed. I used FindWindow
to
> locate the right one (obviously don't know beforehand if the title will
> contain "Rich Text" or "Plain Text" or "HTML") and then BringWindowToTop /
> ShowWindow to get it up there.
>
> One interesting thing to note - FindWindow would only work if there was an
> extra space padded at the end of the title.
>
> Jon
>
> "Neil Waterworth" <nospam-or-nwaterworth@lineone.net> wrote in message
> news:uaWWkQ35DHA.504@TK2MSFTNGP11.phx.gbl...
> > This might work. Try opening a new message in Outlook, then from VFP
> command
> > window..
> >
> > ox = createobject("WScript.Shell")
> > ? ox.AppActivate("Untitled - Message (Plain Text)") && must be the title
> of
> > the new message Window
> >
> > Regards,
> > Neil
> >
> > "Jon Rosenbaum" <nobody@home.com> wrote in message
> > news:%230U0%23505DHA.2348@TK2MSFTNGP10.phx.gbl...
> > > I have an e-mail address field on a form whose right-click event will
> open
> > > up a new Outlook message to that recipient. The automation part of it
> > works
> > > like a charm. However, there are times when the new Untitled message
> > window
> > > will flash in the taskbar and not be the foreground window and other
> times
> > > when the new message will indeed get the foreground (which is the
> desired
> > > result).
> > >
> > > Using both the mail item's Display() and Activate() methods produces
the
> > > same results. Is there a way to make sure that the new message window
> > always
> > > hits the foreground and has focus? I'm assuming that the WinAPI has to
> > come
> > > into play for this..
> > >
> > > Jon
> > >
> > >
> >
> >
>
>



Re: Trying to force Outlook msg window to foreground by Jon

Jon
Mon Feb 02 08:51:05 CST 2004

Neil,

Here's the link I used to base my code on:
http://www.tek-tips.com/gfaqs.cfm/pid/184/fid/4262

Along with the source code sample, there is a good explanation as to the
foreground behavior.

I basically stripped out all of the thread and process related code since I
wasn't interested in making my own application be the foreground window. I
just needed to find the Outlook message window, bring it to the top, and
show it.

Hope that helps.

Jon

"Neil Waterworth" <nospam-or-nwaterworth@lineone.net> wrote in message
news:ezETjK45DHA.1852@TK2MSFTNGP10.phx.gbl...
> Jon,
>
> Glad you sorted it. I'd be interested in some code samples or links for
> this. If you have any, could you please post them.
>
> Thanks,
> Neil
>
> "Jon Rosenbaum" <nobody@home.com> wrote in message
> news:%23Nae4435DHA.696@tk2msftngp13.phx.gbl...
> > Neil,
> >
> > Thank you for the response. In the meantime, I had delved through some
> > WinAPI functions and examples and found what I needed. I used FindWindow
> to
> > locate the right one (obviously don't know beforehand if the title will
> > contain "Rich Text" or "Plain Text" or "HTML") and then BringWindowToTop
/
> > ShowWindow to get it up there.
> >
> > One interesting thing to note - FindWindow would only work if there was
an
> > extra space padded at the end of the title.
> >
> > Jon
> >
> > "Neil Waterworth" <nospam-or-nwaterworth@lineone.net> wrote in message
> > news:uaWWkQ35DHA.504@TK2MSFTNGP11.phx.gbl...
> > > This might work. Try opening a new message in Outlook, then from VFP
> > command
> > > window..
> > >
> > > ox = createobject("WScript.Shell")
> > > ? ox.AppActivate("Untitled - Message (Plain Text)") && must be the
title
> > of
> > > the new message Window
> > >
> > > Regards,
> > > Neil
> > >
> > > "Jon Rosenbaum" <nobody@home.com> wrote in message
> > > news:%230U0%23505DHA.2348@TK2MSFTNGP10.phx.gbl...
> > > > I have an e-mail address field on a form whose right-click event
will
> > open
> > > > up a new Outlook message to that recipient. The automation part of
it
> > > works
> > > > like a charm. However, there are times when the new Untitled message
> > > window
> > > > will flash in the taskbar and not be the foreground window and other
> > times
> > > > when the new message will indeed get the foreground (which is the
> > desired
> > > > result).
> > > >
> > > > Using both the mail item's Display() and Activate() methods produces
> the
> > > > same results. Is there a way to make sure that the new message
window
> > > always
> > > > hits the foreground and has focus? I'm assuming that the WinAPI has
to
> > > come
> > > > into play for this..
> > > >
> > > > Jon
> > > >
> > > >
> > >
> > >
> >
> >
>
>