Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Using Object Name as Variable
Message
From
10/11/2001 06:13:26
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
10/11/2001 05:48:12
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00580107
Message ID:
00580112
Views:
16
>How can I refeance the object name as a variable?. I have several shapes on my form. I want to loop through them and turn them a diferent color one at a time.
for each oControl in thisform.controls
 if upper(oControl.Baseclass) = 'SHAPE'
* If all shapes from same class
* if upper(oControl.Class) = 'MYCLASS'
   with oControl 
* Do whatever :ie
* .BackColor = myColor(.Name)
   endwith
 endif
endfor
Another simple approach is to use a class with _assign property.
define class myShape as Shape
 ChangeColor=.f.
 Status ='' 
 procedure SetColor
 lparameters tcParam
* Set color based on passed param. ie:
 if this.Status == substr(tcParam,1, at('-',tcParam)-1)  
    this.Backcolor = eval(substr(tcParam,at('-',tcParam)+1))
 endif
endproc
 Procedure ChangeColor_assign
 lparameters vNewVal
 this.SetColor(vNewVal)
 endproc
endproc
enddefine
You could invoke color change of all shpaes from this class by simply calling :
thisform.Setall('ChangeColor','Reserved - rgb(255,0,255)','myShape')
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