News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

default font

Started by msmith, February 03, 2005, 11:12:17 PM

Previous topic - Next topic

msmith

Is there a way to set a default font (font, size, etc) for a given window so that each control won't need to be set?

Tedd

Don't think so.
It's fairly simple to just do WM_SETFONT for each of the controls in WM_CREATE
(if a little annoying)
No snowflake in an avalanche feels responsible.

Relvinian

Another option to set the font for all child windows/controls in a window is to use the EnumChildWindow function (along with its callback) and use that to set the font.

You would do this on something like the WM_INITDIALOG message.

Relvinian

P1

Please do not upset the M$ gods of personalization.  It's meant to take on the desktop defaults of the user's choice.  "This is done by design."

As Application programmers, if we want something different, we need to change it for ourselves.  M$ gives the user's choice priority as defaults for the software in use.

Regards,  P1  :8)

Relvinian

I allow the user to change the font of my dialogs (if he/she so desired) by a configuration option and then set all the child windows of the applicationi (or specific dialogs) to the users choice.

I wouldn't personally change the font to something non-default (other then maybe the default dialog font size from 8 to 10 -- because the applications I publish commerically are people who are older and want to easily see it) without user-say.

Relvinian

donkey

Hi msmith,

If you are using windows as opposed to dialogs, you can use the WM_PARENTNOTIFY message to have the child windows enumerated at creation. This has the added advantage that you can exclude any child by simply giving it the WS_EX_NOPARENTNOTIFY style. For example in your WndProc for the main window this will set all controls to the default GUI font...

WndProc FRAME hWnd, uMsg, wParam, lParam
mov eax,[uMsg]

cmp eax,WM_CREATE
jne >.WMPARENTNOTIFY
jmp >>.EXIT

.WMPARENTNOTIFY
cmp eax,WM_PARENTNOTIFY
jne >.WMCOMMAND
cmp W[wParam],WM_CREATE
jne >>.DEFPROC
invoke GetStockObject,DEFAULT_GUI_FONT
invoke SendMessage,[lParam],WM_SETFONT,eax,TRUE
jmp >>.DEFPROC

.WMCOMMAND
cmp eax,WM_COMMAND
jne >.WMCLOSE
jmp >>.EXIT

.WMCLOSE
cmp eax,WM_CLOSE
jne >.WMDESTROY
invoke DestroyWindow,[hWnd]
jmp >>.EXIT

.WMDESTROY
cmp eax,WM_DESTROY
jne >.DEFPROC
invoke PostQuitMessage,NULL
jmp >>.DEFPROC

.DEFPROC
invoke DefWindowProc,[hWnd],[uMsg],[wParam],[lParam]
ret

.EXIT

xor eax,eax
ret
ENDF


However, since all dialog child controls are forced to have the WS_EX_NOPARENTNOTIFY style regardless of whether you specify it or not this will not work on dialogs or dialog as main type applications. Although it will send the message to a dialog if the child is manually created with CreateWindowEx or CreateWindow.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

msmith

Hi Donkey,

Good to hear from you.

The EnumChildWindow mechanism that you and Relvinian have showed me appears to be a way for me to set the fonts for each control systematically. Please correct me if I'm wrong.

This is really not my problem. My compiler maintains a Descriptor for each window and control and the Descriptors are linked internally, so going through the list is no problem.

The GUI which I used some time ago had the concept of a Default Font so when an object was constructed, it would automatically assume the Default Font.

It seems wastefull to have a control created with a known "wrong" font only to turn around and have to reset it.

Thanks,

Mike

donkey

Hi msmith,

My guess is that they were using in-memory dialog templates. The child controls will assume the font given to the dialog in the DLGTEMPLATEEX structure with DS_SETFONT style. I would suspect that the application builds the dialog in memory then uses a dialog as win type application, it would only require modifying one font in one structure prior to creation.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable