hi..
I'm trying to change the font of the button window [not the button on
Dialog Box]
I have used WM_SETFONT message after creating font , using API
CreateFontIndirect() , but it is not working , still showing the font
in Bold format,

here is the following code i'm using....
plz let me know where i'm going wrong


LOGFONT lf;
HFONT hFont;


/*
* for fints on buttons
*/
lf.lfHeight = 25;
lf.lfEscapement = 2700;
lf.lfOrientation = 0;
lstrcpy(lf.lfFaceName, TEXT("Times New Roman"));
g_hFontLeft = CreateFontIndirect(&lf);


CreatWindow("button", ....);


SendMessage(hButton, WM_SETFONT, g_hFontLeft , 0);

Re: Changing button font by David

David
Thu Apr 13 03:40:18 CDT 2006

>I'm trying to change the font of the button window [not the button on
>Dialog Box]
>I have used WM_SETFONT message after creating font , using API
>CreateFontIndirect() , but it is not working , still showing the font
>in Bold format,

Where/when do you delete the font handle? It'll need to exist for the
lifetime of the control using it.

Do you need to set the flag with WM_SETFONT to have the control redraw
itself?

Dave

Re: Changing button font by Anis

Anis
Mon Apr 17 03:23:06 CDT 2006

When do i need to create and set the font ,
before the CreateWidnow or After


Re: Changing button font by David

David
Mon Apr 17 04:06:24 CDT 2006

>When do i need to create and set the font ,
>before the CreateWidnow or After

Either!

It'll obviously need to exist prior to your setting the font with
WM_SETFONT, and it'll need to exist until that window stops using that
font (probably when the window is destroyed).

Dave

Re: Changing button font by Anis

Anis
Mon Apr 17 04:40:24 CDT 2006

thx for the repy,
here i'm creating the button first and then using SendMessage()
but the button is not showing the text

SendMessage(hButton, WM_SETFONT, g_hFont, TRUE);


Re: Changing button font by David

David
Mon Apr 17 07:57:20 CDT 2006

>here i'm creating the button first and then using SendMessage()
>but the button is not showing the text
>
>SendMessage(hButton, WM_SETFONT, g_hFont, TRUE);

You must be doing something wrong - the technique does work! :)

I don't know what else to tell you - I think I've covered all there is
to consider.

To summarise:

You create the font (handle)
Use WM_SETFONT to have the control use the font (assuming the control
is a standard control and so does handle WM_SETFONT).
Only delete the font (handle) when the control is finished with it.

Dave

Re: Changing button font by Anis

Anis
Wed Apr 19 02:40:10 CDT 2006

hi
thx for the HELP

i have found the solution

thx :-)