16,466
社区成员
发帖
与我相关
我的任务
分享
void CSizingFormViewView::OnPaint()
{
CPaintDC dc(this); // device context for painting
// get size ,
CRect rc;
GetWindowRect(&rc);
rc.OffsetRect(-rc.left,-rc.top);
#ifndef VIEW_NO_BORDER
rc.OffsetRect(-2,-2);// offset -2,-2
#endif
// Create a compatible memory DC
CDC memDC;
memDC.CreateCompatibleDC(&dc);
// Select a compatible bitmap into the memory DC
CBitmap bitmap;
bitmap.CreateCompatibleBitmap( &dc, rc.Width(), rc.Height());
HBITMAP oldBmp=(HBITMAP)memDC.SelectObject(&bitmap);
// Erase bkg
memDC.FillSolidRect(&rc,GetSysColor(COLOR_MENU));// RGB(210,210,210));
// Let the dialog draw into memDC.
SendMessage(WM_PRINT,(WPARAM)memDC.m_hDC,
(LPARAM)(PRF_CHILDREN | PRF_CLIENT ));//| PRF_NONCLIENT | PRF_ERASEBKGND | PRF_OWNED));
// copy to CB for checking
#ifdef TEST
memDC.SelectObject(oldBmp);
OpenClipboard();
EmptyClipboard();
SetClipboardData(CF_BITMAP,bitmap);
CloseClipboard();
oldBmp=(HBITMAP)memDC.SelectObject(&bitmap);
#endif
dc.BitBlt(rc.left,rc.top, rc.Width(), rc.Height(),&memDC,0,0,SRCCOPY);
// set back
memDC.SelectObject(oldBmp);
// free
DeleteObject(bitmap.m_hObject);
DeleteObject(memDC);
// do not draw all Ctls !
#if 1
UINT id=0;
CWnd *pWnd=0;
//
pWnd=GetDlgItem(IDC_BUTTON1);
pWnd->GetClientRect(&rc);
pWnd->ValidateRect(&rc);
//
pWnd=GetDlgItem(IDC_BUTTON2);
pWnd->GetClientRect(&rc);
pWnd->ValidateRect(&rc);
//
pWnd=GetDlgItem(IDC_GROUP);
pWnd->GetClientRect(&rc);
pWnd->ValidateRect(&rc);
//
pWnd=GetDlgItem(IDC_RADIO1);
pWnd->GetClientRect(&rc);
pWnd->ValidateRect(&rc);
//
pWnd=GetDlgItem(IDC_RADIO2);
pWnd->GetClientRect(&rc);
pWnd->ValidateRect(&rc);
//
pWnd=GetDlgItem(IDC_STATIC1);
pWnd->GetClientRect(&rc);
pWnd->ValidateRect(&rc);
//
pWnd=GetDlgItem(IDC_PICTURE);
pWnd->GetClientRect(&rc);
pWnd->ValidateRect(&rc);
//
pWnd=GetDlgItem(IDC_EDIT1);
pWnd->GetClientRect(&rc);
pWnd->ValidateRect(&rc);
//
pWnd=GetDlgItem(IDC_EDIT2);
pWnd->GetClientRect(&rc);
pWnd->ValidateRect(&rc);
//
pWnd=GetDlgItem(IDC_EDIT3);
pWnd->GetClientRect(&rc);
pWnd->ValidateRect(&rc);
//
pWnd=GetDlgItem(IDC_EDIT4);
pWnd->GetClientRect(&rc);
pWnd->ValidateRect(&rc);
#endif
// CFormView::OnPaint();
}
BOOL CSizingFormViewView::OnEraseBkgnd(CDC* pDC)
{
// TODO: Add your message handler code here and/or call default
return TRUE;
// return CFormView::OnEraseBkgnd(pDC);
}
OnPaint 中
// Let the dialog draw into memDC.
SendMessage(WM_PRINT,(WPARAM)memDC.m_hDC,
(LPARAM)(PRF_CHILDREN | PRF_CLIENT ));//| PRF_NONCLIENT | PRF_ERASEBKGND | PRF_OWNED));
是 把 窗口 所有的 东西 画一遍,因为 各个控件 已经 画好了 , 所以 要 把 所有控件 都 变为 窗口 有效。
即
// do not draw all Ctls !
#if 1
UINT id=0;
CWnd *pWnd=0;
。。。。。。