Slider to change the dialog box color

Source: Internet
Author: User
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.
}
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.