Windows 为什么Bitblt不能工作
为什么无法在窗口中显示文本?您需要创建位图并在DC中选择它:Windows 为什么Bitblt不能工作,windows,gdi,bitblt,Windows,Gdi,Bitblt,为什么无法在窗口中显示文本?您需要创建位图并在DC中选择它: > case WM_PAINT: { > hdc = BeginPaint(hWnd, &ps); > // TODO: Add any drawing code here... > RECT rt; > GetClie
> case WM_PAINT:
{
> hdc = BeginPaint(hWnd, &ps);
> // TODO: Add any drawing code here...
> RECT rt;
> GetClientRect(hWnd, &rt);
> HDC myHdc = CreateCompatibleDC(hdc);
>
> DrawText(myHdc, szHello, strlen(szHello), &rt, DT_CENTER);
> BitBlt(hdc,0,0,rt.right-rt.left,rt.bottom-rt.top,myHdc,0,0,SRCCOPY);
>
> EndPaint(hWnd, &ps);
}
>
> break;
您需要创建位图并在DC中选择它:
> case WM_PAINT:
{
> hdc = BeginPaint(hWnd, &ps);
> // TODO: Add any drawing code here...
> RECT rt;
> GetClientRect(hWnd, &rt);
> HDC myHdc = CreateCompatibleDC(hdc);
>
> DrawText(myHdc, szHello, strlen(szHello), &rt, DT_CENTER);
> BitBlt(hdc,0,0,rt.right-rt.left,rt.bottom-rt.top,myHdc,0,0,SRCCOPY);
>
> EndPaint(hWnd, &ps);
}
>
> break;
正确的。当您使用CreateCompatibleDC时,我相信选择到DC中的位图是1x1位位图,这不是很有用。对。当您使用CreateCompatibleDC时,我相信选择到DC中的位图是1x1位位图,这不是很有用。