MS Access 2007表单设计视图属性表公开了一些我似乎无法找到常量的颜色选项,以便在代码中使用它们 - 特别是“Text Dark”,“Text Light”,“Background Dark Header “和”背景光标题“。是否存在预先定义的常量?我在对象浏览器或帮助中看起来不像。如果不这样做,有人知道他们的RGB十六进制值吗?
答案 0 :(得分:4)
微软并没有完全记录这些内容,所以我会为其他所有搜索Google Access Color Constant"背景的人提供一个迟到的答案。 Light Header" 。
我见过的最佳信息是Chris Ward's answer to 'Access system color constants' on the MSDN AccessDev forum,于2013年1月1日发布。
我已将该信息重新格式化为枚举:
' Access system color constants, documented by Chris Ward on MSDN Forums, 01-Jan-2013 ' https://social.msdn.microsoft.com/Forums/en-US/ccf8b3b7-fa6b-4d05-9883-44b3642e6688/color-themes-decimal-equivelant-documented?forum=accessdevPublic Enum SysColors acColor_Access_Theme_8 = -2147483600 ' Access Theme 8 acColor_Access_Theme_7 = -2147483601 ' Access Theme 7 acColor_Access_Theme_6 = -2147483602 ' Access Theme 6 acColor_Access_Theme_5 = -2147483603 ' Access Theme 5 acColor_Access_Theme_4 = -2147483604 ' Access Theme 4 acColor_Access_Theme_3 = -2147483605 ' Access Theme 3 acColor_Access_Theme_2 = -2147483606 ' Access Theme 2 acColor_Access_Theme_1 = -2147483607 ' Access Theme 1 acColor_Highlight = -2147483608 ' Highlight acColor_Borders_Gridlines = -2147483609 ' Borders/Gridlines acColor_Altenate_Row = -2147483610 ' Altenate Row acColor_Background_Dark_Header = -2147483611 ' Background Dark Header acColor_Background_Light_Header = -2147483612 ' Background Light Header acColor_Background_Form = -2147483613 ' Background Form acColor_Text_Description = -2147483614 ' Text Description acColor_Text_Dark = -2147483615 ' Text Dark acColor_Text_Light = -2147483616 ' Text Light acColor_Text_Black = -2147483617 ' Text Black acColor_System_Menu_Bar = -2147483618 ' System Menu Bar acColor_System_Menu_Highlight = -2147483619 ' System Menu Highlight acColor_System_Gradient_Inactive_Caption = -2147483620 ' System Gradient Inactive Caption acColor_System_Gradient_Active_Caption = -2147483621 ' System Gradient Active Caption acColor_System_Static_Text = -2147483622 ' System Static Text acColor_System_Static = -2147483623 ' System Static acColor_System_Tooltip_Background = -2147483624 ' System Tooltip Background acColor_System_Tooltip_Text = -2147483625 ' System Tooltip Text acColor_System_3D_Light = -2147483626 ' System 3D Light acColor_System_3D_Shadow = -2147483627 ' System 3D Shadow acColor_System_3D_Highlight = -2147483628 ' System 3D Highlight acColor_System_Inactive_Caption_Light = -2147483629 ' System Inactive Caption Light acColor_System_Button_Text = -2147483630 ' System Button Text acColor_System_Alternate_Row = -2147483631 ' System Alternate Row acColor_System_Button_Shadow = -2147483632 ' System Button Shadow acColor_System_Button_Face = -2147483633 ' System Button Face acColor_System_Highlight_Text = -2147483634 ' System Highlight Text acColor_System_Highlight = -2147483635 ' System Highlight acColor_System_Application_Background = -2147483636 ' System Application Background acColor_System_Inactive_Border = -2147483637 ' System Inactive Border acColor_System_Active_Border = -2147483638 ' System Active Border acColor_System_Title_Bar_Text = -2147483639 ' System Title Bar Text acColor_System_Window_Text = -2147483640 ' System Window Text acColor_System_Menu_Text = -2147483641 ' System Menu Text acColor_System_Window_Frame = -2147483642 ' System Window Frame acColor_System_Window = -2147483643 ' System Window acColor_System_Menu_Background = -2147483644 ' System Menu Background acColor_System_Inactive_Title_Bar = -2147483645 ' System Inactive Title Bar acColor_System_Active_Title_Bar = -2147483646 ' System Active Title Bar acColor_System_Desktop = -2147483647 ' System Desktop acColor_System_Scrollbar = -2147483648# ' System Scrollbar End Enum
请注意,这些不是数字编码的RGB颜色:它们是系统常量的地址或指向RGB颜色定义的变量,如果选择了自定义系统或应用程序颜色主题,它将发生变化
这实际上是一件好事,因为需要辅助功能设置的用户 - 高对比度是最常见的例子 - 不会受到硬编码颜色规范的限制。
你可能会问我如何列举较浅和较暗的色调 - '文字1,打火机50%'等等 - 但它们实际上并不是数字常数:'打火机'和“黑暗'颜色描述符的一部分实际上是调用控件的.BackTint
和.BackShade
方法(用于背景颜色),以及字体的Font.TextColor.TintAndShade
属性(用于前景色) ),你也可以从VBA调用这些方法。
但是,我建议您在编写代码时打开帮助页面,因为背景和字体的方法工作方式略有不同,而且不一致会让您感到不舒服。
答案 1 :(得分:1)
它们可能来自Windows系统设置,并且不对应于每台计算机上的相同RGB值。
找到这个
您还可以在Back Color属性(或者,就此而言,任何颜色属性)中看到20个附加选项的列表。这些包括备用行,背景表单,背景光标题,背景黑色标题,边框/网格线,文本黑色,文本描述,文本光,文本黑暗,突出显示和访问主题1,访问主题2,等等,直到访问主题10.这些是您在“访问选项”中选择的颜色方案的阴影 - 蓝色或银色主题的蓝色阴影,黑色主题的灰色和黑色阴影,以及所有主题中的高光阴影。 / em>
我现在认为这是Access的本地化。 这可能是您无法使用单个RGB值进行的操作。
答案 2 :(得分:1)
我找到了答案,(某种)艰难的方式。我已经在设计时使用了我想要设置的颜色的表单,因此我在加载期间设置了断点,并使用Debug.Print
来查找它们的值。在我玩了一下之后,我会用值来编辑这个答案,并确保我不会混淆哪个是哪个。
与此同时,我将接受Beth的回答,因为它让我思考导致解决方案的方向。
修改强>
以下是我最初询问的四个值,在上下文中:
Public Sub SetHeader(frm As Form)
On Error GoTo Error_Handler
'Access-specific Theme colors
Const TextLight As Long = -2147483616
Const TextDark As Long = -2147483615
Const BackLight As Long = -2147483612
Const BackDark As Long = -2147483611
With frm
If gblnAuthorized Then
.FormHeader.BackColor = BackLight
!Auto_Title0.ForeColor = TextDark
Else
.FormHeader.BackColor = BackDark
!Auto_Title0.ForeColor = TextLight
End If
End With
Exit_Procedure:
Exit Sub
Error_Handler:
DisplayUnexpectedError Err.Number, Err.Description
Resume Exit_Procedure
Resume
End Sub
修改2
偶然地,我发现了一种更容易找到这些值的方法。进入VB编辑器并打开表单的代码。在Propeties窗口顶部的下拉列表中选择控件,然后从那里读取BackColor(或其他) - 它与我在上面的代码中使用的十进制格式相同,而不是在Acces设计环境中使用的名称。 编辑3 表单必须在主Access环境的“设计”或“布局”视图中打开才能生效。
答案 3 :(得分:0)
VBA Constant Description
vbScrollBars Scrollbar color
vbDesktop Desktop color
vbActiveTitleBar Color of the title bar for the active window
vbInactiveTitleBar Color of the title bar for the inactive window
vbMenuBar Menu background color
vbWindowBackground Window background color
vbWindowFrame Window frame color
vbMenuText Color of text on menus
vbWindowText Color of text in windows
vbTitleBarText Color of text in caption, size box, and scroll arrow
vbActiveBorder Border color of active window
vbInactiveBorder Border color of inactive window
vbApplicationWorkspace Background color of multiple document interface applications
vbHighlight Background color of items selected in a control
vbHighlightText Text color of items selected in a control
vbButtonFace Color of shading on the face of command buttons
vbButtonShadow Color of shading on the edge of command buttons
vbGrayText Grayed (disabled) text
vbButtonText Text color on push buttons
vbInactiveCaptionText Color of text in an inactive caption
vb3DHighlight Highlight color for 3-D display elements
vb3DDKShadow Darkest shadow color for 3-D display elements
vb3DLight Second lightest 3-D color after vb3DHighlight
vbInfoText Color of text in ToolTips
vbInfoBackground Background color of ToolTips