StartDownloadsServiceSamplesWorkshopsContact DeutschEnglish
 
Samples
General
Outlook®
 
Awarded by
Microsoft since 2005:
mvp logo
VBOffice Info
Visitors1741963
Impressions6540693
Links
Imprint
Privacy Policy
Contact
E-Mail: Make a form of your own modal against other processes
Author: Michael BauerHomepage
Date: 05.02.2006Accessed: 23134
  
Description

Frequently, Outlook developers need to display a formular to a user to request some data while the user is working on an e-mail.

There's a problem if Word is used as e-mail editor: Your Addin or VBA code runs in the process of Outlook while the e-mail editor runs in the process of Word. That means for instance, you cannot show your formular modal to the mail window; without tricks you even cannot get the mail window on top or give it the focus.

Dr. Jürgen Thümmler provides the DLL dsmodal for free: With that you can easily make any window modal to a window of an other process or even make it modal to all the system.

This sample demonstrates how to obtain the window handles and use dsmodal. Please copy the dsmodal.dll into the system directory (..\winnt\system32) so that it will be found.

The sample uses a VB6 formular. Before loading it, please set the ParentWindowCaption to the caption of the mail window (Inspector.Caption).

With a few changes you can also use it in VBA code. Because the UserForm of the Office library doesn't know the Form_Load event, you could call the code e.g. once in the Inspector_Activate event. Additionally, the UserForm doesn't have a property for its window handle. But with its caption property and the FindChildWindowText function you can get the handle easily.

' <frmSample>
Option Explicit
Private Declare Function MakeModal& Lib "dsmodal" _
  (ByVal AppHwnd&, ByVal hwndDest&, Optional ByVal Beep& = 0)

Public ParentWindowCaption As String

Private Sub Form_Load()
  Dim lParent As Long
  Dim lMe As Long

  lParent = FindChildWindowText(GetDesktopWindow, ParentWindowCaption)

  ' VB Forms:
  lMe = Me.hwnd

  Call MakeModal(lMe, lParent, 1)
End Sub

Private Sub Form_Unload(Cancel As Integer)
  Call MakeModal(0, 0, 0)
End Sub
' </frmSample>

 
 

ReplyAll alerts you before unintentionally replying all, or if you are a confidential BCC recipient of the ... [more]

 

Access the master category list in the blink of an eye, share your categories in a network, get a reminder service, and ... [more]

 

SAM automatically sets the sender, signature, and folder for sent items, for instance based on the recipient ... [more]

 

OLKeeper reliably prevents users from closing their Outlook window and thus possibly missing reminders or ... [more]