MFC message OnCtlColor Change control color

Source: Internet
Author: User

OnCtlColor has the following macro definitions

#define Ctlcolor_msgbox 0
#define CTLCOLOR_EDIT 1
#define Ctlcolor_listbox 2//Edit drop-down list color
#define CTLCOLOR_BTN 3//Edit button color
#define CTLCOLOR_DLG 4//Edit dialog box color
#define CTLCOLOR_SCROLLBAR 5//scroll bar
#define Ctlcolor_static 6//Edit static text color
#define CTLCOLOR_MAX 7

When used:

Hbrush Cctlcolordlg::onctlcolor (cdc* PDC, cwnd* pWnd, UINT nCtlColor)
{
Hbrush HBR = Cdialogex::onctlcolor (PDC, PWnd, nCtlColor);

TODO: Change any of the properties of the DC here

/*

if (This==pwnd->getdlgctrlid ())

{}//This should also be possible

*/
if (nCtlColor = = Ctlcolor_dlg)
{
Static CBrush BR (RGB (255, 100, 0)); Declaring static increases the life cycle
return BR; Default return Hbrush
}
if (nctlcolor==ctlcolor_static)
{
Pdc->setbkmode (TRANSPARENT); Setting the font color can also call SetTextColor ();
Static CBrush BR (RGB (255, 100, 0));
return BR;
}

TODO: If the default is not the desired brush, another brush is returned
return HBR;
}

MFC message OnCtlColor Change control color

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.