CRect rc; GetClientRect(&rc);int x = (rc.Width()-bmp.bmWidth)/2; int y = (rc.Height()-bmp.bmHeight)/2;pDC->BitBlt(x,y,bmp.bmWidth,bmp.bmHeight,&cdc,0,0,SRCCOPY);
对dazebase做一点补充修正int x = (rc.Width()-bmp.bmWidth)/2; int y = (rc.Height()-bmp.bmHeight)/2; 上面两句话得到的是你的窗口客户去的中点坐标pDC->BitBlt(x,y,bmp.bmWidth,bmp.bmHeight,&cdc,0,0,SRCCOPY); 如果直接这样做的话你的图片的左上角在客户区中点了所以稍作更改 pDC->BitBlt(x-bmp.bmWidth/2,y-bmp.bmHeight/2,bmp.bmWidth,bmp.bmHeight,&cdc,0,0,SRCCOPY);
GetClientRect(&rc);int x = (rc.Width()-bmp.bmWidth)/2;
int y = (rc.Height()-bmp.bmHeight)/2;pDC->BitBlt(x,y,bmp.bmWidth,bmp.bmHeight,&cdc,0,0,SRCCOPY);
int y = (rc.Height()-bmp.bmHeight)/2;
上面两句话得到的是你的窗口客户去的中点坐标pDC->BitBlt(x,y,bmp.bmWidth,bmp.bmHeight,&cdc,0,0,SRCCOPY);
如果直接这样做的话你的图片的左上角在客户区中点了所以稍作更改
pDC->BitBlt(x-bmp.bmWidth/2,y-bmp.bmHeight/2,bmp.bmWidth,bmp.bmHeight,&cdc,0,0,SRCCOPY);