Click here to Skip to main content
13,351,225 members (49,129 online)
Click here to Skip to main content
Add your own
alternative version


35 bookmarked
Posted 25 Mar 2002

Screen Color Picker

, 25 Mar 2002
Rate this:
Please Sign up or sign in to vote.
A simple application that retrieves the color codes from any area of your screen, with some cool options.

Sample Image


Color Picker is a simple application that retrieves the color codes from any area of your desktop (including any running applications). The program can copy that code - by pressing the SPACE key - to clipboard either in Hex (0x...) or in HTML compatible color code (#...). The color is shown even if the program has lost focus, but you can't copy the value to clipboard. You can choose if you want the application's window to be modal (stay on top) or not.

Initially I make the window modal. In OnInitDialog :

I use a timer to refresh the color code of the current pixel pointed by the mouse pointer.


To retrieve the color code of any pixel on the screen we must get the device context of the entire screen. We can make that with:

hDC = CreateDC("DISPLAY",0,0,0);
The CreateDC function creates a device context (DC) for a device by using it's name. After we take the handle to the device context of the entire display, we can get the position of the cursor.
CPoint point;
And finally we can get the color code of that point!
color = GetPixel(hDC,point.x,point.y);
After that we can release the device context: 

This application is useful for web designers and programmers, too. I needed this application for designing the colors of my controls.


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

Florin Vasilescu
Web Developer
Romania Romania
No Biography provided

You may also be interested in...

Comments and Discussions

GeneralMy vote of 5 Pin
Pravinda Amarathunge30-Mar-13 5:15
memberPravinda Amarathunge30-Mar-13 5:15 
Generaldesktop Pin
asadullah khan1-Aug-10 7:54
memberasadullah khan1-Aug-10 7:54 
QuestionGet Tray clock text color Pin
Motiram P Patil5-Apr-10 3:17
memberMotiram P Patil5-Apr-10 3:17 
QuestionWhat does one use (code) to "show" the color that the pointer is over? Pin
Richard Perrine8-Jan-09 3:47
memberRichard Perrine8-Jan-09 3:47 
GeneralGreat program Pin
Jose M. Menendez Poó4-May-08 12:15
memberJose M. Menendez Poó4-May-08 12:15 
Generalnice! Pin
Razvan Marcus4-Apr-06 0:24
memberRazvan Marcus4-Apr-06 0:24 
GeneralFYI Pin
Jeremy Falcon27-Mar-02 4:54
memberJeremy Falcon27-Mar-02 4:54 
I've had a utility posted on CP for about two years that does this already. Actually, I'm about to update it with a version 2.0, which IMHO is even way better than 1.x. Smile | :) I can't give details yet because it's classified and I'd have to submit my internals to bo-bo (a little pink bunny).

Check it out...

Jeremy L. Falcon
"The One Who Said, 'The One Who Said...'"
Generaland Pin
gok29-Apr-02 11:21
membergok29-Apr-02 11:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    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 | Terms of Use | Mobile
Web01 | 2.8.180111.1 | Last Updated 26 Mar 2002
Article Copyright 2002 by Florin Vasilescu
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid