-
Hi :) I'm trying to change the font in the
Rich text box with the Common dialog. So I put in this code
CommonDialog1.Action = 4
RichTextBox1.Font = CommonDialog1.FontName
But this dos not change the size and there is
no RichTextBox1.Fontsize.
So howe can You change the Font Name, size, Style, etc.
Thanks All :)
-
Forget a commondialog for fonts here a code i made to do it cuase i never figure out how to use it for ftons so here
Code:
Private Sub Form_Load()
For X = 0 To Screen.FontCount
List1.AddItem Screen.Fonts(X)
Next X
End Sub
Private Sub List1_Click()
RichTextBox1.Font = List1.Text
End Sub
-
To use common dialog with rtf, use something like this. Basically, you want to setup the dialog with whatever font is at the current cursor position (selstart). Then show the dialog. You must set the flags property to show the font dialog. This example sets the flags to show printer and screen fonts, and effects (underline, italic, underline, etc)
Private Sub mnuChooseFont_Click()
On Error GoTo cancelerror
'Setup and show font dialog with font at
'current position in RTF so user can see
'what he/she's changing the font from.
CommonDialog.FontName = currentRTF.SelFontName
CommonDialog.FontSize = currentRTF.SelFontSize
CommonDialog.FontBold = currentRTF.SelBold
CommonDialog.FontItalic = currentRTF.SelItalic
CommonDialog.FontUnderline = currentRTF.SelUnderline
CommonDialog.FontStrikethru = currentRTF.SelStrikeThru
CommonDialog.Color = currentRTF.SelColor
CommonDialog.Flags = cdlCFScreenFonts Or cdlCFPrinterFonts Or cdlCFEffects
CommonDialog.ShowFont
'Apply new font to text
currentRTF.SelFontName = CommonDialog.FontName
currentRTF.SelFontSize = CommonDialog.FontSize
currentRTF.SelBold = CommonDialog.FontBold
currentRTF.SelItalic = CommonDialog.FontItalic
currentRTF.SelUnderline = CommonDialog.FontUnderline
currentRTF.SelStrikeThru = CommonDialog.FontStrikethru
currentRTF.SelColor = CommonDialog.Color
Exit Sub 'Successful
cancelerror: 'Error (user canceled)
Exit Sub
End Sub
Hope that helps.
------------------
Micah Carrick
http://micah.carrick.com
[email protected]
ICQ: 53480225
-
Thanks a Lot :cool: :cool: :cool: