void CRobotClientDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
//CDialog::OnPaint();把这个注释掉,不调用基类的OnPaint()
CPaintDC dc(this);
CDC memdc;
memdc.CreateCompatibleDC(&dc);//创建兼容DC
CBitmap bkg;
bkg.LoadBitmap(IDB_BG);//载入位图(这里用自己定义的位图ID)
BITMAP bkginfo;
bkg.GetBitmap(&bkginfo);//获取位图信息
memdc.SelectObject(&bkg);
RECT rect;
GetWindowRect(&rect);//获取对话框信息
dc.StretchBlt(0,0,rect.right-rect.left,rect.bottom-rect.top,&memdc,0,0,bkginfo.bmWidth,bkginfo.bmHeight,SRCCOPY);
}
}
04-10
96
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
04-08
51
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交