• Advertisement

Archived

This topic is now archived and is closed to further replies.

Is there any easy to to set a font for Dialogboxes and their windows in the win32 API

This topic is 4971 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi everybody. I''m currently practicing my gui skills and have been learning the strange ways of the window dialog box. My current method to change the text to a dialog box is to get a handle to the window of my choice, and than send a WM_SETFONT message with the appropriate parameters. The problem is that in some programs I have a ton of windows! Is there a way I can set the font for everything in with a simple api call or something? Thank you in advance! P.S I Just want to effect the dialog boxes, system menus, controls, and that sort of thing. I don''t need any info on how to set the font for the device context. -xorjesus

Share this post


Link to post
Share on other sites
Advertisement
Hmm, maybe this is was the wrong place to ask this question :[ Anyone know of some good forums for win32 api questions or the answer to my question? Thanx for any help.

Share this post


Link to post
Share on other sites
You could just set the font in the dialog box properties in the resource editor.

Share this post


Link to post
Share on other sites
and without the resource editor ?


The ever vigilant...

[edited by - MonkeyInBlack on June 8, 2004 3:15:42 PM]

Share this post


Link to post
Share on other sites
Change the declaration in front of font:

//DIALOG BOX: Options

IDD_OPTIONS DIALOGEX 0, 0, 235, 143
STYLE DS_SETFOREGROUND | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION
EXSTYLE WS_EX_TOOLWINDOW
CAPTION "Options"
FONT 8, "MS Sans Serif" //CHANGE THIS ONE!!!!!!!!!!!!!!!!!!!

BEGIN
GROUPBOX "Particle Generator (Fire)",IDC_STATIC,7,7,221,116
DEFPUSHBUTTON "OK",IDC_OPTIONS_OK,105,127,58,14
PUSHBUTTON "Cancel",IDC_OPTIONS_CANCEL,170,127,58,14
LTEXT "Particle Count",IDC_STATIC,14,18,46,8
LTEXT "Particle Speed",IDC_STATIC,124,18,46,8
EDITTEXT IDC_OPTIONS_COUNT,63,16,47,12,ES_AUTOHSCROLL
EDITTEXT IDC_OPTIONS_SPEED,171,16,47,12,ES_AUTOHSCROLL
LTEXT "Top X Pos",IDC_STATIC,14,36,45,8
LTEXT "Top Y Pos",IDC_STATIC,124,36,45,8
EDITTEXT IDC_OPTIONS_TOPX,63,35,47,12,ES_AUTOHSCROLL
EDITTEXT IDC_OPTIONS_TOPY,171,35,47,12,ES_AUTOHSCROLL
LTEXT "Bottom X Pos",IDC_STATIC,14,54,45,8
LTEXT "Bottom Y Pos",IDC_STATIC,124,54,45,8
EDITTEXT IDC_OPTIONS_BOTTOMX,63,54,47,12,ES_AUTOHSCROLL
EDITTEXT IDC_OPTIONS_BOTTOMY,171,54,47,12,ES_AUTOHSCROLL
LTEXT "Fade Speed",IDC_STATIC,14,72,45,8
LTEXT "Point Speed",IDC_STATIC,124,72,45,8
EDITTEXT IDC_OPTIONS_FADE,63,72,47,12,ES_AUTOHSCROLL
EDITTEXT IDC_OPTIONS_POINT,171,72,47,12,ES_AUTOHSCROLL
LTEXT "Particle Colors (Values 0-100, designate all at 101 for random)",
IDC_STATIC,13,88,209,8
LTEXT "Red",IDC_STATIC,11,102,17,8
LTEXT "Green",IDC_STATIC,85,102,20,8
LTEXT "Blue",IDC_STATIC,159,102,17,8
EDITTEXT IDC_OPTIONS_RED,29,101,47,12,ES_AUTOHSCROLL | ES_NUMBER
EDITTEXT IDC_OPTIONS_GREEN,107,101,47,12,ES_AUTOHSCROLL |
ES_NUMBER
EDITTEXT IDC_OPTIONS_BLUE,177,101,47,12,ES_AUTOHSCROLL |
ES_NUMBER
END

Share this post


Link to post
Share on other sites
You can''t effect bool, italics, or underline with that option. And that doesn''t eliminate the problem having to do this for every single dialog, control, and button :[

Share this post


Link to post
Share on other sites
quote:
Is there a way I can set the font
Please stipulate next time what attribute of the font you want to set instead of leaving it open to interpretation.

quote:
And that doesn''t eliminate the problem having to do this for every single dialog, control, and button :[


It changes the font of the control...

Share this post


Link to post
Share on other sites
quote:
Original post by xorjesus
You can''t effect bool, italics, or underline with that option. And that doesn''t eliminate the problem having to do this for every single dialog, control, and button :[


You can''t set underlining, but you can set bold and italics.

FONT 8, "Microsoft Sans Serif", 700, 1, 0x0

This sets the font to size 8 ms sans serif, weight 700 (bold), italics.

Note that setting the dialog font affects ALL controls on that dialog.

If you need to set underlining, then you''ll have to do that for each control that needs it.

Share this post


Link to post
Share on other sites
Thx sandman! I guess for underlining I''ll write a program that gets all the identifiers from the resources.h file, and put them in a vector, and then go through a loop and apply the underline. Thx again :]

Share this post


Link to post
Share on other sites

  • Advertisement