RECT rect;
RECT rcParent;
GetClientRect(&rcParent);
rect.left = rcParent.left;
rect.right = rcParent.right - nBtnWidth;
rect.top = rcParent.top ;
rect.bottom = rcParent.top + nOSDHeight;
if(! m_pCaption)
{
m_pCaption = new CStatic();
bRet |= m_pCaption->Create(NULL, WS_CHILD|WS_VISIBLE|SS_NOTIFY, rect, this , IDC_CAPTIONBAR);//
if(csCameraName.IsEmpty()) csCameraName = _T("Untitled");
m_pCaption->SetWindowTextW(csCameraName);
/*CFont * font = new CFont;
font->CreateFontW(22,0,0,0,FW_SEMIBOLD,false,false,0,CHINESEBIG5_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH&FF_SWISS,_T("Arial"));
m_pCaption->SetFont(font);*/
}
Override WM_CTLCOLOR message
HBRUSH CVideo::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor){
HBRUSH hbr = CStatic::OnCtlColor(pDC, pWnd, nCtlColor);
COLORREF textColor = RGB(255,255,255);
COLORREF bkColor = RGB(0,0,0);
if(nCtlColor == CTLCOLOR_STATIC) //
{
pDC->SetTextColor(textColor);
pDC->SetBkColor(bkColor); // 這裡的background color只限於text周圍, 並不是CStatic所create出來的整個rectangle
hbr = CreateSolidBrush(bkColor); // 這樣才會填滿整個retangle
}
return hbr;
其中
- CTLCOLOR_BTN Button control
- CTLCOLOR_DLG Dialog box
- CTLCOLOR_EDIT Edit control
- CTLCOLOR_LISTBOX List-box control
- CTLCOLOR_MSGBOX Message box
- CTLCOLOR_SCROLLBAR Scroll-bar control
- CTLCOLOR_STATIC Static control
或者可以指定要改哪個ID
if(pWnd->GetDlgCtrlID() ==IDC_CAPTIONBAR)
{
pDC->SetTextColor(textColor);
pDC->SetBkColor(bkColor);
}
return hbr;
}
沒有留言:
張貼留言