Windows Colour Dialog (aka ChooseColorA) - can the "basic" colours be changed? (1 Viewer)

AOB

Registered User.
Local time
Today, 09:56
Joined
Sep 26, 2012
Messages
632
Does anybody know if, when calling the Windows Colour Dialog (to provide an option for a user to select a colour for something) :

Open the Windows Color Dialog from VBA

...is it possible to define, set or change, the Basic Colours that are loaded into that dialog (as opposed to the Custom Colours, which can, as is seen within the code, be very easily pre-defined via an array of Long variables)

That is, the block of 8x6 colours at the top, as opposed to the block of 8x2 colours at the bottom?

I find the standard / stock set fairly useless, as many of them are either incredibly similar (there are 5 different greens that are barely distinguishable to the naked eye), or quite garish / loud. Basically, nobody in their right mind would choose any of them and even fewer are going to be willing/bothered going to the trouble of manually working out the red, green and blue constituents to find something vaguely resembling the colour they actually want.

I'd much prefer to pre-define them to be similar to the "Theme Colours" that you get in Excel when formatting font or interior (i.e. 10 columns of basic colours, graduating from lighter to darker down 6 rows) or the similar colour-picker options in the Design view for a form when you modify any of the colour attributes of a control (e.g. Back Color, Fore Color etc.)

(Obviously 60 into 48 won't go; I'm not looking for an exact reproduction here, this is just an example!! Also, I know I've already stated above, I can always pre-define the custom colours instead, but that only gives me 16 shades to play with, when there are 48 directly above going to waste)

I know Excel has things like Application.Dialogs(xlDialogEditColor) and Application.Dialogs(xlDialogColorPalette) etc. but they're not accessible from Access (at least, not without loading up an instance of Excel, which is overkill when all I want is a simple integer representation of a user-selected colour)

The ChooseColor API is pretty much perfect for my requirements apart from the fact the colours it starts off with are terrible!

Any suggestions?
 
To the best of my understanding, there are some predefined colors you can't change in that dialog box, but the color choices include some "slots" where you can put the custom colors you want. It has been a while since I used that feature, because for a long time I have simply supplied the RGB colors I wanted via the 24-bit (16 million) color palette. I defined the colors I wanted using one of the custom-color combinations and created the hexadecimal strings needed for those colors. Thereafter, no more color selection.
 
  • Like
Reactions: AOB
I doubt the base set can be modified.

Why is this needed? Do you want to limit user's color choices to a defined set? How many colors? After a certain point, can't avoid getting colors that look close in hue.

If users want unlimited choices then they should be willing to learn the tool. If they can't be bothered to use the ombre palette on the right, then they shouldn't be offered the Windows color picker to begin with and should only have a standardized set to select from. Build your own "color picker" with a form if you want to provide a standardized set.
 
Last edited:
  • Like
Reactions: AOB
Honestly, it's purely for aesthetic / convenience. The native Windows ChooseColorA API is perfect in that it provides a ready-made visual interface to specify a colour and return it as a simple long integer, to apply where needed elsewhere.

My only issue with the ChooseColor option is that the basic colours are pretty useless. They don't provide a nice spectrum of options across a range of base colours (ROYGBIV) in the same way that the more modern Excel and Access IDE's do. In short, no users would select any of those base colours to be used for any kind of reporting purposes (they look horrible) whereas the "Theme" colours are more carefully defined.

Yes, you can use the palette to pick any colour you want - but common-or-garden users don't want to be fiddling with R's and G's and B's and hues and saturations. They want a quick pick, and are probably used to using the palettes from Excel anyway so want/like a similar set of options to choose from, for consistency as much as convenience.

I just thought it would be nice to provide them that via the wider selection of basic colours, rather than the more restricted (in terms of number) custom colours. And was hoping maybe those basic colours were "set" somewhere, maybe in the registry or something, that I could go in and "fix" the dialog to look more like Excel's options.

I also don't want them to be restricted to a standardised set of my choosing - I do want them to be able to pick any colour they want if they so choose. I'm just trying to provide a convenient set of "quick-picks" that aligns with the kinds of colour-pickers they're used to using in everyday Excel.

I'll just use the 16 custom colours instead and give them a light and dark shade of each of the ROYGBIV's plus black and white - if they want anything outside of that, they can use the palette. Just seems a shame that the basic colours can't be modified.

No biggie - was just curious - on my list of things to get done, this is about #427 in terms of priority!!

Thanks for the insight!
 
In short, no users would select any of those base colours to be used for any kind of reporting purposes (they look horrible) whereas the "Theme" colours are more carefully defined.
Well, that is me put in my place. :)
 
  • Like
Reactions: AOB
Well, that is me put in my place. :)
:ROFLMAO: Sorry @Gasman - that genuinely wasn't meant as a slur on anybody that uses those colours 😳

I should have phrased it more delicately... "None of my users would select any of those base colours as they are a finicky bunch who think that the Excel palette is more appropriate for their specific reporting purposes..."
 
As well as the color dialog that can be called using VBA - Show color dialog, there are several color dialogs including this from the property sheet:
1748341391022.png


I assume you don't like that (or the VBA version) due to the standard colors section.

But you can also use the more streamlined version from the context menu which only shows the theme colours

1748341362437.png


Does that meet your needs?
 
As well as the color dialog that can be called using VBA - Show color dialog, there are several color dialogs including this from the property sheet:
View attachment 119970

I assume you don't like that (or the VBA version) due to the standard colors section.

But you can also use the more streamlined version from the context menu which only shows the theme colours

View attachment 119969

Does that meet your needs?

Either of these would be absolutely perfect; the issue I have is how do I "produce" either of these pickers within my own interface (at run-time, not design time) such that a user could select a colour from it and my code would take the integer interpretation of it (be it RGB, Hex, whatever)

Is that even possible? I didn't think it was?
 
Although not identical, the custom color dialog created using VBA in my article allows you to select the color values using RGB or HSL

1748344600602.png


Or have a look at another of my articles:
 
I do not understand what the runtime requirement is. Do you want to change the palette at runtime.?

If you do not need to change the palette dynamically than you can build your own in a matter of minutes. Here is my demo. I just added enough colors for the demo. This whole demo took me 15 minutes.

MyColorPicker.png


Double click the box and pick a color. It passes the default in as well.

If you need to modify this palette at runtime then I would hold a table with fields

ColorName
TextBoxName
ColorValue

White White1 16777215

Now you fill the unbound form at runtime. That means you need a naming convention on the unbound textboxes put that name in the table.
 

Attachments

Last edited:
  • Like
Reactions: AOB
I do not understand what the runtime requirement is. Do you want to change the palette at runtime.?

If you do not need to change the palette dynamically than you can build your own in a matter of minutes. Here is my demo. I just added enough colors for the demo. This whole demo took me 15 minutes.

View attachment 119976

Double click the box and pick a color. It passes the default in as well.

If you need to modify this palette at runtime then I would hold a table with fields

ColorName
TextBoxName
ColorValue

White White1 16777215

Now you fill the unbound form at runtime. That means you need a naming convention on the unbound textboxes put that name in the table.

By "runtime" I just mean that I want some interface by which a user can specify a colour and pass that back to the code.

The dialogs mentioned by @isladogs in post #7 would be perfect - as they are consistent with the kind of colour pickers users would see in native Excel and so have an air of familiarity about them - but they are pickers that are available from the Design views - from the Properties tabs when formatting controls, or the context menus when formatting form areas - they aren't "callable" for some custom process in my own custom UI that allow a user to specify a colour...

Your sample looks like a superb middle ground though - let me play around with it - I suspect your 15 minutes may be a tad longer for myself :ROFLMAO:

Thanks for this, this is great!
 
I do not understand what the runtime requirement is. Do you want to change the palette at runtime.?

If you do not need to change the palette dynamically than you can build your own in a matter of minutes. Here is my demo. I just added enough colors for the demo. This whole demo took me 15 minutes.

View attachment 119976

Double click the box and pick a color. It passes the default in as well.

If you need to modify this palette at runtime then I would hold a table with fields

ColorName
TextBoxName
ColorValue

White White1 16777215

Now you fill the unbound form at runtime. That means you need a naming convention on the unbound textboxes put that name in the table.
Now I would have thought you would have made those color picker textboxes a class. :)
 
Here is a more updated version to mimic the color picker in Access, but give you the "more color" capability. So the More Colors opens the vba version and passes the value back to the custom form. The form in the middle just needs to be completed with the rest of the colors.

I did not code the recent colors, but that can be done using Tempvars. I think the trick to that is once you fill up the 10 recent colors you need to start overwriting them. So you need to track the next one to fill and cycle if going past 10 recent.

The other thing is you might want to standardize the look and functionality. The VBA picker has Ok Cancel and the Access closes when you pick a color. The vba then formats the border of the selected color. VBA has sunken colors access has flat.

Demo2.png
 

Attachments

Users who are viewing this thread

Back
Top Bottom