如何在 Outlook VSTO 中更改鼠标指针
How change Mouse pointer in Outlook VSTO
我正在尝试使用 Outlook 功能区中的自定义按钮将文件上传到远程服务器。发生了以下步骤
- 用户单击功能区中的上传文件按钮,会看到文件选择器对话框。
- 将看到文件 selection 弹出窗口,用户 select 一个或多个文件
- 点击确定按钮后,我只想将默认光标更改为等待光标
- 文件上传完成后,我尝试恢复默认光标
我的代码如下
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
的 compose window 中
你需要导入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;
}
}
我正在尝试使用 Outlook 功能区中的自定义按钮将文件上传到远程服务器。发生了以下步骤
- 用户单击功能区中的上传文件按钮,会看到文件选择器对话框。
- 将看到文件 selection 弹出窗口,用户 select 一个或多个文件
- 点击确定按钮后,我只想将默认光标更改为等待光标
- 文件上传完成后,我尝试恢复默认光标
我的代码如下
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
的 compose window 中你需要导入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;
}
}