Re: Input box pops behind email window



This is all well and good but the important thing is it works with a couple
of caveats.

First, you have to unload the modal form when you are done with it, just
doing a me.hide isn't good enough. (I do a me.hide when I exit the form,
then, after I have the info I wanted from the form I unload it.)

Second, you have to do a DoEvents after you unload the form.

If you don't do these two things you get very strange results, like Outlook
comes to the forground then goes back after you close the form or if you
click the button the second time the form does not appear until you move off
the wordmail window then back (window goes thru ActivateWindow code again?).

So, thanks for pointing me in the right direction, even if it theoretically
doesn't work.

--
John Svercek


"Dmitry Streblechenko" wrote:

But if you switch to a different app and then come back to that inspector
(e.g. using the Taskbar), your dialog box won't be shown on top of the
inspector. For that your dialog must be a child of the inspector, and that
means inspector's handle must be specified as the parent when CreateWindow
is called, there is no way around that.
While I never used the dll you mention, looking at the docs it does need the
handle of the parent window (second parameter in MakeModal function).

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"Michael Bauer" <mb@xxxxxxxx> wrote in message
news:1mvo6soq2tsn5$.11y1l9a7pcvpt.dlg@xxxxxxxxxxxxx
Am Thu, 2 Feb 2006 10:13:27 -0700 schrieb Dmitry Streblechenko:

The Word Inspector´s handle isn´t needed for bringing the dialog on to the
top. On the other hand the dialog is modal to Outlook and not to Word.

Dr. Juergen Thuemmler offers a DLL for free which allows to make your form
modal to another process:
http://www.mentalis.org/vbexamples/vbexample.php?vbexample=DSMODAL&category=MISC


--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --


With the Word editor, even SetWindowPos won't help: first, Word
inspectors
do not expose the IOleWindow interface that you can use to read the
window
handle, so FindWindow() for the appropriate window caption and/or class
name
is the only way to retrieve the handle. Secondly, Word inspector lives in
the winword.exe address space rather than outlook.exe, which means you
will
have problems with making the inspector window the parent of your window
(which InputBox won't allow you to do, and doing that in VB is close to
impossible since you need to pass the right handle to the CreateWindow()
function). Even after you manage to do that, closing your dialog would
bring
the main Outlook window to the foregroundv since the inspector window is
in
a different process address space...

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"Michael Bauer" <mb@xxxxxxxx> wrote in message
news:3gg6swsfpjkh$.155mcxsn1bjh.dlg@xxxxxxxxxxxxx
Am Wed, 1 Feb 2006 19:46:29 -0800 schrieb John Svercek:

Unfortunately you need to bring your window on top by code with the
Win32
API SetWindowPos. That´s easier if you´re using a VB Form instead of the
InputBox, because for the latter it´s a lot of work to get the window
handle.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --


I have created a Outlook Addin that creates buttons in the email
window.
One
button pops an Input box so the user can enter information. This works
fine
when the Outlook email editor is used but if Wordmail is used the box
pops
up
behind the email window, it seems to be associated with the main
outlook
window rather than the email window.

I am using vb6 and Outlook 2003 (I have not tested 2000 or 2002 yet).

For completeness here is the code snippet that pops the box, nothing
mysterious there.


ThisKey = InputBox("Enter the Key from JCS Technologies, Inc." _
& vbCrLf & "If you do not have a key you can obtain one at
www.JCSTechnologies.com." _
& vbCrLf & "--Or--" _
& vbCrLf & "You can select CANCEL to continue in un-registered
mode.", _
"Collaboration Addin for Outlook")



.