ItemSend -> MsgBox in background ?!?

  • Thread starter Thread starter Courgette
  • Start date Start date
C

Courgette

Hi,
Here is something I realy don't understand :
I use the Application_ItemSend with this code :

Private Sub Application_ItemSend(...)
MsgBox "Coucou"
End Sub

if call when sending a new message, the MessageBox won't appear in
front of my new message window but in front of the Outlook main
window... So that the user can't see it. It goes like if this msgbox
was a Outlook main window Modal Form.

if I use
Private Sub Application_ItemSend(...)
FrmUser1.Show vbModal
End Sub
there is the same problem...

Note that this code works on some of my computers but not all of them.

Can anybody help me ?
 
In case of the message box, you need to specify the window handle of the
window to be used as the message box parent. To get the HWND of Outlook
Explorer/Inspector, QI it for IOleWindow, then call IOleWindow.GetWindow() -
in your case you need to use either Item.GetInspector or
Application.ActiveInspector. I don't think MsgBox() in VB can take a parent
window handle as a parameter, use MessageBox() Windows API function instead.
The same goes for your custom VB form, but I have no idea how (or if) it can
be made a child of another window.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
Dmitry Streblechenko said:
In case of the message box, you need to specify the window handle of the
window to be used as the message box parent. To get the HWND of Outlook
Explorer/Inspector, QI it for IOleWindow, then call IOleWindow.GetWindow() -
in your case you need to use either Item.GetInspector or
Application.ActiveInspector. I don't think MsgBox() in VB can take a parent
window handle as a parameter, use MessageBox() Windows API function instead.
The same goes for your custom VB form, but I have no idea how (or if) it can
be made a child of another window.

Thank you for your assistance but the solution was very different: It
was necessary to unselect the box "Use Word for editing malls". Now,
the ItemSend event works correctly on all my computers. Is this a
normal reaction or a known bug ?

Thanks a lot for your help :)
 
Since MsgBox does not take the parent window handle, it probably uses the
topmost window in the current process. Word editor is implemented by the
word.exe process, while your code runs in the outlook.exe process space, so
I guess that was the problem.

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