outlook中的sendmessage C#addin无法正常工作

时间:2014-08-15 03:19:49

标签: c# outlook vsto outlook-addin

我正在尝试使用SendMessage滚动左侧导航窗格的Outlook C#加载项。它似乎没有效果。加载项是否在低于Outlook的权限级别下运行,因此由于UIPI而阻止SendMessage工作?

我使用EnumChildWindows(递归)迭代,找到左侧导航窗格子窗口的句柄,使用Spy ++识别,使用GetWindowText按类名查找。 " workerBeeFunc"是我的代理人,由EnumChildWindows调用。 Spy ++告诉我导航窗格窗口是具有类名" NUIDocumentWindow"的第二个窗口的子窗口。 (我已将所有WinAPI DLLImport语句留在此处):

private const int WM_VSCROLL = 277; // Vertical scroll
private const int SB_PAGEDOWN = 3; // Scrolls one page down
static StringBuilder childWindowNames = new StringBuilder();
private int NUIWindowCounter = 0;
private stopIterating as bool = false;

public delegate int EnumChildProc(IntPtr hWnd, IntPtr lParam);  //Declare the delegate

public int workerBeeFunc(IntPtr hwndChild, IntPtr Param) //The function the delegate of EnumChildWindows goes to to get the work done.
{
   int a;
   a = WinAPIs.GetWindowText(hwndChild, childWindowNames, 100); //childWindowNames gets cleared on each iteration of this function

   if (childWindowNames.ToString() == "NUIDocumentWindow")
   { 
      NUIWindowCounter++;


      if (NUIWindowCounter == 2)  //The NEXT window is the Navigation Pane
      {
         stopIterating = true;
      }
   return 1;  //Keep iterating
   }

   if (stopIterating == true)
   {
      SendMessage(hwndChild, WM_VSCROLL, (IntPtr)SB_PAGEDOWN, IntPtr.Zero);
      return 0;   //Stop iterating
   }
}

由于UIPI,SendMessage会无声地失败吗?

感谢。

1 个答案:

答案 0 :(得分:0)

Addins在与Outlook本身相同的安全上下文中运行。

不需要任何控件来使用WM_VSCROLL消息。你真的在Spy ++中看到它吗?