【问题标题】:How change Mouse pointer in Outlook VSTO如何更改 Outlook VSTO 中的鼠标指针
【发布时间】:2020-11-13 17:27:59
【问题描述】:

我正在尝试使用 Outlook 功能区中的自定义按钮将文件上传到远程服务器。发生以下步骤

  1. 用户单击功能区中的上传文件按钮,将看到文件选择器对话框。
  2. 将看到文件选择弹出窗口,用户选择一个或多个文件
  3. 单击确定按钮后,我只想更改默认光标等待光标
  4. 文件上传完成后,我尝试恢复默认光标

我的代码如下

 public void UploadFiles(Office.IRibbonControl control)
    {
      OpenFileDialog openFileDialog = new OpenFileDialog();
        if (openFileDialog.ShowDialog() == DialogResult.OK)
        {
           Cursor.Current = Cursors.WaitCursor
          //some code which will call rest API to upload file 
           Cursor.Current = Cursors.default
        }
     }

但上面的代码并没有改变光标。该按钮出现在 Outlook 的撰写窗口中

【问题讨论】:

  • 这能回答你的问题吗? Wait Cursor in VSTO word add-in application
  • 不,这不是答案,我试图在 Outlook 中做而不是 word
  • 啊,我明白了。您是否尝试将其更改为 Outlook?即:Microsoft.Office.Interop.Outlook.
  • 先生,Microsoft.Office.Interop.Outlook 中没有任何可用的 application.System.Cursor 属性。我今天已经尝试了一整天才发帖。

标签: c# outlook vsto


【解决方案1】:

需要导入Word.DLL,然后使用如下代码

 public void UploadFiles(Office.IRibbonControl control)
  {
     OpenFileDialog openFileDialog = new OpenFileDialog();
    if (openFileDialog.ShowDialog() == DialogResult.OK)
    {
            Outlook.Inspector currentInspector = Globals.ThisAddIn.Application.ActiveInspector();
            Word.Document document = currentInspector.WordEditor;
            Word.Application wordApp = document.Application;
            wordApp.System.Cursor = Word.WdCursorType.wdCursorWait;
            //perform your task
           //Switch to default Cursor 
           wordApp.System.Cursor = Word.WdCursorType.wdCursorNormal; 

 }
 }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-06-15
    • 1970-01-01
    • 2023-03-07
    • 1970-01-01
    • 1970-01-01
    • 2013-09-24
    • 2011-06-01
    • 1970-01-01
    相关资源
    最近更新 更多