Click here to Skip to main content
11,429,154 members (63,966 online)
Click here to Skip to main content

Cool Colour Selector Including Hue, Saturation, and Lumination

, 9 Nov 2006 MIT
Rate this:
Please Sign up or sign in to vote.
This colour selector helps to make selecting colours more efficient

Introduction

When I created this colour selector I was creating a 3D graphics program; I was using the standard windows common colour selection dialog box however it became a bit tedious selecting the "Define Custom Colours >>" button to select custom colours. So I designed this colour selector which I find much easier to use.

Using the code

All colour boxes can be dragged and dropped onto the custom colour boxes. Custom colour values are automatically restored each time the dialog box is displayed. The colours can all be dragged onto the "New Colour:" box to select that colour.

Clicking on the "Current Colour:" colour box will select the original colour again. However it is not possible (without modifications) to drag a colour on-top of the "Current Colour:" colour box as that would defeat the object of having it.

It is possible to change the colour reference, hue value, saturation value, lumination value, red value, green value, and the blue value.

I hope that this is of some use to you.

// declare a variable to store our color
COLORREF rgbColor = RGB(255, 0, 0);
 
// create an instance of the color selector
CSelColorDlg dlgSelColor(GetRValue(rgbColor), GetGValue(rgbColor),
                         GetBValue(rgbColor));
// display the color changing dialog box
if(dlgSelColor.DoModal() == IDOK)
{
      // select the new color
      rgbColor = dlgSelColor.GetColor();
      // change the background color
      Invalidate();
}

Points of Interest

Most of the visual appearance of the colour selector has relied on the use of GetBitmapBits() and SetBitmapBits() to save on processing time. When the colour images are generated the image is stored within a CBitmap object; then later to be drawn as usual.

History

  • Fixed major bug regarding desktop colour depths.

License

This article, along with any associated source code and files, is licensed under The MIT License

Share

About the Author

Lea Hayes
Software Developer Rotorz Limited
United Kingdom United Kingdom
I have been fascinated by software and video games since a young age when I was given my first computer, a Dragon 32. Since then I have experimented with numerous methods of development ranging from point-and-click type packages to C++. I soon realized that software development was what I wanted to do.

Having invested a lot of time into programming with various languages and technologies I now find it quite easy to pickup new ideas and methodologies. I relish learning new ideas and concepts.

Throughout my life I have dabbled in game and engine development. I was awarded a first for the degree "BEng Games and Entertainment Systems Software Engineering" at the University of Greenwich. It was good to finally experience video games from a more professional perspective.

Due to various family difficulties I was unable to immediately pursue any sort of software development career. This didn't stop me from dabbling though!

Since then I formed a company to focus upon client projects. Up until now the company has primarily dealt with website design and development. I have since decided that it would be fun to go back to my roots and develop games and tools that other developers can use for their games.

We have recently released our first game on iPhone/iPad called "Munchy Bunny!" (see: http://itunes.apple.com/us/app/munchy-bunny!/id516575993?mt=8). We hope to expand the game and release to additional platforms.

Also, check out our tile system extension for Unity! (see: http://rotorz.com/tilesystem/)
Follow on   Twitter   Google+

Comments and Discussions

 
QuestionHow can I implement this application using slider instead of spectrum. Pin
rajesh_kapure22-Nov-07 2:40
memberrajesh_kapure22-Nov-07 2:40 
QuestionSuggestion: Alpha values? Pin
Jerry Evans10-Nov-06 4:04
memberJerry Evans10-Nov-06 4:04 
GeneralGreat stuff - but some bugs. Pin
_gl8-Nov-06 15:39
member_gl8-Nov-06 15:39 
GeneralRe: Great stuff - but some bugs. Pin
lhayes009-Nov-06 10:18
memberlhayes009-Nov-06 10:18 
GeneralRe: Great stuff - but some bugs. Pin
_gl9-Nov-06 11:53
member_gl9-Nov-06 11:53 
GeneralRe: Great stuff - but some bugs. Pin
_gl10-Nov-06 4:52
member_gl10-Nov-06 4:52 
GeneralRe: Great stuff - but some bugs. Pin
Rick York13-Nov-06 13:17
memberRick York13-Nov-06 13:17 
GeneralI like it Pin
StrayJay9-May-06 4:10
memberStrayJay9-May-06 4:10 
QuestionHow to include in project Pin
craig.miller2-Sep-05 11:48
membercraig.miller2-Sep-05 11:48 
I'm trying to include this control in my project but I can't seem to get all of the resources imported properly. Is there a brief set of instructions somewhere on how to use the control in a project?

Thanks,
Craig
AnswerRe: How to include in project Pin
StrayJay9-May-06 4:02
memberStrayJay9-May-06 4:02 
GeneralRe: How to include in project Pin
lhayes009-May-06 4:21
memberlhayes009-May-06 4:21 
GeneralRe: How to include in project Pin
StrayJay9-May-06 4:40
memberStrayJay9-May-06 4:40 
GeneralWindowsCE Compatability Pin
mutpan21-Nov-04 8:18
membermutpan21-Nov-04 8:18 
Generalvb code Pin
david28078331-Oct-04 20:24
memberdavid28078331-Oct-04 20:24 
GeneralRe: vb code Pin
lhayes0031-Oct-04 21:32
memberlhayes0031-Oct-04 21:32 
GeneralExcellent Job Pin
kmaz12-Jul-04 18:01
memberkmaz12-Jul-04 18:01 
GeneralVery bad example Pin
ardell.yandex27-Jun-04 13:44
memberardell.yandex27-Jun-04 13:44 
GeneralRe: Very bad example Pin
lhayes0027-Jun-04 21:23
memberlhayes0027-Jun-04 21:23 
GeneralRe: Very bad example Pin
ardell.yandex27-Jun-04 23:39
memberardell.yandex27-Jun-04 23:39 
GeneralRe: Very bad example Pin
lhayes0028-Jun-04 7:54
memberlhayes0028-Jun-04 7:54 
Generalnice Pin
Livid21-May-04 15:16
memberLivid21-May-04 15:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.150428.2 | Last Updated 9 Nov 2006
Article Copyright 2004 by Lea Hayes
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid