Great and amazing work!
ReplyOriginally posted by: Eugene Kim
I tried , and using Create function of CButton.
It looks like to work , but always in disabled mode.
I have no idea how to change or, I think in creation period, something needed or some option to include ..
Anyway, color Picker does not work . plz. help me.
Code.. Like this. !!!
m_ColorText.Create(_T(""), WS_CHILD|WS_VISIBLE, Colorrect, this, ID_FONT_COLOR);
ReplyOriginally posted by: arnold
complie error is "cannot open file "mfc42u.lib""
ReplyOriginally posted by: new user
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.
ReplyOriginally posted by: Dave Steckler
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.
...Dave
=================================
void AFXAPI DDX_ColourPicker(CDataExchange *pDX, int nIDC, CColourPicker& Picker, COLORREF& crColour)
HWND hWndCtrl = pDX->PrepareCtrl(nIDC);
if (!Picker.SubclassWindow(hWndCtrl))
}
if (pDX->m_bSaveAndValidate)
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:
{
if (Picker.m_hWnd == NULL) // not subclassed yet
{
ASSERT(!pDX->m_bSaveAndValidate);
{
ASSERT(FALSE); // possibly trying to subclass twice?
AfxThrowNotSupportedException();
}
#ifndef _AFX_NO_OCC_SUPPORT
else
{
// 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))
Picker.AttachControlSite(pDX->m_pDlgWnd);
}
#endif //!_AFX_NO_OCC_SUPPORT
{
crColour = Picker.GetColour();
}
else // initializing
{
Picker.SetColour(crColour);
}
}
Originally posted by: James Southard Jr
CBrush brush( ((state & ODS_DISABLED) || m_crColourBk == CLR_DEFAULT)?
Sets the background of the control to either the button
If so, when I select the "Default color" the background of
One remedy to this would be:
CBrush brush( m_crColourBk = ((state & ODS_DISABLED) || m_crColourBk == CLR_DEFAULT)?
This ensures that the background color is reflected in the
Please correct me if I'm wrong.
Thanks.
In CColourPicker::DrawItem()
::GetSysColor(COLOR_3DFACE) : m_crColourBk);
face default or the selected background color, correct?
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?
::GetSysColor(COLOR_3DFACE) : m_crColourBk);
control's background color.
Originally posted by: Xuelong Zhou
LONG CColourPicker::OnSelEndOK(UINT lParam, LONG /*wParam*/)
CWnd *pParent = GetParent();
if (bIsColourDiff)
return TRUE;
Very nice. Thanks.
A minor bug in OnSetEndOK() when notify parent window for CPN_SELCHANGE, SetColour() is called too soon.
{
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;
SetColour(crNewColour);
if (pParent) {
pParent->SendMessage(CPN_CLOSEUP, lParam, (WPARAM) GetDlgCtrlID());
pParent->SendMessage(CPN_SELENDOK, lParam, (WPARAM) GetDlgCtrlID());
}
if (pParent) pParent->SendMessage(CPN_SELCHANGE, lParam, (WPARAM) GetDlgCtrlID());
}
Originally posted by: rick shide
void CColourPopup::EndSelection(int nMessage)
This popup is getting destroyed when loosing focus, but is
try this:
{
if (!GetSafeHwnd())
return;
...
still getting and responding to mouse button messages, in
particular WM_LBUTTONUP that's generated when releasing the
mouse after picking another application.
Originally posted by: Niki Estner
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.)
void CColourPopup::OnKillFocus(CWnd* pNewWnd)
{
CWnd::OnKillFocus(pNewWnd);
ReleaseCapture();
//DestroyWindow();
}
Reply
Originally posted by: Johnny
void CColourPopup::OnNcDestroy()
{
CWnd::OnNcDestroy();
delete this; // causes crash when Custom colour dialog appears.
}