Newsgroups: comp.windows.ms.programmer
Path: utzoo!utgpu!watserv1!watmath!hyper.hyper.com!bonneau
From: bonneau@hyper.hyper.com (Paul Bonneau)
Subject: Re: Fonts in MessageBox
Message-ID: <1991May21.202253.21230@hyper.hyper.com>
Keywords: Anyone know how to set the font to Helvetica 8 using MessageBox?
Reply-To: bonneau@hyper.UUCP (Paul Bonneau,,)
Organization: HyperCube Inc.
References: <1523@caslon.cs.arizona.edu>
Date: Tue, 21 May 1991 20:22:53 GMT

In article <1523@caslon.cs.arizona.edu> bam@cs.arizona.edu (Brett A. Morrison) writes:
>Keywords says it all.  Please help!  I need to figure out how to change the
>font using the MessageBox function.
>
>E-Mail:  bam@cs.arizona.edu
>
>Brett Morrison
>
The WM_SETFONT message can be used to supply a new font
handle to a control for display.  So, the problem is how
to get the message to each control of the MessageBox.

A sleazy hack springs to mind:

Before the call to MessageBox(), set a global flag to
indicate that a MessageBox is present (and clear the flag
after the call).

When the main window gets the WM_ACTIVTE message with
wParam == 0 *and* the global flag set, then LOWORD(lParam) is
the window handle of the MessageBox.

Walk the linked list of child windows (ie. controls) of the
MessageBox with a loop like:

	for (hwnd = GetWindow(hwndMessageBox, GW_CHILD);
	    hwnd != NULL; hwnd = GetWindow(hwnd, GW_HWNDNEXT))
		SendMessage(hwnd, WM_SETFONT, ...);

There may be a cleaner way, but I think this approach will
work anyway (although make sure you have a bucket handy since
it *is* pretty gagnastic).

cheers - Paul Bonneau.
