0

so i've got this code:

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

How can i make the text appear in the center when re-sizing the window?

1 Answers1

2

Call GetClientRect to get the window dimensions. Do some math to get the center coordinate. It will be easier if you also call SetTextAlign with TA_CENTER to use the text center point as the coordianate you give to TextOut.

ScottMcP-MVP
  • 10,337
  • 2
  • 15
  • 15