在文框视图框架中,视图上的static控件的透明和CDialog类有所不同。代码如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
HBRUSH
CMainView::OnCtlColor(CDC* pDC, CWnd* pWnd,
UINT
nCtlColor)
{
HBRUSH
hbr = CFormView::OnCtlColor(pDC, pWnd, nCtlColor);
if
(CTLCOLOR_STATIC == nCtlColor)
//这一行不同
{
pDC->SetBkMode(TRANSPARENT);
return
(
HBRUSH
)::GetStockObject(NULL_BRUSH);
}
//CString str;
//str.Format(_T("%d\n"),pWnd->GetDlgCtrlID());
//TRACE(str);
return
hbr;
}
|
在判断static控件的ID时,不是用某个具体控件的ID,而是CTLCOLOR_STATIC,表示一类控件。
本文转自Chinayu201451CTO博客,原文链接:http://blog.51cto.com/9233403/1967698 ,如需转载请自行联系原作者