MFC OnPaint某一區域繪製背景色
阿新 • • 發佈:2019-01-01
void CVLifeClientDlg::OnPaint() { if (IsIconic()) { CPaintDC dc(this); // 用於繪製的裝置上下文 SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0); // 使圖示在工作區矩形中居中 int cxIcon = GetSystemMetrics(SM_CXICON); int cyIcon = GetSystemMetrics(SM_CYICON); CRect rect; GetClientRect(&rect); intx = (rect.Width() - cxIcon + 1) / 2; int y = (rect.Height() - cyIcon + 1) / 2; // 繪製圖標 dc.DrawIcon(x, y, m_hIcon); } else { CPaintDC dc(this); CRect rect; m_cCePing.GetWindowRect(&rect); ScreenToClient(&rect); CRect rc(0,rect.top,1920,1080); dc.FillSolidRect(rc,RGB(255,255,255));//*/CDialogEx::OnPaint(); } }