Outlook Plug-ins and Coexisting with the Snagit Application

Many users of the Genius.com Plug-in for Outlook also use a screen capture application from TechSmith called Snagit.  Although Snagit has an Outlook plug-in, it also comes with a stand alone desktop application that consists of a capture and edit form.  When the user grabs an image for use in an email with the stand alone application, problems in other Outlook plug-ins can arise.

The Snagit application executes an Outlook instance separate from the one Outlook plug-ins (including the Genius.com plugin) run in with an open Outlook form.  When the user wants to send a Genius email, the inspector window opened by the Genius Plug-in is under the control of the Snagit process and the Genius Plug-in cannot close it.  So what’s a programmer to do?

Well the approach that seems to work best (with one caveat -as always) is to go to the OS and enumerate the open windows, then search for the inspector window opened by your plugin and use the OS message – pump to send a SC_CLOSE message to that window.  The code looks something like this:

public void CloseInspectorWindow()
{
    // instantiate the delegate
    WindowEnumDelegate del = new WindowEnumDelegate(WindowEnumProc);
 
    // call the win32 function
    EnumChildWindows(IntPtr.Zero, del, 0);
}
 
public static bool WindowEnumProc(IntPtr hwnd, int lParam)
{
    // get the text from the window
    StringBuilder bld = new StringBuilder(256);
    GetWindowText(hwnd, bld, 256);
    string text = bld.ToString();
 
    if (text.Length > 0)
    {
        //"Subject - Message (HTML)"
        if (text.Contains(InspectorCaption))
        {
            SendMessage(hwnd, WM_SYSCOMMAND, SC_CLOSE, 0);
        }
    }
    return true;
}

The inspector caption is saved when the inspector is opened by the Genius Plug-in.  We get the caption because the handle is not available in the Outlook object model.

  • Digg
  • StumbleUpon
  • del.icio.us
  • Facebook
  • Twitter
  • Google Bookmarks
  • DZone
  • HackerNews
  • LinkedIn
  • Reddit