彩色复选框,组框等 [英] Colored Checkbox, Group box and etc
问题描述
我用这种方式着色静态标签:
case WM_CTLCOLORSTATIC:
{
DWORD CtrlID = GetDlgCtrlID((HWND)lParam); // Window Control ID
if(OptionColored)
{
HDC hdcStatic =(HDC)wParam;
SetTextColor(hdcStatic,RGB(255,255,255));
SetBkColor(hdcStatic,RGB(70,70,70));
return(INT_PTR)hBrush;
}
}
现在,如何复选复选框和分组框? / p>
编辑:
当我尝试使用这个代码来改变颜色,背景保护。
尝试播放这些邮件:
WM_CTLCOLORBTN
WM_CTLCOLOREDIT
WM_CTLCOLORDLG
WM_CTLCOLORLISTBOX
WM_CTLCOLORSCROLLBAR
WM_CTLCOLORSTATIC //您已经在使用
我知道您需要处理 WM_CTLCOLORBTN
确定哪一个是一个分组框。,它也应该作为继承自 CButton
在你的代码中也注意到你正在检查( OptionColored
),不知道是什么,但是你需要检查消息是否针对你想要的控件
因此,您不需要检查 if(OptionColored)
b
$ b
DWORD CtrlID = GetDlgCtrlID((HWND)lParam));
if(CtrlID == IDC_STATIC1)//如果需要控制
{
//颜色我的STATIC CONTROLE
}
I colored static lables with this way:
case WM_CTLCOLORSTATIC:
{
DWORD CtrlID = GetDlgCtrlID((HWND)lParam); //Window Control ID
if(OptionColored)
{
HDC hdcStatic = (HDC) wParam;
SetTextColor(hdcStatic, RGB(255,255,255));
SetBkColor(hdcStatic, RGB(70,70,70));
return (INT_PTR)hBrush;
}
}
Now, how can I color checkboxs and groupboxs ?
Edit: When I try with this code to change the color, background woring. text color not.
try playing with these messages:
WM_CTLCOLORBTN
WM_CTLCOLOREDIT
WM_CTLCOLORDLG
WM_CTLCOLORLISTBOX
WM_CTLCOLORSCROLLBAR
WM_CTLCOLORSTATIC //You are already using
I know that you need to handle WM_CTLCOLORBTN
to color check boxes but not sure which one is it for a groupbox. and it should also work for group boxes as those inherit from CButton
Also noticed in your code that you are checking for (OptionColored
), not sure what that is but you need to check if the message is targeted to your desired control to color.
so instead of checking if(OptionColored)
, you need something like:
DWORD CtrlID = GetDlgCtrlID((HWND)lParam));
if (CtrlID == IDC_STATIC1) //If desired control
{
//Color my STATIC CONTROLE
}
这篇关于彩色复选框,组框等的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!