Colorref m_clrbkgndcolor;
Cbrush * m_pbkbrush;
Csliderctrl * p_sliderred;
Csliderctrl * p_slidergreen;
Csliderctrl * p_sliderblue;
Bool ccolordlg: onerasebkgnd (CDC * PDC)
{
// Todo: add the message processing program code and/or call the default value here
If (m_pbkbrush)
{
Crect CR;
Getclientrect (CR );
PDC-> fillrect (& Cr, m_pbkbrush );
Return true;
}
Return cdialogex: onerasebkgnd (PDC );
}
Void ccolordlg: setbackgroundcolor (colorref color, bool brepaint)
{
M_clrbkgndcolor = color;
If (m_pbkbrush)
{
Delete m_pbkbrush;
}
M_pbkbrush = new cbrush (m_clrbkgndcolor );
If (brepaint)
{
Invalidate ();
}
}
Void ccolordlg: onhscroll (uint nsbcode, uint NPOs, cscrollbar * pscrollbar)
{
// Todo: add the message processing program code and/or call the default value here
Updatedata ();
Int Red = p_sliderred-> getpos ();
Int Green = p_slidergreen-> getpos ();
Int Blue = p_sliderblue-> getpos ();
Setbackgroundcolor (RGB (red, green, blue), true );
Cdialogex: onhscroll (nsbcode, NPOs, pscrollbar );
}
Initialization:
Bool ccolordlg: oninitdialog ()
{
........
// Todo: add additional initialization code here
M_pbkbrush = NULL;
P_sliderred = (csliderctrl *) getdlgitem (idc_slider1 );
P_sliderred-> setrange (0,255 );
P_slidergreen = (csliderctrl *) getdlgitem (idc_slider2 );
P_slidergreen-> setrange (0,255 );
P_sliderblue = (csliderctrl *) getdlgitem (idc_slider3 );
P_sliderblue-> setrange (0,255 );
Return true; // return true unless focus is set to the control.
}