【问题标题】:how to make the text appear in center of the window when re-sizing it, visual c++重新调整大小时如何使文本出现在窗口的中心,Visual C++
【发布时间】:2015-02-18 23:44:05
【问题描述】:

所以我有这个代码:

{
    PAINTSTRUCT ps;
    HDC hdc;

switch (message)
{
case WM_PAINT:
    hdc = BeginPaint(hWnd, &ps);
    TextOut(hdc,
        100, 55, TEXT("some text here"), 50
        );

    EndPaint(hWnd, &ps);
break;
case WM_DESTROY:
    PostQuitMessage(0);
    break;
default:
    return DefWindowProc(hWnd, message, wParam, lParam);
    break;
}

如何在调整窗口大小时使文本显示在中心?

【问题讨论】:

    标签: c++ visual-studio-2013 resize window textout


    【解决方案1】:

    调用 GetClientRect 以获取窗口尺寸。做一些数学运算以获得中心坐标。如果您还使用 TA_CENTER 调用 SetTextAlign 以使用文本中心点作为您提供给 TextOut 的坐标,则会更容易。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-07-08
      • 2018-09-25
      • 1970-01-01
      • 1970-01-01
      • 2013-10-07
      • 2014-01-01
      相关资源
      最近更新 更多