Color constants in Access 2007 - vba

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?

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.

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.

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.

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

Related

How to programmatically set Glow Effect (Size and Color) to Text in PowerPoint?

I want to set a glow effect for text in PowerPoint. I have found some code online (e.g. here https://www.skphub.com/2007/ppt001.htm) which claims that one can directly set the Glow Size and Color.
But when I tried, I found that I can set the Glow Size but not the Color (it is read-only).
Globals.ThisAddIn.Application.ActiveWindow.Selection.TextRange2.Font.Glow.Radius = 10 'this works
Globals.ThisAddIn.Application.ActiveWindow.Selection.TextRange2.Font.Glow.Color = RGB(255, 0, 0) 'this fails
My question is how can I set the Text glow color in PPT (2016 or 2019)?
Thanks!
Got it:
use Font.Glow.Color.RBG

How to change the background color of a windows context menu using the winapi

I am currently trying to customize a context menu in Outlook. For the regulars I have had a series of issues which can be seen in this question and with this question.
I would like to adjust the background color a little.
Dim hBrush As IntPtr = NativeMethodsEX.CreateSolidBrush(ColorTranslator.ToWin32(System.Drawing.Color.Red))
Dim mi As New NativeMethodsEX.MenuInfo
With mi
.cbSize = Marshal.SizeOf(mi)
.fMask = NativeMethodsEX.MIM_STYLE Or NativeMethodsEX.MIM_BACKGROUND Or NativeMethodsEX.MIM_APPLYTOSUBMENUS
.dwStyle = NativeMethodsEX.MNS_NOCHECK
.hbrBack = hBrush
End With
NativeMethodsEX.SetMenuInfo(aHwnd, mi)
This code however produces this;.
How can I also change the background of the left hand side or what even is the class name of that part of the window. Also it has a border as well. What is its class name or how can I either remove it or change it?

Not able to set the Backcolor of label as Transparent

Using properties of "label" not able to set the backcolor as transparent ... when i select the color transparent from the option which is showing some color as backcolor, if transparent works properly must show background instead of some colors. please help
If you add a control at design time when setting the background to transparent it 'displays' the background of the form not the control on which it was placed unless that control is a container such as a panel.
2 options:
1 place the label on a panel and the label then displays the panel background (which can be a picture if that is what you are trying to do)
2 place the label programatically i.e.
dim Label1 As New Label
Control.Controls.Add(Label1)
Label1.BackColor = Color.Transparent

How to implement this using Windows forms?

I have two problems with my windows form in Visual Basic .NET 2008. If you have worked with sticky notes you will understand me better.
Now my problems:
If you look you'll see the background color of number 1 and 2 are
diffrent but both belongs to the same control. How is this possible?
In right bottom corner, there is something by which a user can resize the form.
How I can do this?
Item 1: I think you are referring to LinearGradient Brush-- look in the System.Drawing.Drawing2D class.
Item 2: They are drawing a resize handler. You can try using the ControlPaint.DrawSizeGrip method or draw your own.
Update:
Per your comments, you can look into Owner-drawing a Windows.Forms TextBox
You can draw a gradient background by overriding OnPaintBackground():
protected override void OnPaintBackground(PaintEventArgs e)
{
// set these to whatever you want
Color color1 = Color.LightBlue;
Color color2 = Color.DarkBlue;
using (Brush backbrush =
new LinearGradientBrush(e.ClipRectangle, color1, color2,
LinearGradientMode.Vertical))
{
e.Graphics.FillRectangle(backbrush, e.ClipRectangle);
}
}
You can show the size gripper by setting the form's SizeGripStyle to Show:
SizeGripStyle = SizeGripStyle.Show;
Or just set it in the designer.
EDIT: Look at this page for creating a transparent textbox (if the textbox is transparent, the gradient form background will show through.)

Color.ToArgb relation between 5046311 and 14221235?

the form backcolor is 14221235 , but when i set the customcolor in colordialog to equal the form backcolor, it sets it to 5046311 !!! what is the problem?
this is how i am getting the background color:
get_background = Str(Abs(Form1.BackColor.ToArgb))
the reason i am turning it into a string is because i will feed it into a string which has "32498239, 234234234, 23423234, 32234432432, 423324234"
then i take this string and put it in customcolors like this. btw this piece of code works fine:
Dim numberStrings = My.Settings.mytext1.Split(","c).Select(Function(x) x.Trim())
ColorDialog1.CustomColors = numberStrings.Select(Function(x) CInt(x)).ToArray()
a user below mentioned that toargb takes into account the opacity. this is an excellent point indeed, and i want to clarify that i DO NOT need the opacity. how would i do toargb without taking into opacity?
this is what you want
Microsoft.VisualBasic.RGB(Me.BackColor.R, Me.BackColor.G, Me.BackColor.B).ToString
The 32-bit result from .ToArgb() contains not just the three visible color components (red, green and blue) but also the alpha component, which is essentially opacity. This is a pure guess on my part, but I think the ColorDialog is just used for picking RGB values, so when you set the color to the form's BackColor, the dialog just ignores the alpha component (or sets it to zero), which is why you end up getting a different number from the .ToArgb() method.
Note: this is just speculation on my part. It would help if you posted a code sample that demonstrates the specific problem.
I don't really understand the question. You want to set the custom color dialog CustomColor property to (the form's backcolor) r + g + b components? Not sure why you would do that, you can always just get the form's backcolor, set the Alpha value to 255 and then set the result to the CustomColor property:
Color c = Color.FromArgb( 255, form1.BackColor );
myColorDlg.CustomColor = c;
Or just use form1.BackColor.ToArgb() & 0xFFFFFF (if you want the integer value).
If you are asking for ARGB (A = Alpha) then you are asking for the opacity information. Instead you could use the R, G, B Properties of Color Independently.
You could use Color.FromArgb(255, me.BackColor).ToArgb() in order to get the ARGB value of the same color with 100% opacity.
To highlight how to pass the same colour (Using Fredou's answer) from a colorDialog to set a pie chart segment colour, one which is a .Net embedded chart and the other an Excel chart:
embchartPie.Series(0).Points(Index).Color = ColorDialog1.Color
With ColorDialog1.Color
xl_Pie_Chart.SeriesCollection(1).points(Index + 1).format.fill.forecolor.rgb = RGB(.R, .G, .B).ToString
End With