我想把画背景色操作加在里面。
16 个解决方案
#1
WM_CTLCORLOR
#2
响应控件所在对话框的:WM_CTLCORLOR
#3
http://sanjianxia.myrice.com/vc/vc37.htm
#4
响应事件:WM_CTLCORLOR ,函数参数有指向控件ID的!然后再得到控件的CWnd画背景!
#5
HBRUSH CAlarmDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
switch( nCtlColor )
{
case CTLCOLOR_EDIT:
pDC->SetBkColor( RGB(240,240,230) ); // yellow
return m_hEditBrush;
break;
default:
pDC->SetBkColor( RGB(BKRED,BKGREEN,BKBLUE) ); // red
return m_hOtherBrush;
}
return CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
}
HBRUSH m_hOtherBrush;
m_hOtherBrush = CreateSolidBrush( RGB(BKRED,BKGREEN,BKBLUE) );
#6
同意 :new_stranger
case CTLCOLOR_EDIT:
pDC->SetBkColor( RGB(240,240,230) );
HBRUSH m_hEditBrush = CreateSolidBrush( RGB(BKRED,BKGREEN,BKBLUE) );
return m_hEditBrush;
case CTLCOLOR_EDIT:
pDC->SetBkColor( RGB(240,240,230) );
HBRUSH m_hEditBrush = CreateSolidBrush( RGB(BKRED,BKGREEN,BKBLUE) );
return m_hEditBrush;
#7
HBRUSH m_hEditBrush = CreateSolidBrush( RGB(BKRED,BKGREEN,BKBLUE) );
return m_hEditBrush;
啊呀,返回了一个局部对象的指针。
在设置颜色时为什么有一些颜色设置无效??
如:
pDC->SetBkColor( RGB(14,14,255) ); //???
return m_hEditBrush;
啊呀,返回了一个局部对象的指针。
在设置颜色时为什么有一些颜色设置无效??
如:
pDC->SetBkColor( RGB(14,14,255) ); //???
#8
这里起作用的是一些常用的256索引值,你去看看MSDN的说明,或者是Windows的帮助
#9
那怎样才能使用 pDC->SetBkColor( RGB(14,14,255) ); 哪。
#10
对EDIT控件来说,只有返回刷子有效,SetBkColor这个函数不是给它用的,是给别的控件用的。如CRichEdit
#11
RGB(14,14,255)
刷子这个颜色好像也不行啊。
刷子这个颜色好像也不行啊。
#12
pDC->SetBkMode(TRANSPARENT);// you cannt edit it anymore
pDC->SetTextColor(RGB(255,0,0));
return (HBRUSH)brush.GetSafeHandle();
pDC->SetTextColor(RGB(255,0,0));
return (HBRUSH)brush.GetSafeHandle();
#13
MSDN
#14
子类化,响应wm_paint消息
#15
new_stranger(陌生人)的对
#16
derive a CEdit class namely CEditEx:
in its header file:
///////////////////////////////////
CBrush brHot;
CBrush br;
afx_msg HBRUSH CtlColor(CDC* pDC, UINT nCtlColor);
///////////////////////////////////
in its implentation file:
//////////////////////////////
CEditEx::CEditEx()
{
brHot.CreateSolidBrush(RGB(255,255,255));
br.CreateSolidBrush(RGB(221,221,221));
}
BEGIN_MESSAGE_MAP(CEditEx, CEdit)
//{{AFX_MSG_MAP(CEditEx)
ON_WM_CTLCOLOR_REFLECT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
HBRUSH CEditEx::CtlColor(CDC* pDC, UINT nCtlColor)
{
//if(m_bMouseOver)
{
pDC->SetBkColor(RGB(255,255,255));
return brHot;
}
//else
//{
// pDC->SetBkColor(RGB(221,221,221));
// return br;
//}
}
//////////////////////////////
I have published a mouse sensitive CEdit class on wwww.codeproject.com
If you still have some interest,go and check it:
"a focus-sensitive CEdit class"
by DavidRipple
in its header file:
///////////////////////////////////
CBrush brHot;
CBrush br;
afx_msg HBRUSH CtlColor(CDC* pDC, UINT nCtlColor);
///////////////////////////////////
in its implentation file:
//////////////////////////////
CEditEx::CEditEx()
{
brHot.CreateSolidBrush(RGB(255,255,255));
br.CreateSolidBrush(RGB(221,221,221));
}
BEGIN_MESSAGE_MAP(CEditEx, CEdit)
//{{AFX_MSG_MAP(CEditEx)
ON_WM_CTLCOLOR_REFLECT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
HBRUSH CEditEx::CtlColor(CDC* pDC, UINT nCtlColor)
{
//if(m_bMouseOver)
{
pDC->SetBkColor(RGB(255,255,255));
return brHot;
}
//else
//{
// pDC->SetBkColor(RGB(221,221,221));
// return br;
//}
}
//////////////////////////////
I have published a mouse sensitive CEdit class on wwww.codeproject.com
If you still have some interest,go and check it:
"a focus-sensitive CEdit class"
by DavidRipple
#1
WM_CTLCORLOR
#2
响应控件所在对话框的:WM_CTLCORLOR
#3
http://sanjianxia.myrice.com/vc/vc37.htm
#4
响应事件:WM_CTLCORLOR ,函数参数有指向控件ID的!然后再得到控件的CWnd画背景!
#5
HBRUSH CAlarmDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
switch( nCtlColor )
{
case CTLCOLOR_EDIT:
pDC->SetBkColor( RGB(240,240,230) ); // yellow
return m_hEditBrush;
break;
default:
pDC->SetBkColor( RGB(BKRED,BKGREEN,BKBLUE) ); // red
return m_hOtherBrush;
}
return CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
}
HBRUSH m_hOtherBrush;
m_hOtherBrush = CreateSolidBrush( RGB(BKRED,BKGREEN,BKBLUE) );
#6
同意 :new_stranger
case CTLCOLOR_EDIT:
pDC->SetBkColor( RGB(240,240,230) );
HBRUSH m_hEditBrush = CreateSolidBrush( RGB(BKRED,BKGREEN,BKBLUE) );
return m_hEditBrush;
case CTLCOLOR_EDIT:
pDC->SetBkColor( RGB(240,240,230) );
HBRUSH m_hEditBrush = CreateSolidBrush( RGB(BKRED,BKGREEN,BKBLUE) );
return m_hEditBrush;
#7
HBRUSH m_hEditBrush = CreateSolidBrush( RGB(BKRED,BKGREEN,BKBLUE) );
return m_hEditBrush;
啊呀,返回了一个局部对象的指针。
在设置颜色时为什么有一些颜色设置无效??
如:
pDC->SetBkColor( RGB(14,14,255) ); //???
return m_hEditBrush;
啊呀,返回了一个局部对象的指针。
在设置颜色时为什么有一些颜色设置无效??
如:
pDC->SetBkColor( RGB(14,14,255) ); //???
#8
这里起作用的是一些常用的256索引值,你去看看MSDN的说明,或者是Windows的帮助
#9
那怎样才能使用 pDC->SetBkColor( RGB(14,14,255) ); 哪。
#10
对EDIT控件来说,只有返回刷子有效,SetBkColor这个函数不是给它用的,是给别的控件用的。如CRichEdit
#11
RGB(14,14,255)
刷子这个颜色好像也不行啊。
刷子这个颜色好像也不行啊。
#12
pDC->SetBkMode(TRANSPARENT);// you cannt edit it anymore
pDC->SetTextColor(RGB(255,0,0));
return (HBRUSH)brush.GetSafeHandle();
pDC->SetTextColor(RGB(255,0,0));
return (HBRUSH)brush.GetSafeHandle();
#13
MSDN
#14
子类化,响应wm_paint消息
#15
new_stranger(陌生人)的对
#16
derive a CEdit class namely CEditEx:
in its header file:
///////////////////////////////////
CBrush brHot;
CBrush br;
afx_msg HBRUSH CtlColor(CDC* pDC, UINT nCtlColor);
///////////////////////////////////
in its implentation file:
//////////////////////////////
CEditEx::CEditEx()
{
brHot.CreateSolidBrush(RGB(255,255,255));
br.CreateSolidBrush(RGB(221,221,221));
}
BEGIN_MESSAGE_MAP(CEditEx, CEdit)
//{{AFX_MSG_MAP(CEditEx)
ON_WM_CTLCOLOR_REFLECT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
HBRUSH CEditEx::CtlColor(CDC* pDC, UINT nCtlColor)
{
//if(m_bMouseOver)
{
pDC->SetBkColor(RGB(255,255,255));
return brHot;
}
//else
//{
// pDC->SetBkColor(RGB(221,221,221));
// return br;
//}
}
//////////////////////////////
I have published a mouse sensitive CEdit class on wwww.codeproject.com
If you still have some interest,go and check it:
"a focus-sensitive CEdit class"
by DavidRipple
in its header file:
///////////////////////////////////
CBrush brHot;
CBrush br;
afx_msg HBRUSH CtlColor(CDC* pDC, UINT nCtlColor);
///////////////////////////////////
in its implentation file:
//////////////////////////////
CEditEx::CEditEx()
{
brHot.CreateSolidBrush(RGB(255,255,255));
br.CreateSolidBrush(RGB(221,221,221));
}
BEGIN_MESSAGE_MAP(CEditEx, CEdit)
//{{AFX_MSG_MAP(CEditEx)
ON_WM_CTLCOLOR_REFLECT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
HBRUSH CEditEx::CtlColor(CDC* pDC, UINT nCtlColor)
{
//if(m_bMouseOver)
{
pDC->SetBkColor(RGB(255,255,255));
return brHot;
}
//else
//{
// pDC->SetBkColor(RGB(221,221,221));
// return br;
//}
}
//////////////////////////////
I have published a mouse sensitive CEdit class on wwww.codeproject.com
If you still have some interest,go and check it:
"a focus-sensitive CEdit class"
by DavidRipple