Create your own color palette
We have learned Binary, Octal & Hexadecimal Numbering Systems and learned few simple rules by which we can devise new numbering systems with any Base value, provided the user knows about it and can decipher the new number.
Last week we have worked with a Form to enter Decimal Numbers and get it converted into Binary as well as to display the RGB Color for that number.
If you would like to learn and understand Binary, Octal and Hexadecimal Numbering Systems then check the following Posts:
- Learn Binary Numbering System
- Learn Binary Numbering System-2
- Octal Numbering System
- Hexadecimal Numbering System
- Colors 24 bits and binary conversion
This week, we will work with a Form based Utility that is more useful to you at design time of a new Project. You can create your own 24 bit custom colors visually and save up to 15 colors in a Color Palette on the Form. You can pick any of this colors and apply it on Form background or on other Control's Foreground, Background or Border Color Properties at design time.
An image of the Employees Form in Design View with the Form's Header Section Property Sheet along with the Color Palette Form is given below for reference:
A new custom color is created on the color palette Form (see the big rectangle) and applied it on the Employees Form Header Section Background, by setting the color value in the Back Color Property.
Click on the image to enlarge it. The Employees Form is in Design View, its Header Section is in selected state and its Property Sheet with the Back Color Property is visible. When you click on one of the grid of 15 Color Boxes (these you can create yourself and save it in each box of the color palette, over-writing the existing ones) will display its corresponding color number in the Text Box above the Color Palette with RGB Color label. You can Copy (Ctrl+C) and Paste (Ctrl+V) into the Property Sheet for Value: Back Color, Fore Color or Border Color, as the case may be, to set the Color of Form Background or Control Colors.
If you are using MS-Access2007 the Color Values in the above Properties will be shown in Hexadecimal Form with the hash symbol like #4E61BC. But you can paste the Decimal Color Value there and it will automatically convert into Hexadecimal form. Since, we have learned Hexadecimal Numbering System I want to draw your attention to a small problem in Microsoft Access2007.
Let us take a sample Color Number in Decimal: 12345678 for the Form Header or Detail Section Background and paste it (or type it) into the Property Sheet and press Enter key. It will be converted into Hexadecimal Number like #4E61BC and the Form Background will be filled with a Dark Blue Color. Take note of the first two digits and last two digits of Hexadecimal Number shown in blue and red colors.
- Now, open the VBA Editing Window (Alt+F11) and display the Debug window (Ctrl+G)
- Type ? HEX(12345678) and press Enter key to convert the Decimal Number 12345678 into Hexadecimal Number. The Question mark is the Print Command.
- The result will be BC614E and if you paste this value into the Property Sheet as #BC614E it will be accepted as it is and the color displayed will be Dark Red Color instead of Dark Blue. Compare this number with the earlier number shown in blue and red colors. MS-Access2007 converts the Color Decimal Number into Hexadecimal form and switches the right-most two Hexadecimal digits with the left-most two digits because it handles the color values (Red and Blue positions) differently.
- Suppose you have a Color Value in Hexadecimal form like 614E (24910 decimal) while pasting the value into the Property sheet you must change it to #4E6100 to get the Color equal to the decimal value 24910. The color number is always expressed in 6 digit hexadecimal number.
- The safest method is to Paste the decimal value into the Color Property and let MS-Access2007 take care of the conversion part.
Now, we will look at the simple trick of designing new Colors (logically you have over 16 Million 24 Bit Colors to work with) and saving it on the Color palette for later use.
You can download a database with the above Form with the Programs from a link at the bottom of this Article, so that you can Import this Form into your new Projects, design your own colors and use them on your Forms or Controls.
You can click on the above image to enlarge it to view the controls properly. Let us examine the controls on the Form.
- There are three Scrollbar controls to input the integer values from 0 - 255 for Red, Green and Blue colors (primary colors) by moving the Scrollbar's slider controls to the right to increase the value, or left to decrease the value, of each color. If you click on the arrow marks on the right/left edges of the scrollbars then the values will increase by 1 on each click or if you click and hold the control then the value will increase/decrease rapidly and the color graph also will change with it. You can watch the large rectangle at the bottom right how the new color is formed by changing the colors with the Red, Green and Blue Scrollbars.
- The Bar Graph at the right of the scrollbars gives a visual indication of the variation of color values, which mixes together to form the new color, and the decimal values appear in the Text Boxes at the left, with the labels Red, Green and Blue.
- The big rectangle label control, at the bottom right of the Form, displays the new color created by setting the values in the scrollbar control.
- The Text Box with the Label RGB Color displays the RGB Color Number.
- You can highlight the number in the RGB Color Text Box and Copy (Ctrl+C) the Number and Paste (Ctrl+V) it in the Form's/Control's Back Color, Fore Color or Border Color Property to set the Color there.
- If you would like to preserve this newly created color then you can Click on the big rectangle, to pick the Color from there, then click on one of the 15 color boxes shown at the left to store that color there for later use.
- If you want to pick a color from one of the saved colors then click on it. The selected color number will appear in the RGB Color Text Box above. You can Copy and Paste it in the Color Property of the Form or Control.
- You have the RGB Color Number, but you want to modify it to your liking then Copy and Paste that color decimal number into the RGB Color Text Box (or type it in) and press the Enter Key. The color will appear in the big rectangle and the Red, Green and Blue Text Boxes will display their corresponding color values. The Bar Chart will give you a visual clue of each color at a glance. You may then move the slider of the Scrollbar Controls to modify the color.
- If you are using MS-Access2007 then you must convert the Hexadecimal Number into Decimal Number by typing ? &hXXxxXX in the Debug Window, where xX stands for Hexadecimal digits. Don't forget to interchange the rightmost two digits with the leftmost two digits of the six digit hexadecimal number. You will get the result in Decimal Number form and then you can copy it into the RGB Color Text Box to modify.
- You can directly enter integer values (Ranging from 0 to 255) in Red, Green and Blue Text Boxes given at the left of the Scrollbar Controls to create a new color.
Digital Clock on Main Switchboard
Label Animation Zoom out Fade
Label Animation in Color
Label Animation Zoom-in Style
Label Animation Variant