Outlook 2010 VSTO - 窗体区域中的标准 Office 图标

发布于 2024-11-29 20:34:22 字数 330 浏览 1 评论 0原文

将显示标准 Outlook 图标的按钮添加到功能区非常简单。将按钮的属性 OfficeImageId 设置为已知 ID(例如“EncryptMessage”)即可完成。有关可能值的完整列表,请参阅Office 2010 加载项:图标库< /a>.

现在我的问题是,我可以在表单区域中实现相同的功能吗?我的意思是,添加一个显示标准 Office 图标的 PictureBox?显然没有 OfficeImageId 属性,但也许有人知道解决方法。

Adding buttons showing standard Outlook icons to a Ribbon is pretty straightforward. Set the button's property OfficeImageId to a known ID (e.g. "EncryptMessage") and you're done. For a complete list of possible values see Office 2010 Add-In: Icons Gallery.

Now my question is, can i archieve the same thing in a Form Region? I mean, adding for example a PictureBox showing that standard Office icon? Obviously there is no OfficeImageId property, but perhaps someone knows a workaround.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

我一直都在从未离去 2024-12-06 20:34:22

您提供的链接指向 Word 2010 文档。到目前为止,我一直在使用 Excel 2007 文档,其功能区扩展显示所有内置图标(“其他人下载的内容”部分中的“2007 Office System 加载项:图标库”)。在此工作簿中,您可以单击图标,并且一个VBA窗体勇敢地显示了16x16和32x32的图标。

这只是一个带有两个图片框的VBA窗体。

   Sub OnAction(control As IRibbonControl, id As String, index As Integer)
    If (control.Tag = "large") Then
        id = Strings.Mid(id, 3)
    End If

    Dim form As New ControlInfoForm
    form.nameX.Caption = "imageMso: " & id
    Set form.Image1.Picture = Application.CommandBars.GetImageMso(id, 16, 16)
    Set form.Image2.Picture = Application.CommandBars.GetImageMso(id, 32, 32)
    form.Show
End Sub

希望这可以帮助您获取图像。

The link you provided goes to a Word 2010 document. I was using until now the Excel 2007 document with a ribbon extension showing all the built-in icons ("2007 Office System Add-In: Icons Gallery" in the "What others download section). In this Workbook you can click on an icon, and a VBA form shows the 16x16 and the 32x32 icon bravely.

It's just a VBA form with two picture boxes. The code is as follows:

   Sub OnAction(control As IRibbonControl, id As String, index As Integer)
    If (control.Tag = "large") Then
        id = Strings.Mid(id, 3)
    End If

    Dim form As New ControlInfoForm
    form.nameX.Caption = "imageMso: " & id
    Set form.Image1.Picture = Application.CommandBars.GetImageMso(id, 16, 16)
    Set form.Image2.Picture = Application.CommandBars.GetImageMso(id, 32, 32)
    form.Show
End Sub

I hope that this helps you to get the image.

寄风 2024-12-06 20:34:22

要完成上述帖子 MSDN 论坛上的这篇文章,这里是VB.Net 答案:

获取 IPictureDisp

Dim MyMso As String = "FileFind"
Dim MyIPicture As stdole.IPictureDisp = Globals.ThisAddIn.Application.CommandBars.GetImageMso(MyMso, 16, 16)

扩展以转换为 Drawing.Image

<System.Runtime.CompilerServices.Extension()>    
Function GetImage(MyIPicture As stdole.IPictureDisp) As Drawing.Image
    If CType(MyIPicture.Type, Integer) = 1 then
        Return = Drawing.Image.FromHbitmap(MyIPicture.Handle, MyIPicture.hPal)
    else
        Throw New ArgumentException("Image not supported.")
    End If
End Function

分配给控件

Dim MyButton As New Button
MyButton.Image = MyIPicture.GetImage

注意:我不知道为什么 If CType(MyIPicture.Type , Integer) = 1 是必需的。欢迎任何见解..!另外,同一篇文章引用了 System.Windows.Forms.AxHost,但似乎没有在任何地方使用它?

To complete the above post with this post on MSDN Forum, here is a VB.Net answer:

Get the IPictureDisp

Dim MyMso As String = "FileFind"
Dim MyIPicture As stdole.IPictureDisp = Globals.ThisAddIn.Application.CommandBars.GetImageMso(MyMso, 16, 16)

Extension to convert into a Drawing.Image

<System.Runtime.CompilerServices.Extension()>    
Function GetImage(MyIPicture As stdole.IPictureDisp) As Drawing.Image
    If CType(MyIPicture.Type, Integer) = 1 then
        Return = Drawing.Image.FromHbitmap(MyIPicture.Handle, MyIPicture.hPal)
    else
        Throw New ArgumentException("Image not supported.")
    End If
End Function

Assign to a control

Dim MyButton As New Button
MyButton.Image = MyIPicture.GetImage

Note: I have no idea why If CType(MyIPicture.Type, Integer) = 1 is required. Any insight is welcome.. ! Also, the same post refers to System.Windows.Forms.AxHost, but does not seem to be using it anywhere?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文