确定活动的 Microsoft Visio 绘图窗口及其关联的打印预览和全屏显示窗口的背景色。 读/写。
语法
expression。 BackgroundColor
表达 一个代表 Window 对象的变量。
返回值
OLE_COLOR
备注
Visio 中 OLE_COLOR 属性的有效值可以是下列值之一:
&H00 bbggrr, 其中 bb 是介于 0 和 0xFF (255) 之间的蓝色值, gg 为绿色值, rr 为红色值。
&H800000 xx ,其中 xx 是有效的 GetSysColor 索引。
有关 GetSysColor 函数的详细信息,请在 MSDN 上的 Microsoft 平台 SDK 中搜索“ GetSysColor ”。
OLE_COLOR 数据类型用于返回颜色的属性。 当属性声明为 OLE_COLOR 时,Visual Basic 编辑器中的属性窗口会显示一个颜色选取器对话框,该对话框允许用户直观地选择属性的颜色,而无需记住等效的数字。
另外,您还可以为 OLE_COLOR 使用下列 Microsoft Visual Basic for Applications (VBA) 颜色常量。
常量 | 值 | 说明 |
---|---|---|
vbBlack | 0x0 | 黑色 |
vbRed | 0xFF | 红色 |
vbGreen | 0xFF00 | 绿色 |
vbYellow | 0xFFFF | 黄色 |
vbBlue | 0xFF0000 | 蓝色 |
vbMagenta | 0xFF00FF | 洋红 |
vbCyan | 0xFFFF00 | 蓝绿 |
vbWhite | 0xFFFFFF | 白色 |
对于绘图窗口、打印预览窗口或全屏视图窗口,将窗口的 BackgroundColor 属性设置为默认 (-1 以外的值,) 将覆盖该窗口集的 ApplicationSettings.DrawingBackgroundColor、 ApplicationSettings.PrintPreviewBackgroundColor 和 ApplicationSettings.FullScreenBackgroundColor 设置。 为了能够重置同一组窗口的这些属性,必须将 BackgroundColor 重置为其默认值 -1。 如果打开了多个绘图,则为一组窗口设置 BackgroundColor 不会影响其他打开窗口集的设置。
但是,对于 ShapeSheet 窗口,将窗口的 BackgroundColor 属性设置为默认值以外的值会更改 ShapeSheet 窗口的背景色,但不会影响任何其他窗口设置。
示例
以下 VBA 宏显示如何使用 BackgroundColor 属性来获取和设置当前绘图窗口背景色。 它还演示如何从 Visio Application 对象获取 ApplicationSettings 对象,并演示 BackgroundColor 属性与 ApplicationSettings.DrawingBackgroundColor 属性之间的关系。 此示例假定 Visio 中打开了一个活动绘图窗口,并且所有背景色属性最初都设置为其默认值。
Public Sub BackgroundColor_Example()
Dim vsoApplicationSettings As Visio.ApplicationSettings
Set vsoApplicationSettings = Visio.Application.Settings
'Get the current application background color.
Debug.Print vsoApplicationSettings.DrawingBackgroundColor
'Get the active window background color.
Debug.Print ActiveWindow.BackgroundColor
'Change the application background color.
'This also changes the active window color as
'well as the setting in the Color Settings dialog box.
vsoApplicationSettings.DrawingBackgroundColor = vbRed
'Change the active window background color.
ActiveWindow.BackgroundColor = vbMagenta
'Change the application background color again.
'This time, there is no change in the current
'window color, but the dialog box setting changes.
vsoApplicationSettings.DrawingBackgroundColor = vbYellow
'Reset Window.BackgroundColor to its default value.
ActiveWindow.BackgroundColor = -1
'Change the application background color again.
'Now both the active window color
'and the dialog box setting change.
vsoApplicationSettings.DrawingBackgroundColor = vbBlue
End Sub
支持和反馈
有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。