Is there a code to change the font and font size in an edit control?
I have searched through my API reference for about a half an hour with no luck.

Does anybody here know how this can be done??

I tried to PostMessage WM_SETFONT to the edit control but that didn't work for me.

Is there another way?

And also how would I change the background color of my window to lets say.. white??

Posted on 2002-01-23 00:27:33 by poison

to change the font you have to use WM_SETFONT:
(I don't know another way)

Invoke SendMessageA, HandleOfEditbox, WM_SETFONT, HandleOfFont, 0

You get the handle of the font by using CreateFont(Indirect).
This API can be used to change the size of the font, too!


If you have a dialog, then handle WM_CTLCOLORDLG:


Invoke CreateSolidBrush, WINDOW_BACK_COLOR

If you create the window via CreateWindow, then set the backcolor in your WNDCLASSEX:

Invoke CreateSolidBrush, WINDOW_BACK_COLOR
mov wc.hbrBackground, eax

Think thats all..
Posted on 2002-01-23 02:15:32 by Rennsemmel
Ok, I did the CreateFont thing but I am lost.... How do I get the return value of it??
I tried to get it from eax which is where i thot it would be but it crashes.

I'm trying to get hte handle of the font Comic Sans MS and Verdana

does anyone know the handles of these??
Posted on 2002-01-23 12:45:38 by poison
I use this code for setting the standard Windows Font to a button:

invoke GetStockObject, DEFAULT_GUI_FONT
mov hFont, eax

invoke CreateWindowEx, 0, addr szButtonClass, addr szCommand3, WS_CHILD or WS_VISIBLE, 336, 136, 89, 33, hWin, BUTTON1, 400000h, 0
invoke SendMessage, eax, WM_SETFONT, hFont, 0
Posted on 2002-01-23 13:00:00 by bazik
Will someone please tell me how to do this stuff but make the instructions for like a newbie, then maybe i'll understand :)

I figured out how to make the background of the window white but is there a way to change the background of static text and an edit box white also?

I tried that createfont thing a bunch of times in a bunch of different ways but i didn't understand. I just want to make the font of my edit box Comic Sans MS font size 12 and the font of the static text to Verdana and size to 12.

Posted on 2002-01-23 13:16:15 by poison
Here it is at its simplist

FontName db "Comic Sans MS",0
hFont dd 0

invoke CreateFont,11,6,0,0,0,0,0,0,0,0,0,0,0,ADDR FontName
mov hFont,eax


invoke SendMessage,SomeWindowHandle,WM_SETFONT,hFont,0

Play around with the first two numbers in the CreateFont function to change the height and width of the font.
Posted on 2002-01-23 19:59:32 by Eóin