如何为 Office XP CommandBars 设置掩码和图片属性求解答

如何为 Office XP CommandBars 设置掩码和图片属性求解答,第1张

使用这些属性可以自定义生成的命令栏控件上放置图片

请注意 这些属性还是在 Microsoft Office 2003 中可用。使用 掩码 和 图片 属性定义为类型 IPictureDisp ,这是 stdole 库的成员。 IPictureDisp 使用不能跨进程边界封送的方法。 因此,掩码和图片 属性才能调用的进程 (自动化的 VBA 宏的外接程序和进程中运行的 ActiveX DLL)。

收起这个图片展开这个图片将图像保存为 circle.bmp。要创建掩码,用黑色填充圆,然后用白色填充圆之外的区域。 掩码图片添加到 CommandBar 控件时, 掩码的黑色区域是可见的而白色的区域是透明。

收起这个图片展开这个图片将图像保存为 mask.bmp。创建COM 加载项的步骤启动Visual Basic 并创建新的 AddIn 项目。在项目 菜单中上, 单击 引用。 如果低于版本 XP 处于选中状态,清除"Microsoft Office"类型库,将类型库,并为 Microsoft Office XP 中选择类型库。 单击 确定。在项目资源管理器右键单击 frmAddin ,然后单击 删除frmAddin。在项目器,双击 连接 设计器。 为 应用程序 选择Microsoft Excel ,并为 初始加载行为 选择启动。在视图 菜单单击 代码 ,然后将代码中用以下:

Option Explicit Dim oExcel As Object Dim WithEvents oButton As Office.CommandBarButton Private Sub AddinInstance_OnConnection(ByVal Application As Object, _ ByVal ConnectMode As AddInDesignerObjects.ext_ConnectMode, _ ByVal AddInInst As Object, custom() As Variant) Dim oPic As stdole.IPictureDisp Dim oMask As stdole.IPictureDisp ' Load the picture and mask. Set oPic = LoadPicture(App.Path &"\circle.bmp") Set oMask = LoadPicture(App.Path &"\mask.bmp") ' Save an instance of our application. Set oExcel = Application ' Create a new button on the standard CommandBar. Set oButton = oExcel.CommandBars("Standard").Controls.Add(msoControlButton) With oButton ' Set a tag for the button. .Tag = "My Button" ' Set the event to fire when the button is pressed. .OnAction = "!<" &AddInInst.ProgId &">" ' Set the picture property -- if you are using the Mask property, this ' property must be set before you set the Mask property. .Picture = oPic ' Set the Mask property. .Mask = oMask ' Show the button. .Visible = True End With End Sub Private Sub AddinInstance_OnDisconnection(ByVal RemoveMode As _ AddInDesignerObjects.ext_DisconnectMode, custom() As Variant) ' Delete the button. oButton.Delete ' Release references. Set oButton = Nothing Set oExcel = Nothing End Sub Private Sub oButton_Click(ByVal Ctrl As Office.CommandBarButton, _ CancelDefault As Boolean) ' Our button was pressed. MsgBox "The button was pressed!" End Sub 保存该项目并生成外接程序位图存储在文件夹中。启动Excel。 一个带有黄色圆圈的新控件将显示标准的 CommandBar 上中。请注意围绕黄色圆圈的区域是透明。其他注意事项

在原有的图片编码方法基础上,增加像素的透明度信息。图形处理中,通常把RGB三种颜色信息称为红通道、绿通道和蓝通道,相应的把透明度称为Alpha通道。多数使用颜色表的位图格式都支持Alpha通道。

简单的来说,掩码图就是设置一个区域,使其不参加处理

BMP

BMP是一种与硬件设备无关的图像文件格式,使用非常广。它采用位映射存储格式,除了图像深度可选以外,不采用其他任何压缩,因此,BMP文件所占用的空间很大。BMP文件的图像深度可选lbit、4bit、8bit及24bit。B...


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/bake/11385123.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-15
下一篇2023-05-15

发表评论

登录后才能评论

评论列表(0条)

    保存