Click here to Skip to main content
12,622,652 members (27,752 online)
Click here to Skip to main content
Add your own
alternative version

Stats

97.1K views
3.5K downloads
40 bookmarked
Posted

xgui - a set of Photoshop-like color picker controls

, 2 Apr 2002
Rate this:
Please Sign up or sign in to vote.
xgui is a user-controls library, including several user-interface controls inspired by the great Adobe Photoshop
xgui demo project screenshot

In this page:

  1. What is xgui?
  2. How to use it

What is xgui? 

xgui is a user-controls library, including several user-interface controls: color picker, slider, color preview well and controller, inspired by the great Adobe Photoshop.

Currently RGB and HSV color models are supported.

How to use it 

Include wrapper headers 

xgui library is accessed by using so-called wrappers. Wrappers are headers defining 4 classes with all members inline functions. Following steps describe the simpliest case - drive a picker, slider and a well by using a controller.

Initialize xgui library 

Load and initialize library (in InitInstance, for example):

HINSTANCE handle = LoadLibrary ("xgui.dll");
if (handle == NULL)
{
	AfxMessageBox ("Cannot load library.");
	return (FALSE);
}
FARPROC func = GetProcAddress (handle, "xgui_initialize");
if (func == NULL)
{
	AfxMessageBox ("Cannot find function.");
	return (FALSE);
}
func ();

Add controls to a dialog box 

Add a user-controls to a dialog box template in resource editor. Set window class (xgui_controller, xgui_picker, xgui_slider or xgui_well). Select additional options (as style lo-word) for slider and picker:

Resource editor screenshot

For the slider control, 0x7280 means vetical slider with both triangles, where each triangle is having size = 6 (2 + 4 = 6), running at visual mode 0x80 (consult "xgui_constants.h" for available visual modes or "slider.h" about the following schema):

 +- horizontal slider (8)
 |  +- verical slider (4)
 |  |  +- left / top triangle (2)
 |  |  |  +- right / bottom triangle (1)
 |  |  |  |  +--------+- triangle(s) size - 4 (0 = actual size of 4)
 |  |  |  |  |        |  +--------------------+- visual mode (modes enum)
 |  |  |  |  |        |  |                    |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|16|15|14|13|12|11|10| 9| 8| 7| 6| 5| 4| 3| 2| 1|
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
 |                    |
 +--------------------+- layout mode

Picker uses only bits 9-12 for the same purpose as slider control.

Uncheck visible and tabstop for controllers and tabstop only for color wells.

Declare member variable 

In your dialog box class header append a single member variable for the controller:

xgui::wrapper::controller	master;

Set-up variable 

Use class wizard to add a handler for WM_INITDIALOG and setup class instance inside:

master.attach (
	GetDlgItem (IDC_CONTROLLER)->m_hWnd);
master.setup_as_picker (
	GetDlgItem (IDC_WELL)->m_hWnd,
	GetDlgItem (IDC_PICKER)->m_hWnd,
	GetDlgItem (IDC_SLIDER)->m_hWnd);
master.visual (
	xgui::modes::rgb_red | xgui::modes::reverse);

Query controller for the current selection 

Use color method of the controller wrapper to get or to set the current color.

Compile and execute 

That's all. Compile and execute the project.

Check-out demo project source code for advanced usage.

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

Share

About the Author

Bobi B.
Web Developer
Bulgaria Bulgaria
No Biography provided

You may also be interested in...

Pro
Pro

Comments and Discussions

 
QuestionVb.Net Pin
tamilpuyal_2810-Oct-11 0:55
membertamilpuyal_2810-Oct-11 0:55 
GeneralImpressive Pin
rakeshk_37118-Nov-04 0:58
memberrakeshk_37118-Nov-04 0:58 
GeneralChanges to make it run on Win98 Pin
juwe25-Mar-04 22:24
sussjuwe25-Mar-04 22:24 
GeneralStrange crash...solved Pin
Andreas Muegge16-Sep-02 7:02
memberAndreas Muegge16-Sep-02 7:02 
GeneralAnouncement: 0.0.4 released Pin
Bobi B.7-Aug-02 11:23
memberBobi B.7-Aug-02 11:23 
GeneralNice Pin
dswigger17-Jun-02 6:01
memberdswigger17-Jun-02 6:01 
GeneralNot bad, not bad at all. Some suggestions. Pin
Maxzz7-Apr-02 21:57
memberMaxzz7-Apr-02 21:57 
GeneralYou should see the RGB Cube Pin
KlausCH3-Apr-02 22:49
memberKlausCH3-Apr-02 22:49 
GeneralSuggestion Pin
Christian Graus3-Apr-02 12:12
memberChristian Graus3-Apr-02 12:12 
GeneralRe: Suggestion Pin
Adi Shavit3-Apr-02 23:37
memberAdi Shavit3-Apr-02 23:37 
GeneralRe: Suggestion Pin
Christian Graus3-Apr-02 23:39
memberChristian Graus3-Apr-02 23:39 
GeneralRe: Suggestion Pin
Bobi B.4-Apr-02 2:40
memberBobi B.4-Apr-02 2:40 
GeneralPretty.... Pin
Jim Crafton3-Apr-02 6:49
memberJim Crafton3-Apr-02 6:49 

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.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.161128.1 | Last Updated 3 Apr 2002
Article Copyright 2002 by Bobi B.
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid