Click here to Skip to main content
Licence 
First Posted 3 Mar 2004
Views 61,206
Bookmarked 28 times

Cool Colour Selector Including Hue, Saturation, and Lumination

By | 9 Nov 2006 | Article
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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Lea Hayes

Software Developer
Rotorz Limited
United Kingdom United Kingdom

Member

Follow on Twitter Follow on Twitter
Google+
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://www.rotorz.com/tile-system)

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
QuestionHow can I implement this application using slider instead of spectrum. Pinmemberrajesh_kapure1:40 22 Nov '07  
QuestionSuggestion: Alpha values? PinmemberJerry Evans3:04 10 Nov '06  
GeneralGreat stuff - but some bugs. Pinmember_gl14:39 8 Nov '06  
GeneralRe: Great stuff - but some bugs. Pinmemberlhayes009:18 9 Nov '06  
GeneralRe: Great stuff - but some bugs. Pinmember_gl10:53 9 Nov '06  
GeneralRe: Great stuff - but some bugs. Pinmember_gl3:52 10 Nov '06  
GeneralRe: Great stuff - but some bugs. PinmemberRick York12:17 13 Nov '06  
GeneralI like it PinmemberStrayJay3:10 9 May '06  
QuestionHow to include in project Pinmembercraig.miller10:48 2 Sep '05  
AnswerRe: How to include in project PinmemberStrayJay3:02 9 May '06  
GeneralRe: How to include in project Pinmemberlhayes003:21 9 May '06  
GeneralRe: How to include in project PinmemberStrayJay3:40 9 May '06  
GeneralWindowsCE Compatability Pinmembermutpan7:18 21 Nov '04  
Generalvb code Pinmemberdavid28078319:24 31 Oct '04  
GeneralRe: vb code Pinmemberlhayes0020:32 31 Oct '04  
GeneralExcellent Job Pinmemberkmaz17:01 12 Jul '04  
GeneralVery bad example Pinmemberardell.yandex12:44 27 Jun '04  
GeneralRe: Very bad example Pinmemberlhayes0020:23 27 Jun '04  
GeneralRe: Very bad example Pinmemberardell.yandex22:39 27 Jun '04  
GeneralRe: Very bad example Pinmemberlhayes006:54 28 Jun '04  
Generalnice PinmemberLivid14:16 21 May '04  

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.

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