Introduction
Bobi B has written a very cool Photoshop-like color picker (you can
click here
to see how cool it is), but since this is compiled into a DLL, it
is very hard to use with existing MFC projects. I decided therefore to create a simple class to mimic CGTColorDialogDlg
- but this time based on CDialog
.
How to use it:
Very easy! Simply add the following code in the header file of the class where you want to display the Color Picker Dialog:
#include "GTColorDialogDlg.h"
And in the .cpp file:
CGTColorDialogDlg dlg
dlg.SetColor(RGB(0,0,255));
int nResponse = dlg.DoModal()
if (nResponse == IDOK)
{
COLORREF crReturn = dlg.GetColor();
}
Technical Details
The Color Picker Dialog is constructed using the following classes:
- GTColorWellWnd - (GTColorWellWnd.h, GTColorWellWnd.cpp)
- GTColorSliderWnd - (GTColorSliderWnd.h,GTColorSliderWnd.cpp)
- GTColorSelectorWnd - (GTColorSelectorWnd.h,GTColorSelectorWnd.cpp)
- CGTColorDialogDlg - (CGTColorDialogDlg.h,CGTColorDialogDlg.cpp
The class inheritance diagrams are as follows: