DirectWrite处理WM_SIZE消息

对于DirectWrite程序,在窗口大小改变时,也要同步更新render target的尺寸,否则的话,所绘文本可能超出窗口之外。可以定义一个OnResize函数来更新render target的尺寸,然后再WM_SIZE中调用这个函数。

// When window size changed, we need to resize the render target as well
VOID OnResize(UINT width, UINT height)
{
    if(g_pRenderTarget)
    {
        D2D1_SIZE_U size = D2D1::SizeU(width, height);
        g_pRenderTarget->Resize(size);
    }
}

调用

case WM_SIZE:
    {
        UINT width = LOWORD(lParam);
        UINT height = HIWORD(lParam);
        OnResize(width, height);
        break;
    }

==

你可能感兴趣的:(DirectWrite处理WM_SIZE消息)