If you click on ColorPicker, it doesn't show the the selected color of ColorPicker. Instead it just displays all colors unselected. When MORE COLORS is clicked, it does not show color of ColorPicker, instead it selects black color each time.
I think this control will be more desirable when it correctly identifies the color of ColorPicker.
I'm not an expert on the whole world of DDX and such...but I think there's a major bug in the DDX_ColourPicker function. In particular, you can't do something like:
CColourPicker* p = (CColourPicker*)CWnd::FromHandle(hwnd);
and then do something which actually mucks with a data member of this object (mainly because CWnd::FromHandle just generates a temporary CWnd object, not a CColourPicker object).
Er....right? (as I said, I'm not an expert in this stuff...)
So I changed DDX_ColorPicker as follows (basically copied code out of DDX_Control, and then set/get the appropriate value.
Again, sorry if I'm way off base here. Please let me know if there's a better way to do this.
void AFXAPI DDX_ColourPicker(CDataExchange *pDX, int nIDC, CColourPicker& Picker, COLORREF& crColour)
if (Picker.m_hWnd == NULL) // not subclassed yet
HWND hWndCtrl = pDX->PrepareCtrl(nIDC);
ASSERT(FALSE); // possibly trying to subclass twice?
// If the control has reparented itself (e.g., invisible control),
// make sure that the CWnd gets properly wired to its control site.
if (pDX->m_pDlgWnd->m_hWnd != ::GetParent(Picker.m_hWnd))
Sets the background of the control to either the button
face default or the selected background color, correct?
If so, when I select the "Default color" the background of
the control is set to the default, while the color stored
in m_crColourBk is changed to black. Is this supposed to be
the way it behaves, or should the background of the control
always reflect the current background color?
Very nice. Thanks.
A minor bug in OnSetEndOK() when notify parent window for CPN_SELCHANGE, SetColour() is called too soon.
LONG CColourPicker::OnSelEndOK(UINT lParam, LONG /*wParam*/)
COLORREF crNewColour = (COLORREF) lParam;
// save the flag first ifthe colour is different
// use it when SendMessage(CPN_SELCHANGE,...)
BOOL bIsColourDiff=(crNewColour != GetColour());
m_bActive = FALSE;
void CColourPopup::EndSelection(int nMessage)
This popup is getting destroyed when loosing focus, but is
still getting and responding to mouse button messages, in
particular WM_LBUTTONUP that's generated when releasing the
mouse after picking another application.
The control is neat, but it always crashed on my machine (NT4, SP4, IE5, VC6) when I chose the "more colors" item.
I killed the "DestroyWindow" in OnKillFocus, and it ran fine, yet I guess it must have had some sense...
(The popup will stay open as long as the ColorDialog is open, but it will close immediately after the ColorDialog is closed.)