Results 1 to 4 of 4

Thread: Need Help with the RichTextBox and CommonDialog

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 1999
    Posts
    28

    Post

    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

  2. #2
    Addicted Member
    Join Date
    Jul 1999
    Posts
    219

    Post

    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

  3. #3
    Addicted Member
    Join Date
    May 1999
    Location
    Californ-I- A
    Posts
    207

    Post

    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


  4. #4

    Thread Starter
    Junior Member
    Join Date
    Nov 1999
    Posts
    28

    Post

    Thanks a Lot

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width