Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Programmatically creating method or event procedure
Message
From
22/02/1999 06:16:44
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
22/02/1999 05:39:41
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00189903
Message ID:
00189905
Views:
14
>How to programmatically create method or event procedure of added object?
>I have form. In init event of this form I want add object and set up properties ,metods and events of this object.
>For example, next few lines create command button and set up caption and cancel properties.
>
>THISFORM.ADDOBJECT("cmdCancelBtn",'commandbutton")
>WITH THISFORM.cmdCancelBtn
> .CAPTION="quit"
> .CANCEL=.T.
>ENDWITH
>
>But how can I write, for example, procedure for CLICK event?
>
>Thanks
>
>Maros Klempa
Maros,
You can't do it and you can do it. You can do if it's OK to do on the fly tricks. Event, method code writing needs design time, and also creation time is considered as desing time. You may choose different tricks (not sure it's a trick). One that I find easy :
- Write your class programmatically to a temp file.
- Set procedure to that file.
- Add your object from that file library
ie: Assume you have a form with an edtCode object.
set textmerge on
set textmerge to myfile.prg
\<<thisform.edtCode.value>>
set textmerge to
set textmerge off
set procedure to myfile.prg
thisform.addobject("mytest","mytxtbox")
thisform.mytest.visible = .t.

* edtCode.value at the point you call above method
define class mytxtbox as textbox
  procedure someprocedure
    * Some code
  endproc
enddefine
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