Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Programmatically creating a form with the RTF control
Message
From
13/02/2002 09:54:37
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
ActiveX controls in VFP
Title:
Programmatically creating a form with the RTF control
Miscellaneous
Thread ID:
00619443
Message ID:
00619443
Views:
95
Hi,

I'm trying to programmatically create a form and add a RichTextBox (RTF) control to it. I'm confused because I've seen elsewhere two ways of setting control's attributes:

<Attribute> = <Value> and .Object.<Attribute> = <Value>

Don't know what each of these two ways really do, and when to use each of them (for me should exist only the first one, though!). The question is that having tried both of them could not make the scroll bars to appear. Can anyone help me to understand why they don't show up (and how to make the scroll bars to appear!) and the reason for having both ways to set object's attributes?

TIA,

Fernando

Below is the code fragment I'm using to perform my tests (if you just paste it in a .prg file and DO it, it'll work).
 cRemarks = "For a RichTextBox control with setting 1 (Horizontal), "          + ;
            "2 (Vertical), or 3 (Both), you must set the MultiLine property"   + ;
            " to True. At run time, the Microsoft Windows operating "          + ;
            "environment automatically implements a standard keyboard "        + ;
            "interface to allow navigation in RichTextBox controls with "      + ;
            "the arrow keys (UP ARROW, DOWN ARROW, LEFT ARROW, and RIGHT "     + ;
            "ARROW), the HOME and END keys, and so on. Scroll bars are "       + ;
            "displayed only if the contents of the RichTextBox extend beyond " + ;
            "the control's borders. If ScrollBars is set to False, the "       + ;
            "control won't have scroll bars, regardless of its contents. "     + ;
            "A horizontal scrollbar will appear only when the RightMargin "    + ;
            "property is set to a value that is larger than the width of the " + ;
            "control. (The value can also be equal to, or slightly smaller "   + ;
            "than the width of the control.)"

 oShowRTF = CreateObj ("frmShowRTF")
 oShowRTF.Show ()

 Define Class MyRTFClass as OleControl

 OleClass = "RICHTEXT.RichTextCtrl.1"
 OleLCid  = 1033

* What properties must be set with the .Object.<PropertyName> syntax 
* and what must not, in order to things be properly set up and work 
* as desired ?

 .Object.Appearance       =  1
 .Object.BorderStyle      =  1 
 .Object.BulletIndent     =  5
 .Object.ControlSource    = ""
 .Object.DisabledNoScroll = .F.
 .Object.Enabled          = .T.
 .Object.FileName         = ""
 .Object.HideSelection    = .T.
 .Object.Locked           = .F.
 .Object.MaxLength        =  0
 .Object.MultiLine        = .T.
 .Object.ScrollBars       =  3   && Both horizontal and vertical scroll bars.  
 .Object.TabStop          = .T.
 .Object.Visible          = .T.

  Appearance              =  1
  BorderStyle             =  1 
  BulletIndent            =  5
  ControlSource           = ""
  DisabledNoScroll        = .F.
  Enabled                 = .T.
  FileName                = ""
  HideSelection           = .T.
  Locked                  = .F.
  MaxLength               =  0
  MultiLine               = .T.
  ScrollBars              =  3   && Both horizontal and vertical scroll bars. 
  TabStop                 = .T.
  Visible                 = .T.
         
 EndDefine

 Define Class frmShowRTF as Form

  Top      		=   5
  Left     		=   5
  Height  		= 240
  Width   		= 260
  Name    		= "frmShowRTF"
  Caption 		= "RitchText Control Example"
  AutoCenter 		= .F.
  ShowWindow 		=  0
  BorderStyle		=  2
  Enabled    		= .T.
  WindowType 		=  1 
  BorderStyle		=  3
 
  Add Object oleRTF as MyRTFClass with Top    =   5, ;
                                       Left   =   5, ;
                                       Height = 230, ;
                                       Width  = 250
  Procedure Resize
  
   If ThisForm.Height < 30
      ThisForm.Height = 30
   endif
                  
   ThisForm.oleRTF.Height = Thisform.Height - 10
   ThisForm.oleRTF.Width  = Thisform.Width  - 10

 EndProc

 Procedure Init
  ThisForm.oleRTF.TextRTF = cRemarks
 EndProc

 Procedure Activate

  With ThisForm
       MessageBox ("The question is: 'Why the Scroll Bars do not appear ?'"+ Chr (13) +  Chr (13) + ;
                   "Here are the 'oleRTF.Object' properties:" + Chr (13) + Chr (13) + ;
                   "RightMargin:     " + Chr (9) + lTrim (Str (.oleRTF.Object.RightMargin    )) + Chr (13) + ;
                   "BulletIndent:    " + Chr (9) + lTrim (Str (.oleRTF.Object.BulletIndent   )) + Chr (13) + ;
                   "ScrollBars:      " + Chr (9) + lTrim (Str (.oleRTF.Object.ScrollBars     )) + Chr (13) + ;
                   "MultiLine:       " + Chr (9) + Transform  (.oleRTF.Object.MultiLine       ) + Chr (13) + ;
                   "DisableNoScroll: " + Chr (9) + Transform  (.oleRTF.Object.DisableNoScroll ) + Chr (13) + Chr (13) + ;
                   "And here are the 'oleRTF' properties:"                                      + Chr (13) + Chr (13) + ;
                   "RightMargin:     " + Chr (9) + lTrim (Str (.oleRTF.RightMargin           )) + Chr (13) + ;
                   "BulletIndent:    " + Chr (9) + lTrim (Str (.oleRTF.BulletIndent          )) + Chr (13) + ;
                   "ScrollBars:      " + Chr (9) + lTrim (Str (.oleRTF.ScrollBars            )) + Chr (13) + ;
                   "MultiLine:       " + Chr (9) + Transform  (.oleRTF.MultiLine              ) + Chr (13) + ;
                   "DisableNoScroll: " + Chr (9) + Transform  (.oleRTF.DisableNoScroll        ) )
  EndWith                  

 EndProc

 EndDefine
Next
Reply
Map
View

Click here to load this message in the networking platform