Access 2007 中的颜色常量

发布于 2024-10-10 12:07:00 字数 213 浏览 0 评论 0原文

MS Access 2007 表单设计视图属性表公开了一些颜色选项,我似乎无法找到这些选项的常量以便在代码中使用它们。具体来说:文本深色文本浅色背景深色标题背景浅色标题

这些是否存在预定义常量?我在对象浏览器或帮助中没有看到它们。如果做不到这一点,有人知道他们的 RGB 十六进制值吗?

The MS Access 2007 Form Design view property sheet exposes some color options that I can't seem to find constants for in order to use them in code. Specifically: Text Dark, Text Light, Background Dark Header and Background Light Header.

Do predefined constants for these exist? I don't seem them in the Object Browser or the Help. Failing that, does anyone know their RGB hex values offhand?

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

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

发布评论

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

评论(4

软糯酥胸 2024-10-17 12:07:00

Microsoft 对此没有很好的记录,因此我将为其他在 Google 中搜索访问颜色常量“背景光标题”的人提供一个较晚的答案。

我见过的最好的信息是 Chris Ward 在 MSDN AccessDev 论坛上对“访问系统颜色常量”的回答,发布于 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=accessdev

公共枚举 SysColors    acColor_Access_Theme_8 = -2147483600 ' 访问主题 8    acColor_Access_Theme_7 = -2147483601 ' 访问主题 7    acColor_Access_Theme_6 = -2147483602 ' 访问主题 6    acColor_Access_Theme_5 = -2147483603 ' 访问主题 5    acColor_Access_Theme_4 = -2147483604 ' 访问主题 4    acColor_Access_Theme_3 = -2147483605 ' 访问主题 3    acColor_Access_Theme_2 = -2147483606 ' 访问主题 2    acColor_Access_Theme_1 = -2147483607 ' 访问主题 1    acColor_Highlight = -2147483608 ' 突出显示    acColor_Borders_Gridlines = -2147483609 ' 边框/网格线    acColor_Altenate_Row = -2147483610 ' 备用行    acColor_Background_Dark_Header = -2147483611 ' 背景深色标题    acColor_Background_Light_Header = -2147483612 ' 背景光标题    acColor_Background_Form = -2147483613 ' 背景表单    acColor_Text_Description = -2147483614 ' 文本描述     acColor_Text_Dark = -2147483615 ' 文本深色    acColor_Text_Light = -2147483616 ' 文本光    acColor_Text_Black = -2147483617 ' 文本黑色    acColor_System_Menu_Bar = -2147483618 ' 系统菜单栏    acColor_System_Menu_Highlight = -2147483619 '系统菜单突出显示    acColor_System_Gradient_Inactive_Caption = -2147483620 '系统渐变非活动标题    acColor_System_Gradient_Active_Caption = -2147483621 '系统渐变活动标题    acColor_System_Static_Text = -2147483622 '系统静态文本    acColor_System_Static = -2147483623 '系统静态    acColor_System_Tooltip_Background = -2147483624 '系统工具提示背景    acColor_System_Tooltip_Text = -2147483625 '系统工具提示文本    acColor_System_3D_Light = -2147483626 ' 系统 3D 光    acColor_System_3D_Shadow = -2147483627 ' 系统 3D 阴影    acColor_System_3D_Highlight = -2147483628 ' 系统 3D 高亮    acColor_System_Inactive_Caption_Light = -2147483629 '系统非活动字幕灯    acColor_System_Button_Text = -2147483630 '系统按钮文本    acColor_System_Alternate_Row = -2147483631 '系统备用行    acColor_System_Button_Shadow = -2147483632 '系统按钮阴影    acColor_System_Button_Face = -2147483633 ' 系统按钮面    acColor_System_Highlight_Text = -2147483634 '系统突出显示文本    acColor_System_Highlight = -2147483635 '系统高亮    acColor_System_Application_Background = -2147483636 '系统应用程序背景    acColor_System_Inactive_Border = -2147483637 '系统非活动边框    acColor_System_Active_Border = -2147483638 '系统活动边框    acColor_System_Title_Bar_Text = -2147483639 '系统标题栏文本    acColor_System_Window_Text = -2147483640 '系统窗口文本    acColor_System_Menu_Text = -2147483641 '系统菜单文本    acColor_System_Window_Frame = -2147483642 '系统窗口框架    acColor_System_Window = -2147483643 '系统窗口    acColor_System_Menu_Background = -2147483644 '系统菜单背景    acColor_System_Inactive_Title_Bar = -2147483645 '系统非活动标题栏    acColor_System_Active_Title_Bar = -2147483646 '系统活动标题栏    acColor_System_Desktop = -2147483647 '系统桌面     acColor_System_Scrollbar = -2147483648# '系统滚动条 结束枚举

请注意,这些不是数字编码的 RGB 颜色:它们是指向 RGB 颜色定义的系统常量或变量的地址如果选择自定义系统或应用程序颜色主题,这些定义将会更改

这实际上是一件好事,因为需要辅助功能设置的用户(最常见的例子是高对比度)不会被硬编码的颜色规范所确定。

您可能会问我如何枚举较亮和较暗的色调 - “文本 1、较亮 50%”等等 - 但它们实际上不是数字常量:颜色描述符的“较亮”和“较暗”部分实际上是调用控件的 .BackTint.BackShade 方法(对于背景颜色)以及字体的 Font.TextColor.TintAndShade 属性(对于前景色) ,您也可以从 VBA 调用这些方法。

不过,我建议您在编写代码时打开帮助页面,因为背景和字体的方法的工作方式略有不同,这种不一致会让您感到困惑。

This isn't very well documented at all by Microsoft, so I'll put in a late answer for everyone else who's searching Google for Access Color Constant "Background Light Header".

The best information I've seen is Chris Ward's answer to 'Access system color constants' on the MSDN AccessDev forum, posted on January 1st 2013.

I've reformatted that information into an enumeration:


' 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=accessdev

Public 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

Note that these aren't numerically-encoded RGB colors: they are addresses to system constants or variables pointing to RGB color definitions which will change if a custom system or application color theme is selected.

This is actually a good thing, as users requiring accessibility settings - high contrast being the most common example - won't be nailed down by your hardcoded color specifications.

You might ask me how to enumerate the lighter and darker tints - 'Text 1, Lighter 50%' and so on - but they aren't actually numeric constants: the 'Lighter' and 'Darker' part of a color descriptor are actually calls to the control's .BackTint and .BackShade methods (for background colors), and the font's Font.TextColor.TintAndShade property (for foreground colors), and you can call those methods from VBA too.

However, I recommend that you open up the help page when you code it up, because the methods for backgrounds and fonts work in slightly different ways, and that inconsistency will catch you out.

孤城病女 2024-10-17 12:07:00

我找到了答案,(有点)艰难的方式。我已经有了在设计时想要设置颜色的表单,因此我在加载期间设置了断点,并使用 Debug.Print 来查找它们的值。在我玩了一下之后,我将用这些值编辑这个答案,并确保我不会混淆哪个是哪个。

与此同时,我将接受贝丝的回答,因为它让我朝着解决方案的方向思考。

编辑

以下是我最初在上下文中询问的四个值:

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 编辑器并打开表单的代码。在“属性”窗口顶部的下拉列表中选择控件,然后从那里读取背景颜色(或其他内容)——它与我在上面的代码中使用的十进制格式相同,而不是在 Acces 设计环境中使用的名称。 编辑 3 必须在主 Access 环境的“设计”或“布局”视图中打开表单才能正常工作。

I found the answer, the (sort of) hard way. I already have forms with the colors I want set up at design time, so I set breakpoints during their load, and used Debug.Print to find their values. I'll Edit this answer with the values after I play around a bit and make sure I'm not mixing up which is which.

In the meantime, I'm going to Accept Beth's answer, since it got me thinking in the direction that led to the solution.

Edit

Here are the values for the four that I asked about originally, in context:

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

Edit 2

Just by accident, I found an easier way to find the values for these. Go into the VB Editor and open the form's code. Select the control in the drop down at the top of the Propeties window and read the BackColor (or whatever) from there--it's in the same decimal format I used in the code above, rather than the name used in the Acces design environment. Edit 3 The form has to be open in Design or Layout view in the main Access environment for this to work.

绿光 2024-10-17 12:07:00

它们可能来自 Windows 系统设置,并不对应于每台计算机上的相同 RGB 值。

找到此

后,您还可以在“背景颜色”属性(或任何颜色属性)中看到 20 个附加选项的列表。其中包括交替行、背景表格、浅色背景标题、深色背景标题、边框/网格线、黑色文本、文本描述、浅色文本、深色文本、突出显示和 Access 主题 1、Access 主题 2 等,最高可达 Access主题 10。这些是您在“访问选项”中选择的配色方案的色调 - 蓝色或银色主题为蓝色色调,黑色主​​题为灰色和黑色色调,所有主题中的橙色色调为突出显示。< /em>

此处

我现在认为它是 Access 本地的。
这可能是您无法使用单个 RGB 值完成的事情。

They may come from Windows system settings and not correspond to the same RGB value on every computer.

After finding this

You can also see in the Back Color property (or, for that matter, any color property) a list of 20 additional options. These include Alternate Row, Background Form, Background Light Header, Background Dark Header, Borders/Gridlines, Text Black, Text Description, Text Light, Text Dark, Highlight, and Access Theme 1, Access Theme 2, and so on, up to Access Theme 10. These are shades of the color scheme you chose in Access Options-shades of blue for the Blue or Silver theme, and shades of gray and black for the Black theme, and with a shade of orange in all themes for Highlight.

here

I'm now thinking it's local to Access.
It may be something you can't do with a single RGB value.

树深时见影 2024-10-17 12:07:00
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
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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文