Edit box with automatic scrollbars?
Hi,
I'm trying to modify an edit box so that when the text in it exceeds its visible size, it automatically gains scrollbars. I've tried doing it like so:-
Code:
(in my main window's WindowProc...)
(g_hwndText = edit box)
case EN_CHANGE:
{
int iNumLines;
HDC hDC;
RECT rc;
TEXTMETRIC tm;
DWORD dwStyle;
GetClientRect(g_hwndText, &rc);
iNumLines = SendMessage(g_hwndText, EM_GETLINECOUNT, 0, 0);
hDC = GetDC(g_hwndText);
GetTextMetrics(hDC, &tm);
ReleaseDC(g_hwndText, hDC);
if (rc.bottom - (iNumLines * tm.tmHeight) < 0)
{
dwStyle = GetWindowLong(g_hwndText, GWL_STYLE);
SetWindowLong(g_hwndText, GWL_STYLE, dwStyle | WS_VSCROLL);
}
break;
}
But it doesn't seem to work. Any ideas?