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 Procedure myRTF.MouseDown Lparameters Button, Shift, x, Y If m.button = 2 Thisform.RTFShortCut(This) Endif Endproc Procedure RTFShortCut(oRef) Define Popup rtfShCut SHORTCUT Relative From Mrow(),Mcol() Define Bar 1 Of rtfShCut Prompt 'Toggle Bold' Define Bar 2 Of rtfShCut Prompt 'Toggle Italic' Define Bar 3 Of rtfShCut Prompt 'Toggle Underline' On Selection Bar 1 Of rtfShCut oRef.SelBold = !oRef.SelBold On Selection Bar 2 Of rtfShCut oRef.SelItalic = !oRef.SelItalic On Selection Bar 3 Of rtfShCut oRef.SelUnderline = !oRef.SelUnderline Activate Popup rtfShCut Endproc EnddefineCetin