Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: tushar Kanvinde
  Where is tushar Kanvinde?
 Kolhapur, Maharastra
 India
 tushar Kanvinde
 To: Cetin Basoz
  Where is Cetin Basoz?
 Izmir
 Turkey
 Cetin Basoz
 Tags
Subject: RE: Run time Code
Thread ID: 143212 Message ID: 143274 # Views: 1 # Ratings: 0
Version: Visual FoxPro 9 Category: Forms
Date: Monday, August 27, 2007 12:21:07 PM         
   


> > I am creating a number of text Boxes at run time using "AddOBJECT". Each Textbox has a different name. How do I dynamically add a few lines of code to the click event of each textbox. The code will be different fof each textbox and may many lnes of code. Can I do that? Please give me an example.
> >
> > Thanks in advance;
> >
> > Paul D'Anna
>
> Like Mike noted,
> It's generally not needed.
> Anyway if you really need it write your class code at runtime to a file, compile (VFP6 SP3 and later) and newobject() from there.
> BindEvent() would work the same way.
>
> For example (not tested):
>
>
text to myText1 noshow
> define class myTextBox1 as Textbox
>  procedure click
>    messagebox("Are you sure that you need to create me at runtime?")
>  endproc
> enddefine
> define class myTextBox2 as Textbox
>  procedure click
>    messagebox("Oh well. Here we go.")
>  endproc
> enddefine
> endtext
> 
> lcTemp = forcepath(sys(2015)+'.prg', sys(2023))
> StrToFile(m.myText1, m.lcTemp)
> compile (m.lcTemp)
> thisform.newObject('myNewTextBox1', m.lcTemp)
> thisform.newObject('myNewTextBox2', m.lcTemp)
> erase (forceext(m.lcTemp,'*'))

>
> Cetin Basoz

Cetin

I think the erase will have to happen after the objects are released.

Regards
Tushar

ENTIRE THREAD

Run time Code Posted by Paul D'Anna @ 8/26/2007 5:21:49 AM
RE: Run time Code Posted by tushar @ 8/26/2007 8:05:45 AM
RE: Run time Code Posted by Paul D'Anna @ 8/26/2007 12:41:10 PM
RE: Run time Code Posted by tushar @ 8/26/2007 3:27:41 PM
RE: Run time Code Posted by Mike Yearwood @ 8/26/2007 9:05:58 PM
RE: Run time Code Posted by Cetin Basoz @ 8/27/2007 11:58:03 AM
RE: Run time Code Posted by tushar @ 8/27/2007 12:21:07 PM
RE: Run time Code Posted by Cetin Basoz @ 8/27/2007 12:59:11 PM