Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Im creating a tect box by invoking the following command:
hServerLog = CreateWindowEx(WS_EX_CLIENTEDGE,
"EDIT",
"",
WS_CHILD|WS_VISIBLE|WS_VSCROLL|ES_READONLY|ES_LEFT|ES_MULTILINE|ES_AUTOVSCROLL,
0, 0,
491,250,
hWnd,
NULL,
hInst,
NULL);How do I change the default font of that textbox into somthing else?

You can't change the default font for a Win32 control; it defaults to the default system font. However, you can change the font of any control, by resetting it anytime after creation (calling CreateWindowEx).
Some people prefer to wait until the ctrl's parent window receives the WM_CTLCOLOREDIT message. It is sent when the ctrl is first drawn, at which time its colors and font can be set.
Anyway, you'll need to create a font, or use an existing one, and set it like this:
SendMessage(hServerLog, WM_SETFONT, (WPARAM)hMyFont, 0);
where hMyFont is a handle to a font, such as one created by the CreateFontIndirect() function. For example:
LOGFONT lf;
memset(&lf, 0, sizeof(LOGFONT);
lf.lfWeight = FW_NORMAL;
lf.lfHeight = 20; //in pixels
lf.lfFaceName = "Arial";HFONT hMyFont = CreateFontIndirect(&lf);
There are other options with the zany LOGFONT structure, but that's beyond this post.

![]() |
C++: Convert Multibyte bu...
|
aku
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |