我想把原点放在中心,所以我做了:
SetViewportOrgEx(hdc,width/2,height/2,NULL);
(如下面的代码所示)
现在,在实施双缓冲后,它似乎无法正常工作。任何想法为什么以及什么应该是这里的最佳实践?非常感谢
下面的代码:
case WM_PAINT:
{
hdc = BeginPaint(hWnd, &ps);
// TODO: Add any drawing code here...
RECT rect;
GetClientRect(hWnd, &rect);
int width=rect.right;
int height=rect.bottom;
//Changing Origin position
SetViewportOrgEx(hdc,width/2,height/2,NULL);
HDC backbuffDC = CreateCompatibleDC(hdc);
HBITMAP backbuffer = CreateCompatibleBitmap( hdc, width, height);
int savedDC = SaveDC(backbuffDC);
SelectObject( backbuffDC, backbuffer );
HBRUSH hBrush = CreateSolidBrush(RGB(255,255,255));
FillRect(backbuffDC,&rect,hBrush);
DeleteObject(hBrush);
//Drawing on backbuffDC
BitBlt(hdc,0,0,width,height,backbuffDC,0,0,SRCCOPY);
RestoreDC(backbuffDC,savedDC);
DeleteObject(backbuffer);
DeleteDC(backbuffDC);
EndPaint(hWnd, &ps);
}