Skip to content

Instantly share code, notes, and snippets.

@Vladimir-Novick
Created March 19, 2022 11:49
Show Gist options
  • Save Vladimir-Novick/42d854b5c1f285178a0ea2d14cf0f33d to your computer and use it in GitHub Desktop.
Save Vladimir-Novick/42d854b5c1f285178a0ea2d14cf0f33d to your computer and use it in GitHub Desktop.
SIZE TextRect = { 0 };
RECT textrect = { 0 };
GetClientRect(hWnd, &rect);
textrect = rect;
DrawText(hdc, buff, -1, &textrect, DT_CALCRECT);
float rowCount = ((float)textrect.right / (float)(rect.right - rect.left)) + 0.9999;
rect.top += ((rect.bottom - rect.top) - (textrect.bottom *(int)rowCount))/ 2;
DrawText(hdc, buff, -1, rect, DT_CENTER | DT_WORDBREAK | DT_EXPANDTABS);
SelectObject(hdc, hOldFont);
::SetTextColor(hdc, oldtxtColor);
::SetBkMode(hdc, oldMode);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment