do form shapeclicker && Assuming you have an empty Shapeclicker form for i=1 to 5 && to put 5 object on the form, named Room1 to Room5 shapeclicker.addobject("Room"+alltrim(str(i)), "MyRoom") with eval("shapeclicker.Room"+alltrim(str(i))) && Cascade .Left = (i-1) * 50 .Top = (i-1) * 50 endwith endfor shapeclicker.Setall('Visible',.T.) && Make them visibleThis is the same code for following different style class declarations :
define class MyRoom as container add object "Detector" as MyShape procedure Detector.click && Parent IS Roomn - part of Room class wait window "Clicked "+this.parent.Name timeout 2 endproc enddefine define class MyShape as shape Top=0 Left=0 procedure init with this .borderstyle=0 .backstyle=0 .Height=.Parent.Height && Size itself to parent's size .Width=.Parent.Width endwith endproc enddefine2)
define class MyRoom as container procedure Init this.addobject("Detector", "MyShape") endproc enddefine define class MyShape as shape Top=0 Left=0 procedure init with this .borderstyle=0 .backstyle=0 .Height=.Parent.Height && Size itself to parent's size .Width=.Parent.Width endwith endproc procedure Click && Parent MIGHT BE Roomn - not part of Room class wait window "You clicked "+this.parent.Name timeout 2 with this .Backstyle = 1 .Backcolor = rgb(255,255,0) endwith endproc enddefineSo what's the difference between 'this.addobject' and 'add object' ? Well in first you only 'add' it to room, in second 'subclass' in room :) You should see the difference with these code (just change the MyRoom definition in above 2nd):
define class MyRoom as container add object "Detector" as MyShape procedure Detector.click && Parent IS Roomn - part of Room class wait window "Now You clicked "+this.parent.Name ; timeout 2 * UNCOMMENT following line and retest * dodefault() && Call parent CLASS click code endproc enddefinePS: DoDefault() call might be anywhere in code (before or after wait window here) and as many times as you want depending on when you want it to execute (kinda include).
>do form main
>for i=1 to 5 && to put 5 object on the form, named Room1 to Room5
> main.addobject("Room"+alltrim(str(i)), "MyRoom")
>endforÇ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