Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Use rtf sample
Message
From
15/07/2006 09:36:06
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
General information
Forum:
Visual FoxPro
Category:
ActiveX controls in VFP
Title:
Miscellaneous
Thread ID:
01136615
Message ID:
01136664
Views:
27
>This is a basic question.
>
>I want a form with just an RTF control and the controls above it for font selection, size, color and characteristics.
>
>I see the RTF example in the VFP sample application. I don't know how to make a form with just these items - whatever I tried it always refers back to the sample vcx, which contains lots of other stuff.
>
>Can someone give me a simple step-by-step, or email me with the form?
>
>One other thing - in the sample application, when you select a word and then apply say Bold, it removes the selection indicator. But if you then choose say Italic it acts upon the same selection as before. Can one have the words previously selected again show as selected after applying the Bold, etc.?
>
>Cyril

Cyril,
Below sample, though doesn't show all the capabilities of RTF control, doesn't use any external classes so should be easier to understand.
Public oForm
oForm = Createobject('myForm')
oForm.Show

Define Class myForm As Form
  Height = 400
  Width = 800
  DataSession = 2
  Caption = "RTF sample"

  Add Object myGrid As Grid With ;
    top=0,Left=0,Height=400,Width=200,;
    recordsource='crsEmployee',ColumnCount=2
  Add Object myRTF As OleControl With ;
    OleClass="RICHTEXT.RichTextCtrl.1",;
    Left=210,Top = 10, Height=300,Width=580
  Add Object cmdRTF As CommandGroup With ;
    Left = 210,Top = 320,ButtonCount=5

  Procedure Load
    * Use employee notes as ready sample text source
    Select first_name,last_name,notes,notes As rtfNotes ;
      FROM (_samples+'data\employee') ;
      INTO Cursor crsEmployee ;
      readwrite
  Endproc

  Procedure Init
    With This.cmdRTF && add buttons to RTF button group
      .Buttons(1).Caption = "Toggle Bold"
      .Buttons(2).Caption = "Toggle Italic"
      .Buttons(3).Caption = "Toggle Underline"
      .Buttons(4).Caption = "Font"
      .Buttons(5).Caption = "Color"
      .SetAll('AutoSize',.T.)
      .SetAll("Top",2,'CommandButton')
      For ix = 2 To .ButtonCount
        .Buttons(m.ix).Left = .Buttons(m.ix-1).Left + .Buttons(m.ix-1).Width + 2
      Endfor
      .AutoSize = .T.
    Endwith

    With This.myRTF && Bind RTF controlsource to rtfNotes memo
      .ControlSource = "crsEmployee.rtfNotes"
      .HideSelection = .F. && default .t. hides selection after a SelOperation
    Endwith
  Endproc

  Procedure myGrid.AfterRowColChange
    Lparameters nColindex
    Thisform.Refresh()
  Endproc

  Procedure cmdRTF.Click
    With This.Parent.myRTF
      Do Case
        Case This.Value = 1 && bold
          .SelBold = !.SelBold
        Case This.Value = 2 && italic
          .SelItalic = !.SelItalic
        Case This.Value = 3 && underline
          .SelUnderline = !.SelUnderline
        Case This.Value = 4 && Font
          lcFont = Getfont()
          .SelFontName = Getwordnum(m.lcFont,1,',')
          .SelFontSize = Val(Getwordnum(m.lcFont,2,','))
          .SelBold = ( 'B'$Getwordnum(m.lcFont,3,',') )
          .SelItalic = ( 'I'$Getwordnum(m.lcFont,3,',') )
        Case This.Value = 5 && color
          .SelColor = Getcolor()
      Endcase
    Endwith
  Endproc
Enddefine
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform