-
I know this is probably not how you should do it, nut why won't this work:
Code:
HWND hWnd;
hInst = hInstance;
hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
Text1 = CreateWindowEx(WS_EX_CLIENTEDGE, "Edit", "1", WS_CHILD | ES_NUMBER, 20,20, 80, 25, hWnd,0, hInst, NULL);
HFONT hFont;
HDC hDC;
SIZE TxtSize;
CHAR* Tahoma = "Tahoma";
ShowWindow(Text1, nCmdShow);
hDC = GetDC(Text1);
GetTextExtentPoint32(hDC, "T", 1, &TxtSize);
hFont = (HFONT) CreateFont( TxtSize.cx , 0, 0, 0, FW_NORMAL, 0, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, 0, Tahoma);
SelectObject(hDC, hFont);
ReleaseDC(Text1, hDC);
if ((!hWnd) && (!Text1))
{
return FALSE;
}
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
return TRUE;
Unless you didn't get it, I'm trying to set the TextBox's font to Tahoma. It doesn't raise any errors, but the font is always that boldish systemy font.
Any help?
-
You have to send it a WM_SETFONT message:
Code:
SendMessage(Text1, WM_SETFONT, (WPARAM)Tahoma, TRUE);
-
<ahem>
I knew that all along.
Thanks,
Moi.