对于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; }
==
本文转自zdd博客园博客,原文链接:http://www.cnblogs.com/graphics/archive/2012/09/15/2686985.html,如需转载请自行联系原作者