>Hi,
>
>Problem: I want to dynamically add a number of n Labels on a form and each label has to do something when I press the rightclick on each of them.
>
>So I wrote a program (myclass.prg) in which I defined a class called MyLabel:
>
>DEFINE CLASS MyLabel AS Label
>
> PROCEDURE RightClick
> MESSAGEBOX('rightclick')
> ENDPROC
>
>ENDDEFINE
>
>(I've written the class definition inside a *.prg file because I saw that I can't write a class definition inside a buttonclick event procedure for example.)
>
>In the Load procedure of the form I call the myclass.prg file:
>
>DO myclass
>
>When I press a button on the form I want to add the labels.Button click procedure looks like:
>
>n=10
>for i=1 to n
> name = 'lab'+ALLTRIM(str(i))
> thisform.AddObject(name,'MyLabel')
>endfor
>
>The problem is that I get an error "Class definition MyLabel is not found" when I run the application.
>
>Can someone, please, tell me what is wrong or give me another ideea
>
>Thanks
Do myClass
Has no effect. It runs the prg, doesn't encounter any commands to execute and returns.
for i=1 to 10
name = 'lab'+ALLTRIM(str(i))
thisform.NewObject(m.name,'MyLabel','MyClass.prg')
with eval('thisform.'+m.name)
.Visible = .t.
endwith
endfor
Cetin