问题描述
大家好,
如何使用onctlcolor()帮助更改按钮颜色。
我将开发不起作用的代码可以给出建议
CBrush m_brush; //dlg.h
m_brush.createsolidbrush(RGB(255,0,0)); // dlg.cpp(oninitdialog())
CTestClass:OnCtlColor(CDC pDC,CWD pWnd,UINT nctlcolor)
{
HBRUSH hbr = CDialogEx :: OnCtlColor(pDC,pWnd,nCtlColor);
开关(nCtlColor)
{
案例IDC_BUTTON1:pDC-> setBkColor((RGB(255,0,0));
hbr = m_brush;
}
返回m_brush;
}
Hi everyone,
how to change the button color with help onctlcolor().
I will develop code it is not working could pls give suggestion
CBrush m_brush; //dlg.h
m_brush.createsolidbrush(RGB(255,0,0));//dlg.cpp(oninitdialog())
CTestClass:OnCtlColor(CDC pDC,CWD pWnd,UINT nctlcolor)
{
HBRUSH hbr = CDialogEx::OnCtlColor(pDC, pWnd, nCtlColor);
switch(nCtlColor)
{
case IDC_BUTTON1: pDC->setBkColor((RGB(255,0,0));
hbr = m_brush;
}
return m_brush;
}
这篇关于如何使用onctlcolor()帮助更改按钮颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!