Runtime added Page Methods 
Author Message
 Runtime added Page Methods

I have a form that creates 1 to ???? tabs on a pgframe when the form is
created. I create the pages on the page frame in the init of the form.
Simple stuff.

Since the Pages are created at runtime is there anyway to populate the
methods of the new Pages (click, activate...) with code?

I can change the properties in the init of the form just fine but don't know
if there is a way to add code to the methods.

Are all dynamically created Page methods inaccessable since you created them
at runtime? Somehow that seems to defeat the flexability of adding pages on
the fly.  I guess the same could be said for adding grid columns to a grid
on the fly.

Thanks, Rick



Sun, 23 Feb 2003 22:18:20 GMT  
 Runtime added Page Methods

No way to add code at runtime.


Quote:
> I have a form that creates 1 to ???? tabs on a pgframe when the form is
> created. I create the pages on the page frame in the init of the form.
> Simple stuff.

> Since the Pages are created at runtime is there anyway to populate the
> methods of the new Pages (click, activate...) with code?

> I can change the properties in the init of the form just fine but don't
know
> if there is a way to add code to the methods.

> Are all dynamically created Page methods inaccessable since you created
them
> at runtime? Somehow that seems to defeat the flexability of adding pages
on
> the fly.  I guess the same could be said for adding grid columns to a grid
> on the fly.

> Thanks, Rick



Sun, 23 Feb 2003 23:13:30 GMT  
 Runtime added Page Methods
Guess that will always be in the 'next' version of VFP.

Rick


Quote:

>No way to add code at runtime.



>> I have a form that creates 1 to ???? tabs on a pgframe when the form is
>> created. I create the pages on the page frame in the init of the form.
>> Simple stuff.

>> Since the Pages are created at runtime is there anyway to populate the
>> methods of the new Pages (click, activate...) with code?

>> I can change the properties in the init of the form just fine but don't
>know
>> if there is a way to add code to the methods.

>> Are all dynamically created Page methods inaccessable since you created
>them
>> at runtime? Somehow that seems to defeat the flexability of adding pages
>on
>> the fly.  I guess the same could be said for adding grid columns to a
grid
>> on the fly.

>> Thanks, Rick



Mon, 24 Feb 2003 06:00:12 GMT  
 Runtime added Page Methods


Quote:
> Guess that will always be in the 'next' version of VFP.

> Rick

I doubt it. You wouldn't have the class libraries available to store the
source code as it is in design time, so the code couldn't be compiled.

One of the more popular methods of handling special code in pages (or
optionbuttons) is to set your superclass pageframe.PageCount high - like 50.
Then at design time you can loop through the pages and add the code with the
WriteMethod() method.
At run time, you would just remove the ones you don't want by setting the
PageCount to the desired number.



Mon, 24 Feb 2003 06:26:37 GMT  
 Runtime added Page Methods

We all have been begging the VFP developers to add a ADDMETHOD method to
each object -- perhaps in VFP 7.0 ;-) but until then...

There is a way of doing this in VFP 6.0 SP3 or SP4, but it's a bit tricky.
What you do is create a program that creates a VFP code string  that creates
a page frame and page objects using the DEFINE CLASS structure.

I've needed to use this technique with grid columns since these objects do
not inherit from any other class and are pseudo objects. Pages in a page
frame are the same they don't inherit from any class.

Sample pseudo Code (gives general idea, I doubt this code would run without
some debugging):

#DEFINE CRLF CHR(13) + CHR(10)
LOCAL cCode
cCode = ""
cCode = cCode + "DEFINE CLASS mypgf AS pageframe" + CRLF
cCode = cCode + "ADD OBJECT myPage" + CRLF
cCode = cCode + "ENDDEFINE" + CRLF
cCode = cCode + "DEFINE CLASS myPage AS Page" + CRLF
cCode = cCode + "FUNCTION Activate" + CRLF
cCode = cCode + "MessageBox('I am active!',0,'Active page')" + CRLF
cCode = cCode + "ENDFUNC" + CRLF
cCode = cCode + "ENDDEFINE"

STRTOFILE(cCode, 'MYPAGE.PRG')
COMPILE MYPAGE.PRG

** Now you can use the ADDOBJECT or CREATEOBJECT method and function to
instaniate your page frame objects from the compiled code created from the
cCode code string. You can of course make the cCode any valid VFP commands,
functions or objects, etc.

Like I said it is a bit tricky but it can be done. Question is, is it worth
the work of creating and debugging a VFP code string to be "late compiled".
There is also a performance price as VFP's compiler is indeed fast, but it
still takes time to compile and then instaniate an object. There is also an
annoying thermometer that pops up during the compile.

Anyone who has used the language known as Forth will be familuar with code
that dymically creates code strings, compiles them on the fly and then runs
the code which in turn creates other dynamic code strings, etc., etc. (Leads
to very complicated yet powerful code).

Hope this helps,

Ryan Jentzsch
Computer Software Solutions



Mon, 24 Feb 2003 12:01:59 GMT  
 Runtime added Page Methods
Here's one way to get rid of the "Compiling..." message:

DECLARE INTEGER GetDesktopWindow IN WIN32API
DECLARE INTEGER LockWindowUpdate IN WIN32API INTEGER lnHandle
hWin = GetDeskTopWindow()
LockWindowUpdate(hWin)
COMPILE xyz.prg
LockWindowUpdate(0)

--
Fred


Quote:

> We all have been begging the VFP developers to add a ADDMETHOD method to
> each object -- perhaps in VFP 7.0 ;-) but until then...

> There is a way of doing this in VFP 6.0 SP3 or SP4, but it's a bit tricky.
> What you do is create a program that creates a VFP code string  that
creates
> a page frame and page objects using the DEFINE CLASS structure.

> I've needed to use this technique with grid columns since these objects do
> not inherit from any other class and are pseudo objects. Pages in a page
> frame are the same they don't inherit from any class.

> Sample pseudo Code (gives general idea, I doubt this code would run
without
> some debugging):

> #DEFINE CRLF CHR(13) + CHR(10)
> LOCAL cCode
> cCode = ""
> cCode = cCode + "DEFINE CLASS mypgf AS pageframe" + CRLF
> cCode = cCode + "ADD OBJECT myPage" + CRLF
> cCode = cCode + "ENDDEFINE" + CRLF
> cCode = cCode + "DEFINE CLASS myPage AS Page" + CRLF
> cCode = cCode + "FUNCTION Activate" + CRLF
> cCode = cCode + "MessageBox('I am active!',0,'Active page')" + CRLF
> cCode = cCode + "ENDFUNC" + CRLF
> cCode = cCode + "ENDDEFINE"

> STRTOFILE(cCode, 'MYPAGE.PRG')
> COMPILE MYPAGE.PRG

> ** Now you can use the ADDOBJECT or CREATEOBJECT method and function to
> instaniate your page frame objects from the compiled code created from the
> cCode code string. You can of course make the cCode any valid VFP
commands,
> functions or objects, etc.

> Like I said it is a bit tricky but it can be done. Question is, is it
worth
> the work of creating and debugging a VFP code string to be "late
compiled".
> There is also a performance price as VFP's compiler is indeed fast, but it
> still takes time to compile and then instaniate an object. There is also
an
> annoying thermometer that pops up during the compile.

> Anyone who has used the language known as Forth will be familuar with code
> that dymically creates code strings, compiles them on the fly and then
runs
> the code which in turn creates other dynamic code strings, etc., etc.
(Leads
> to very complicated yet powerful code).

> Hope this helps,

> Ryan Jentzsch
> Computer Software Solutions



Mon, 24 Feb 2003 23:59:25 GMT  
 Runtime added Page Methods
Perfect.  This is what I was looking for and it will work perfectly with how
I dynamically create 1 to ??? pgf pages in my form's init.  It will be
possible to store different activate methods for all my pages in a table and
just 'append' the appropriate ones when I create the form.

Thanks,  Rick

Quote:

>We all have been begging the VFP developers to add a ADDMETHOD method to
>each object -- perhaps in VFP 7.0 ;-) but until then...

>There is a way of doing this in VFP 6.0 SP3 or SP4, but it's a bit tricky.
>What you do is create a program that creates a VFP code string  that
creates
>a page frame and page objects using the DEFINE CLASS structure.

>I've needed to use this technique with grid columns since these objects do
>not inherit from any other class and are pseudo objects. Pages in a page
>frame are the same they don't inherit from any class.

>Sample pseudo Code (gives general idea, I doubt this code would run without
>some debugging):

>#DEFINE CRLF CHR(13) + CHR(10)
>LOCAL cCode
>cCode = ""
>cCode = cCode + "DEFINE CLASS mypgf AS pageframe" + CRLF
>cCode = cCode + "ADD OBJECT myPage" + CRLF
>cCode = cCode + "ENDDEFINE" + CRLF
>cCode = cCode + "DEFINE CLASS myPage AS Page" + CRLF
>cCode = cCode + "FUNCTION Activate" + CRLF
>cCode = cCode + "MessageBox('I am active!',0,'Active page')" + CRLF
>cCode = cCode + "ENDFUNC" + CRLF
>cCode = cCode + "ENDDEFINE"

>STRTOFILE(cCode, 'MYPAGE.PRG')
>COMPILE MYPAGE.PRG

>** Now you can use the ADDOBJECT or CREATEOBJECT method and function to
>instaniate your page frame objects from the compiled code created from the
>cCode code string. You can of course make the cCode any valid VFP commands,
>functions or objects, etc.

>Like I said it is a bit tricky but it can be done. Question is, is it worth
>the work of creating and debugging a VFP code string to be "late compiled".
>There is also a performance price as VFP's compiler is indeed fast, but it
>still takes time to compile and then instaniate an object. There is also an
>annoying thermometer that pops up during the compile.

>Anyone who has used the language known as Forth will be familuar with code
>that dymically creates code strings, compiles them on the fly and then runs
>the code which in turn creates other dynamic code strings, etc., etc.
(Leads
>to very complicated yet powerful code).

>Hope this helps,

>Ryan Jentzsch
>Computer Software Solutions



Sat, 01 Mar 2003 01:32:42 GMT  
 Runtime added Page Methods
This worked perfectly.  Thanks,  Rick
Quote:
>Here's one way to get rid of the "Compiling..." message:

>DECLARE INTEGER GetDesktopWindow IN WIN32API
>DECLARE INTEGER LockWindowUpdate IN WIN32API INTEGER lnHandle
>hWin = GetDeskTopWindow()
>LockWindowUpdate(hWin)
>COMPILE xyz.prg
>LockWindowUpdate(0)
>--
>Fred



Sat, 01 Mar 2003 01:43:47 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. How to add a method at runtime

2. Add Code to a Grid Column Text Valid Method at RunTime

3. add code to method at runtime

4. Adding Pages with Objects to Pageframe at Runtime

5. Add method code to pageframe pages?

6. Can I set a grid method at runtime?

7. Determine an objects properties and methods at runtime

8. Adding Controls to a Form at Runtime

9. Add Field at runtime using variables

10. VFP5 Adding rows to a grid at runtime

11. Using alter table to add new field @ runtime

12. Assigning Event code to columns added to a grid at runtime

 

 
Powered by phpBB® Forum Software