Color queries in Form

chrisjames25

Registered User.
Local time
Today, 23:20
Joined
Dec 1, 2014
Messages
404
HI

Week ago PBaldy and Gasman helped me adapt an allen brown code to change back color of textboxes as i tab through them.

Works like a charm. Question is the code references the colour liek this

Code:
Private Const mlngcFocusBackColor = &HB0FFFF

I know how to change colours using rgb(,,,) but no clue how to find a colour i like and then write it like this. Any help explaining this would be great.

Cheers
 
Here's what I do. There is probably a faster way.
  1. Create a new Form1.
  2. Add a new textbox Text0.
  3. Still in design view, open the property sheet for Text0 and find the BackColor property on the Format tab.
  4. Click on the ellipsis (...) at the far right of BackColor property row, which opens a fancy color palette selector tool.
  5. Pick a color. This now becomes the background color of the control. In later versions of Access, however, this is no longer the actual long integer code. Maybe you get a reversed hex notation (#BBGGRR), or a text description like "Background 1, Darker 35%"
  6. To get the actual number, write code like...
    Code:
    Private Sub Text0_DblClick(Cancel As Integer)
        Debug.Print Me.Text0.BackColor
    End Sub
    ...which writes the actual value to the immediate pane. See how that works?
  7. Copy that number to your constant...
    Code:
    Private Const mlngcFocusBackColor = 11599871
  8. Circuitous, but, done! :)
hth
Mark
 
Possibly a little easier way to accomplish the same;
Create a new blank form.
Add 4 Text boxes to it (TxtR, TxtG, TxtB, TxtCV).
In the after accept for each of the fields, add the following:

Code:
    Me.Detail.BackColor = RGB(TxtR, TxtG, TxtB)
    Me.TxtCV = "Colour Value = " & Me.Detail.BackColor

As you change values, your TxtCV will update to show the current value. Nice part is you can see the rest of the screen clearly to see just what colour it changes to. Toss on other fields / captions as needed to see how they will look on the background.
 
This little open source freeware program called WhatColor shows a tool tip with the RGB values of the pixel under the cursor.

It is one of dozens of simple utilities written using the AutoHotKey scripting language.
 
I use a modified version of a colour converter utility by Daniel Pineault which is available here: https://www.devhut.net/2010/11/17/ms-access-sample-colors/

attachment.php


EDIT: The latest versionof my utility is available at:
 

Attachments

  • ColourConverter.PNG
    ColourConverter.PNG
    19.2 KB · Views: 506
Last edited:

Users who are viewing this thread

Back
Top Bottom