I am creating a console application and I need to center the text. This is my code:
void centerText(const char* word)
{
HWND hwnd = GetConsoleWindow();
RECT rct;
GetWindowRect(hwnd, &rct);
HDC dc = GetDC(hwnd);
_bstr_t msg(word);
DrawText(dc, msg, -1, &rct, DT_CENTER | DT_SINGLELINE);
ReleaseDC(hwnd, dc);
}
But the "word/msg" doesn't show. Thank you for your help.