不是“自绘控件” 是 在 NCPAINT 中 直接画 图片 例子: LRESULT CMyFileOpenDlg::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) { // TODO: Add your specialized code here and/or call the base class if (message==WM_NCPAINT||message==WM_NCACTIVATE) { DrawCaption(); return 1; } return CDialog::WindowProc(message, wParam, lParam); } void CMyFileOpenDlg::DrawCaption() { CDC* pWinDC = GetWindowDC(); CRect reWin; GetWindowRect(reWin); reWin.OffsetRect(-reWin.left,-reWin.top); //reWin.bottom=reWin.top+23; CBitmap bit; bit.LoadBitmap(IDB_BITMAP1); // 红色 矩形 CBrush brush; brush.CreatePatternBrush(&bit);// 作背景 pWinDC->SelectObject(brush); pWinDC->PatBlt(3,3,reWin.Width()-6,GetSystemMetrics(SM_CYCAPTION),PATCOPY); pWinDC->SetBkMode(TRANSPARENT); pWinDC->TextOut(6,6,"SelfDraw Caption",16); ReleaseDC(pWinDC); }
自绘标题栏 NCPAINT
"dialog窗口标题处加图片吗?" 1 有必要吗 2 可以 但 麻烦
m_Group 是 资源中 拖的 Group 控件, 然后关联的 变量。
// m_bmpGroup.LoadBitmap(IDB_BITMAP2); m_Group.SetBitmap(m_bmpGroup);
15,979
社区成员
115,897
社区内容
加载中
试试用AI创作助手写篇文章吧