窗口控件背景透明

要讓窗口控件背景透明只需響應CtlColor消息並返回透明畫刷就行。code

HBRUSH CXXXDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
    HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
    
    // TODO: Change any attributes of the DC here
    if(pWnd->GetDlgCtrlID() == IDC_LIST1 )
    {
        pDC->SetTextColor(RGB(255, 0, 0));
        pDC->SetBkMode( TRANSPARENT ) ;   
        return (HBRUSH)GetStockObject(NULL_BRUSH);
    }
    // TODO: Return a different brush if the default is not desired
    return hbr;
}
相關文章
相關標籤/搜索