*- Form1.Command1.Click() > >WITH This > DO CASE > CASE .Caption = "One" > .Caption = "Two" > iTargetX = ThisForm.Text1.Top > iTargetY = ThisForm.Text1.Left > CASE .Caption = "Two" > .Caption = "Three" > iTargetX = ThisForm.Text2.Top > iTargetY = ThisForm.Text2.Left > OTHERWISE > *- Must be Three so set back to "One". > .Caption = "One" > iTargetX = ThisForm.Text3.Top > iTargetY = ThisForm.Text3.Left > ENDCASE >ENDWITH > >MOUSE AT iTargetX / 15, iTargetY / 5 ; > WINDOW (ThisForm.Caption) > >RETURN .T.
************************************************** *-- Form: form1 (d:\prg\test\form1.scx) *-- ParentClass: form *-- BaseClass: form * DEFINE CLASS form1 AS form DataSession = 1 Top = 0 Left = 0 Height = 295 Width = 434 DoCreate = .T. Caption = "Form1" Name = "Form1" ADD OBJECT command1 AS commandbutton WITH ; Top = 240, ; Left = 312, ; Height = 27, ; Width = 84, ; Caption = "1", ; Name = "Command1" ADD OBJECT text1 AS textbox WITH ; Value = "text1", ; Height = 23, ; Left = 12, ; Top = 24, ; Width = 100, ; Name = "Text1" ADD OBJECT text2 AS textbox WITH ; Value = "text2", ; Height = 23, ; Left = 12, ; Top = 72, ; Width = 100, ; Name = "Text2" ADD OBJECT text3 AS textbox WITH ; Value = "text3", ; Height = 23, ; Left = 12, ; Top = 120, ; Width = 100, ; Name = "Text3" PROCEDURE command1.Click LOCAL loObject, lnLeft,lnTop, lcName loObject = EVAL("thisform.text" + this.caption) && get the object reference to the desired control lnLeft = OBJTOCLIENT(loObject, 2) && 2 - left lnTop = OBJTOCLIENT(loObject, 1) && 1 - top this.caption = IIF(this.caption = "1", "2", IIF(this.caption = "2", "3", "1")) && change caption after each click lcName = thisform.name thisform.name = SYS(2015) && There is the bug in WINDOW clause if you have multiple instances of the same form MOUSE AT lnTop, lnLeft WINDOW (WONTOP()) PIXELS thisform.Name = lcName ENDPROC ENDDEFINE * *-- EndDefine: form1 **************************************************