Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!yale!ox.com!metapyr!marc From: marc@metapyr.UUCP ( The Karate Kid ) Newsgroups: comp.windows.ms Subject: Re: Setting ListBox font Message-ID: <956@metapyr.UUCP> Date: 28 Aug 90 13:44:02 GMT References: <1355@msa3b.UUCP> <2915@ncr-sd.SanDiego.NCR.COM> Reply-To: marc@metapyr.UUCP (Marc Paige - The Karate Kid ) Organization: Meta Systems, Ltd. -- Ann Arbor, MI Lines: 48 In article <2915@ncr-sd.SanDiego.NCR.COM> carlc@mars.SanDiego.NCR.COM (Carl Christofferson) writes: >In article <1355@msa3b.UUCP> kevin@msa3b.UUCP (Kevin P. Kleinfelter) writes: >>How does one set the font for a listbox? The only thing I can find >>about changing fonts in TFM is for TextOut. i.e. >> SelectObject (hDC, hFont); >> TextOut (hDC, ...); >> > >If your list box is in a dialog box, its real simple. First, get a handle >to the desired font, > hDesiredFont = GetStockObject (XXX_FONT); // I used SYSTEM_FIXED_FONT > >Then, in the WM_INITDIALOG in your dialog box code, send a WM_SETFONT message >to the list box: > case WM_INITDIALOG: > SendDlgItemMessage (hDlg, ID_CONTROL, WM_SETFONT, hDesiredFont, 0L); > // ID_CONTROL is the ID you gave to your list box, ie IDL_LISTBOX > // other code as desired > break; > >That's it! Hope this helps. > >Carl Christofferson >carlc@mars.SanDiego.NCR.COM >disclaimer: Any opinions expressed are entirely my own ... The control does not have to be in a dialog box! The WM_SETFONT message can be sent to any window at any time! I've done this to show a change of focus for MDI child windows and the title bar (pretty cool effect). Just load the desired font and then force a repaint of the frame (WM_NCPAINT) and voila a new font in the title bar. The WM_PAINT with the new font from WM_SETFONT will cause the contents of a control to be painted correctly. Windows has come a long way with this feature. BTW, I'm also VERY glad to see that they added the extended dialog box call. I hate using file statics or globals to configure complex dialogs. Now I can pass the handle to a nice structure describing the configuration. "Isn't that special?!" I hope this is the last of this. Remember a window is a window is a window. Pretty much anything you can do to a window of your own class can be done to a window of the standard classes. AND you can always subclass to do the things that the standard classes can't do. Marc Paige ------------------------------------------------------------------------------ "tired and shagged out from a prolonged squawk" - mpfc the parrot sketch