Aracılığıyla paylaş


Rotation Property (Visual FoxPro)

Specifies a number of degrees to rotate a control in a counterclockwise direction. Read/write at design time and run time.

Control.Rotation [= nValue]

Return Value

  • nValue
    Specifies 0 to 360 degrees of rotation for a control. The default setting is 0.

Remarks

Applies To: Label Control (Visual FoxPro) | Line Control | Shape Control

Clarity of the text can vary depending on the font and font size specified. For example, small font sizes appear best set at 0-, 90-, or 180-degrees.

For Label controls, the following functionality applies when setting Rotation:

  • Rotation works only with TrueType fonts. Certain font settings such as FontStrikethru might not display properly at certain angles.

  • Rotation is not supported when the Style property is set to 3 (Themed) because the label text is drawn by the theme. For more information, see Style Property.

  • When aligning text in the label, the Alignment property is respected only when Rotation is set to 0. Otherwise, the label is centered then rotated. For more information, see Alignment Property.

  • The WordWrap property is supported only when Rotation is set to 0. In other words, if Rotation is set to a value other than 0, no wordwrapping occurs even if WordWrap is to True (.T.). For more information, see WordWrap Property.

  • The AutoSize property does not resize the control based on the Rotation setting. Text is always centered in the label. Therefore, it is recommended that you make sure the label is large enough to accommodate for any rotation position. For more information, see AutoSize Property.

  • Hotkeys (\<) specified in the Caption property do not display, though they remain functional, when labels are rotated. For more information, see Caption Property (Visual FoxPro).

For Shape and Line controls, the following functionality applies when setting Rotation:

  • Rotation applies when drawing polygon shapes and lines created by the PolyPoints property. For more information, see PolyPoints Property.

  • The control rotates around its center axis.

Example

The following example creates a form and adds a label and two command buttons based on custom classes. The Rotation property is set each time you click the Rotate command button, which rotates the label.

The following lines of code use the CREATEOBJECT( ) function to create a form and the AddObject method to add a Label control and two custom command buttons to the form. The Visible property is then set to True (.T.) for the label and the command buttons so they display on the form. The Show method displays the form and the READ EVENTS command begins event processing. The DEFINE CLASS command defines a custom Label class and CommandButton classes and contains settings for the appropriate properties.

frmMyForm = CREATEOBJECT('Form')
frmMyForm.AddObject('lblLabel1','lblMyLabel')
frmMyForm.AddObject('cmdCmndBtn1','cmdMyCmndBtn1')
frmMyForm.AddObject('cmdCmndBtn2','cmdMyCmndBtn2')
frmMyForm.lblLabel1.Visible = .T.
frmMyForm.cmdCmndBtn1.Visible =.T.
frmMyForm.cmdCmndBtn2.Visible =.T.
frmMyForm.Show
READ EVENTS
DEFINE CLASS lblMyLabel AS Label
   Caption = "MyLabel"
   Left = 150
   Top = 50
   Height = 50
   Width = 50
ENDDEFINE

The class definition for the following command button increments the Rotation property in the Click event every time the button is clicked. When the Rotation property is increased, the label rotates by the specified number of degrees. When the number of degrees totals 360, the Rotation property is reset to 0 so that the label appears in its starting position.

DEFINE CLASS cmdMyCmndBtn1 AS CommandButton
   Caption = '\<Rotate'
   Left = 125
   Top = 150
   Height = 25
   PROCEDURE Click
      ThisForm.lblLabel1.Visible = .F.
      ThisForm.lblLabel1.Rotation = ThisForm.lblLabel1.Rotation + 45
      IF ThisForm.lblLabel1.Rotation = 360
         ThisForm.lblLabel1.Rotation = 0
      ENDIF
      ThisForm.lblLabel1.Visible = .T.
ENDDEFINE

The class definition for the following command button includes the CLEAR EVENTS command in the Click event of the command button to stops event processing and closes the form.

DEFINE CLASS cmdMyCmndBtn2 AS CommandButton
   Caption = '\<Quit'
   Cancel = .T.
   Left = 125
   Top = 200
   Height = 25
   PROCEDURE Click
      CLEAR EVENTS
ENDDEFINE

See Also

Reference

RotateFlip Property

Other Resources

Properties (Visual FoxPro)