Author | Message | Time |
---|---|---|
Okee | I've been moving my connection code out of my console bot, and into the Win32 GUI shell I created awhile ago, for it. I wanted to add the ability to let the user select the font and font size of the richtext box. How should I go about making that font select pop up window appear, and then changing the font of the window? | May 16, 2005, 6:08 AM |
Myndfyr | To create a standard font dialog, if you're using MFC, you can use the CFontDialog window object, or if not, the Standard Font Dialog Box. Then to change the font of a window, if you're using MFC, you can use CWnd::SetFont or if not, use the WM_SETFONT message. You may also want to read The Logical Font. [edit: Thanks UL for the message info :)] | May 16, 2005, 11:14 PM |
UserLoser. | [quote author=MyndFyre link=topic=11605.msg112667#msg112667 date=1116285246]I can't find a "SetWindowFont' function in MSDN. [/quote] Use WM_SETFONT message | May 17, 2005, 2:27 AM |
Okee | Alright, I've been passing my CHOOSEFONT items to ChooseFont, and im working on what comes after calling ChooseFont. I'm not sure what the HDC paramater of SelectObject should be though. Should it be the window handle to my richtext box? I haven't made use of HDC in my program so far, so I don't know what the "handle to my device context" should be? My code.. [code] case ID_CONFIGURATION_FONTSETUP_CHANNELTEXT: ZeroMemory(&FontChannelCf, sizeof(FontChannelCf)); FontChannelCf.lStructSize = sizeof (FontChannelCf); FontChannelCf.hwndOwner = hDlg; FontChannelCf.lpLogFont = &FontChannelLf; FontChannelCf.rgbColors = FontChannelCrgb; FontChannelCf.Flags = CF_SCREENFONTS | CF_EFFECTS; if(ChooseFont(&FontChannelCf) == TRUE) { FontChannelHf = CreateFontIndirect(FontChannelCf.lpLogFont); FontChannelHfprev = SelectObject((HDC)GetDlgItem(hDlg, IDC_BNCHAT), FontChannelHf); FontChannelCrgb = FontChannelCf.rgbColors; FontChannelRgbprev = SetTextColor((HDC)GetDlgItem(hDlg, IDC_BNCHAT), FontChannelCrgb); } break; [/code] | May 17, 2005, 6:16 AM |
Adron | SelectObject is used to pick that font as the active font on a device context. It's done right before you write text to that device context. It's probably not what you want to do. | May 17, 2005, 4:17 PM |
UserLoser. | You could use the CHARFORMAT struct. Use EM_SETCHARFORMAT. I don't know why I didn't see you say rich text box earlier | May 17, 2005, 6:43 PM |
Okee | Yeah I was looking at the CHARFORMAT struct, and EM_SETCHARFORMAT. I stopped looking at it though, because I don't think you can use the GetFont function, or make a similar font selection dialog box appear. How do you integrate the font select box with the CHARFORMAT struct, and messages? Should I just make my own (which would suck for taking away from the clean look im going for)? | May 18, 2005, 2:11 AM |