Rich Text Box [font] (1 Viewer)

Kn1ght_M4r3

Member
Joined
Mar 3, 2003
Messages
332
Location
D o w n l o a d C o m p l e t e .....
okay this is the problem im having, i wanted to let the font change for the RTB and i altered the code and now its able to change the font without selecting it before hand. though now for the size and color i dont know how to change it. any ideaZ?

rtbDisplay = rich text box
cdlViewer = common dialog
the code:

Private Sub Command1_Click()
cdlViewer.Flags = cdlCFBoth Or cdlCFEffects
cdlViewer.ShowFont
rtbDisplay.Font = cdlViewer.FontName
rtbDisplay.SelFontSize = cdlViewer.FontSize
rtbDisplay.SelBold = cdlViewer.FontBold
rtbDisplay.SelItalic = cdlViewer.FontItalic
rtbDisplay.SelUnderline = cdlViewer.FontUnderline
rtbDisplay.SelColor = cdlViewer.Color
End Sub

Initially the code for line 3 was rtbDisplay.SelFontName but i changed it and now i do not need to select the text i wish to change.
 

sunny

meh.
Joined
Jul 7, 2002
Messages
5,352
Gender
Male
HSC
2002
Code:
With rtbDisplay
  .Font = cdlViewer.FontName
  .Font.Size = cdlViewer.FontSize
  .SelStart = 0
  .SelLength = Len(rtbDisplay.Text)
  .SelColor = cdlViewer.Color
  .SelUnderline = cdlViewer.FontUnderline
  .SelItalic = cdlViewer.FontItalic
  .SelBold = cdlViewer.FontBold
  .SelStrikeThru = cdlViewer.FontStrikethru
End With
The Sel* properties only apply to text in the RTB that are currently highlighted and calling them when there's no text highlighted has no effect. You can simulate text being selected by using SelStart and SelLength.
 

sunny

meh.
Joined
Jul 7, 2002
Messages
5,352
Gender
Male
HSC
2002
Yep. SelStart will start the selection before the first character (so that the first character will be selected), and SelLength selects text of length x starting from SelStart. Since we want to select everything that is in the box, we use SelLength = Len(rtbDisplay.txt) to get everything from start to end.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top