Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
MyLabel
Message
De
27/04/2005 04:09:31
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
27/04/2005 03:12:11
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Titre:
Divers
Thread ID:
01008730
Message ID:
01008743
Vues:
19
>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') 
* Do not forget to set visible=.t.
* ie: 
with eval('thisform.'+m.name)
 .Visible = .t.
endwith
endfor
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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform