书法字典:https://www.shufadict.com

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;
    }

==

posted on 2012-09-15 21:36  翰墨小生  阅读(1502)  评论(0编辑  收藏  举报

导航

书法字典:https://www.shufadict.com