WM_CTLCOLOR消息的用法。有关控件…

出自http://blog.chinaunix.net/uid-24585655-id-2125549.html


HBRUSH CDialogColor::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
    HBRUSH hbr = CDialog::OnCtlColor(pDC,pWnd, nCtlColor);
    // TODO: Change any attributes of theDC here

    //设置显示字体
   
pDC->SetBkColor(RGB(255,255,255));//改变所有控件字体的背景色
    CFont * cFont=new CFont;
    cFont->CreateFont(16,0,0,0,FW_SEMIBOLD,FALSE,FALSE,0,
                                          ANSI_CHARSET,OUT_DEFAULT_PRECIS,
                                          CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,
                                          DEFAULT_PITCH&FF_SWISS,"Arial");
    //对特定的控件做修改

    switch()
    {
       case CTLCOLOR_STATIC: //对所有静态文本控件的设置

      {
          pDC->SetBkMode(TRANSPARENT);
          //设置背景为透明

          pDC->SetTextColor(RGB(255,255,0)); //设置字体颜色

          pWnd->SetFont(cFont); //设置字体

          HBRUSH B = CreateSolidBrush(RGB(125,125,255));
          //创建画刷

          return (HBRUSH) B; //返回画刷句柄

      }
    

你可能感兴趣的:(others)