I have put a font dialog box in my test app. When the user selects "Set Font...", a font dialog box pops up and allows the user to pick his choice. The problem arise when the user picks his choice and wants to repaint the client area using current font selection. Here is what it should do: => when the user selects "Set Font..." a font dialog box should pop up. ------> i used API "ChooseFont" to create a font dialog box. ------> and used "CreateFontIndirect" to use the selected font as current font ------> i saved the current selection in "hFont" and then called "SendMessageA" with "WM_SETFONT" to repaint the client area. ----> DOESN"T WORK! I guess it is not as simple as I thought it is. => NOW, how do i apply the selected font in the edit control? Thanks in Advance! e-nigma
Posted on 2001-01-14 08:11:00 by e-nigma
I'm not quite sure if I understood you right but: invoke SendMessage,hWndEdit,WM_SETFONT,hFont,0 should work tho...
Posted on 2001-01-14 10:28:00 by JimmyClif
Here are a couple of things to check:
  • Is CreateFontIndirect successful?
  • Is the handle to the edit window correct? edit: replaced with MB tags
    
    ,,
  • and are also available
  • Hiro This message was edited by Hiroshimator, on 2/7/2001 7:03:42 AM
  • Posted on 2001-01-14 11:11:00 by Iczelion
    Pointer to the LOGFONT was not properly defined. Now, it is WORKING! =>But there is another problem. When the app is restarted the default font is the one provided by the system. But I want to use previously selected font as the default font everytime the app is started. Is there any specific API to do this? =>I'd like to add one more question. Whenever I save a file, the last alphabet in the file gets deleted. Suppose a file named "asm.txt" contains the data "WIN32ASM Is Great". When I save and reopen it, the data will be "WIN32ASM Is Grea". The alphabet "t" is not saved. Why is that? I've use WM_GETTEXTLENGTH to determine the length before before writing it to the disk. Thanks in Advance! e-nigma
    Posted on 2001-01-14 23:56:00 by e-nigma
    =>But there is another problem. When the app is restarted the default font is the one provided by the system. But I want to use previously selected font as the default font everytime the app is started. Is there any specific API to do this? If I understand the problem correctly, it's like this: 1. User runs your app. 2. User sets the font for your app. 3. Your app uses user-selected font. 4. User exits your app. 5. User re-starts your app, but app has reverted to default font. No API call will save "user preferences" between program instances. Your best bet is to use the registry. Create a key something like: HKEY_CURRENT_USER\Software\e-nigma\YourApp\ then create the value named DefaultFont and set it's value-data to the name of the font the user selected. At run-time, have your app check this value, and set font accordingly... I suppose you could use a settings file instead of the registry (i.e. YourApp.INI), but then again we could all go back to using adding-machines instead of computers, too.
    Posted on 2001-02-07 06:45:00 by Q
    Actually, we could really all go back to using the abbacus if we wanted, too.... :D _Shawn
    Posted on 2001-02-07 10:47:00 by _Shawn
    Well if I'm not wearing shoes I can count to twenty! Mirno
    Posted on 2001-02-07 11:12:00 by Mirno