Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Moving an object around
Message
 
To
25/03/2004 10:08:44
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00889390
Message ID:
00889609
Views:
15
>
>Another quest if I may, in creating a form programmatically using:
>"frmMyForm = CREATEOBJECT('Form')",
>

>
>
>How does one get access to the methods of the form itself like you do for the objects on the form?
>

>
>This is a encrypted english for me.
>
>- Get access for write code or for execute the code ?
>
>Sorry but i have not understood.



In other words, from the example below where a form is created programatically, you see where the classes are defined for each object? You can access these objects methods like the click event by saying "Procedure click" and below it typing what you want in the click event. But how do you do this for the form itself?


frmMyForm = CREATEOBJECT('Form') && Create a Form
frmMyForm.Closable = .F. && Disable the Control menu box

frmMyForm.AddObject('cmdCommand1','cmdMyCmndBtn') && Add Command button
frmMyForm.AddObject('opgOptionGroup1','opgMyOptGrp') && Add Option Group
frmMyForm.AddObject('shpCircle1','shpMyCircle') && Add Circle Shape
frmMyForm.AddObject('shpEllipse1','shpMyEllipse') && Add Ellipse Shape
frmMyForm.AddObject('shpSquare','shpMySquare') && Add Box Shape

frmMyForm.cmdCommand1.Visible =.T. && "Quit" Command button visible

frmMyForm.opgOptionGroup1.Buttons(1).Caption = "\frmMyForm.opgOptionGroup1.Buttons(2).Caption = "\frmMyForm.opgOptionGroup1.Buttons(3).Caption = "\frmMyForm.opgOptionGroup1.SetAll("Width", 100) && Set Option group width
frmMyForm.opgOptionGroup1.Visible = .T. && Option Group visible
frmMyForm.opgOptionGroup1.Click && Show the circle

frmMyForm.SHOW && Display the form
READ EVENTS && Start event processing

DEFINE CLASS opgMyOptGrp AS OptionGroup && Create an Option Group
ButtonCount = 3 && Three Option buttons
Top = 10
Left = 10
Height = 75
Width = 100

PROCEDURE Click
ThisForm.shpCircle1.Visible = .F. && Hide the circle
ThisForm.shpEllipse1.Visible = .F. && Hide the ellipse
ThisForm.shpSquare.Visible = .F. && Hide the square

DO CASE
CASE ThisForm.opgOptionGroup1.Value = 1
ThisForm.shpCircle1.Visible = .T. && Show the circle
CASE ThisForm.opgOptionGroup1.Value = 2
ThisForm.shpEllipse1.Visible = .T. && Show the ellipse
CASE ThisForm.opgOptionGroup1.Value = 3
ThisForm.shpSquare.Visible = .T. && Show the square
ENDCASE
ENDDEFINE

DEFINE CLASS cmdMyCmndBtn AS CommandButton && Create Command button
Caption = '\ Cancel = .T. && Default Cancel Command button (Esc)
Left = 125 && Command button column
Top = 210 && Command button row
Height = 25 && Command button height

PROCEDURE Click
CLEAR EVENTS && Stop event processing, close Form
ENDDEFINE

DEFINE CLASS shpMyCircle AS Shape && Create a circle
Top = 10
Left = 200
Width = 100
Height = 100
Curvature = 99
BackColor = RGB(255,0,0) && Red
ENDDEFINE

DEFINE CLASS shpMyEllipse AS Shape && Create an ellipse
Top = 35
Left = 200
Width = 100
Height = 50
Curvature = 99
BackColor = RGB(0,128,0) && Green
ENDDEFINE

DEFINE CLASS shpMySquare AS Shape && Create a square
Top = 10
Left = 200
Width = 100
Height = 100
Curvature = 0
BackColor = RGB(0,0,255) && Blue
ENDDEFINE
"Build a man a fire, and he's warm for a day.
Set a man on fire, and he's warm for the rest of his life."
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform