Originally posted by: Vince Buttigieg
It's people like you that make this site as great as it is.
When I decided I needed a colour picker, I was about to attempt my own, when I though - "let's try code guru"... and needless to say, your code is superior to what I could have developed.
You may have submitted it quite a while ago, but never the less, here's another "THANKYOU!" ;-)
ReplyOriginally posted by: Jon
#include "colorbtn.rc"
to my exising .rc, it says
Undefined keyword or keyname : DS_MODALFRAME
I'm trying to insert it (programmatically) into an ActiveX control - could this be the cause? I'd be most gratefull if someone could provide an answer...
Jon
I've followed your instructions but when I add the
Originally posted by: Etienne Lefrancois
Exactly what I'm looking for !!!!
ReplyOriginally posted by: anonymous
Assertion failure occures at
colorbtn.SubclassDlgItem(IDC_BUTTON,this);
But it works fine with release mode.
I use visual c++ 6.0.
Anyway thanks for releasing source code.
It doesn't work with debug mode.
Reply
Originally posted by: Ernest L.
BEGIN_MESSAGE_MAP(CColorBtn, CButton)
if (dlg.DoModal() == IDOK)
Thanks,
I suggest to add in the message map the following lines
if you want to handle [CLICK] event on a Property Page.
Set the "Notify" with the "Owner draw", then replace the
OnClicked handler function.
Note that OnClicked handler prototypes has changed. This is a sample solution to be able to detect if color has changed.
//{{AFX_MSG_MAP(CColorBtn)
ON_CONTROL_REFLECT_EX(BN_CLICKED, OnClicked)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
BOOL CColorBtn::OnClicked(NMHDR * pNotifyStruct, LRESULT* result )
{
// When the button is clicked, show the dialog.
{
currentcolor = CColorBtnDlg::colors[dlg.colorindex];
InvalidateRect(NULL);
}
*result = 0;
return FALSE;
}
Reply
Originally posted by: RRLogin
Under certain conditions, the code will GPF under release builds when the color picker dialog is closed. It appears that the OnDrawItem is getting called after the dialog is closed; there is at least a WM_PAINT message that is in the middle of the GPF that makes me think so.
Reply
Originally posted by: Evert de Bruin
You just saved my life!
ReplyOriginally posted by: Don Carlson
This saved me a lot of time. The only thing I have added was the following:
Add a public variable to the class CColorBtnDlg:
COLORREF previousColor;
Give previousColor a default color value in the constructor.
Then in void CColorBtnDlg::OnOther(), when declaring the CColorDialog dlg, declare it with the previousColor:
CColorDialog dlg(previousColor);
Finally, in void CColorBtn::OnClicked(), prior to calling the dlg.DoModal(), set the previousColor as follows:
dlg.previousColor = currentcolor;
This way, if the "Other..." button is selected, the common color dialog will start off at the current color selection. This helps when selecting a new color or making a color tweak.
Don ...
Originally posted by: Lutz Roeder
this control is exactly that what im looking for!
lutz
Originally posted by: Patty You
I found that your control is very easy to use, it saved me time to reinvent the wheel. Thank you for putting your cool code here to share. Keep up with the great work!
Reply