Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Simulating RightClick in RTF Box control
Message
From
31/08/2006 08:32:02
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
30/08/2006 18:10:27
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
General information
Forum:
Visual FoxPro
Category:
ActiveX controls in VFP
Environment versions
Visual FoxPro:
VFP 9 SP1
Miscellaneous
Thread ID:
01150005
Message ID:
01150107
Views:
37
>RTF Box has no rightclick method. The MSDN article on .click says "To distinguish between the left, right, and middle mouse buttons, use the MouseDown and MouseUp events". So I tried to do it in the .MouseUp - and it says the parameters are _MouseUp([index As Integer,]button As Integer, shift As Integer, x As Single, y As Single)... where index is there if the control is a member of a control array. So far so good - adding the code to my RTF class, VFP dutifully filled in the "Lparameters Button, Shift, x, Y" line. So far so good.
>
>The problem is that no parameters get passed, none at all. All four are .f.
>
>Any ideas?
>
>Update: while it doesn't work as specified, I managed to have it pass parameters to a bindevent()ed method in the form. Go figure.
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
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