Access 2007 中的颜色常量
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
Microsoft 对此没有很好的记录,因此我将为其他在 Google 中搜索访问颜色常量“背景光标题”的人提供一个较晚的答案。
我见过的最好的信息是 Chris Ward 在 MSDN AccessDev 论坛上对“访问系统颜色常量”的回答,发布于 2013 年 1 月 1 日。
我已将该信息重新格式化为枚举:
请注意,这些不是数字编码的 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:
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'sFont.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.
我找到了答案,(有点)艰难的方式。我已经有了在设计时想要设置颜色的表单,因此我在加载期间设置了断点,并使用 Debug.Print 来查找它们的值。在我玩了一下之后,我将用这些值编辑这个答案,并确保我不会混淆哪个是哪个。
与此同时,我将接受贝丝的回答,因为它让我朝着解决方案的方向思考。
编辑
以下是我最初在上下文中询问的四个值:
编辑 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:
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.
它们可能来自 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.