modify the click event during execution 
Author Message
 modify the click event during execution

hello everybody,

I'm able to create labels during execution with the
thisform.addobject("label1",'label') statement.

What i am trying to do is during execution declare the click event something
like Thisform.label1.click="do form(home(), 'test.scx') with
substr(thisform.label&y, 5,3), so i can execute a form with a specific
record number from a database.

Everytime i get a message like click is a readonly property and can't be
modified.

Does anybody know how to get aroung this problem???

John van den Heuvel





Thu, 30 Oct 2003 20:31:55 GMT  
 modify the click event during execution
Sorry, no go for this one. You must either subclass the label and type the
proper code in the Click event or you must manually add the label to the
form in designtime and code the click event there. If you have more than one
Click events that you want to fire, you must use a DO CASE - ENDCASE or IF -
ENDIF switch in the Click event.
--
Eric den Doop
www.foxite.com - The Home Of The Visual FoxPro Experts



Quote:

> hello everybody,

> I'm able to create labels during execution with the
> thisform.addobject("label1",'label') statement.

> What i am trying to do is during execution declare the click event
something
> like Thisform.label1.click="do form(home(), 'test.scx') with
> substr(thisform.label&y, 5,3), so i can execute a form with a specific
> record number from a database.

> Everytime i get a message like click is a readonly property and can't be
> modified.

> Does anybody know how to get aroung this problem???

> John van den Heuvel





Thu, 30 Oct 2003 21:38:56 GMT  
 modify the click event during execution
I've kind of lost him on this one also.  Why would you want to modify code "on
the fly" in a situation like that.  You can just use a do case and run the
appropriate methods which can be coded at design time.  However, it is possible
to compile prg code "on the fly" but it doesn't sound like his situation would
need that.  Seems like a few do cases with some methods should be just fine.

Regards,

Quote:
>Subject: Re: modify the click event during execution

>Date: 5/13/2001 6:38 AM Pacific Daylight Time

>Sorry, no go for this one. You must either subclass the label and type the
>proper code in the Click event or you must manually add the label to the
>form in designtime and code the click event there. If you have more than one
>Click events that you want to fire, you must use a DO CASE - ENDCASE or IF -
>ENDIF switch in the Click event.
>--
>Eric den Doop
>www.foxite.com - The Home Of The Visual FoxPro Experts

Mike


Fri, 31 Oct 2003 05:40:24 GMT  
 modify the click event during execution

Quote:
> I'm able to create labels during execution with the
> thisform.addobject("label1",'label') statement.

> What i am trying to do is during execution declare the click event
> something
> like Thisform.label1.click="do form(home(), 'test.scx') with
> substr(thisform.label&y, 5,3), so i can execute a form with a specific
> record number from a database.

> Everytime i get a message like click is a readonly property and can't be
> modified.

> Does anybody know how to get aroung this problem???

John --

I agree with others that you probably don't really need to modify the
code on the fly; there's probably a better way to do it by putting some
context-sensitive code in the click method. For example, the click
method could be:
**************
labelNumber = VAL(SUBSTR(this.name,6))
do form WITH m.labelNumber
**************

However, there IS a way to do something much like what you ask for. To
your control class, add a property called "clickCode". In the click
method put:
**************
IF NOT EMPTY(THIS.clickCode)
   command = THIS.clickCode
   &command
ENDIF
**************

Somewhere else, generate the code needed and store it in the clickCode
property.

If you need to execute multiple lines of code, you can loop through the
MLINE()s and execute one at a time, or if you need to be able to handle
structured commands like IF/ENDIF you can use Randy Pearson's CodeBlck
(look for it on the Universal Thread).

Hope this helps,
- Neil



Fri, 31 Oct 2003 07:17:55 GMT  
 modify the click event during execution
One way to do this is by using macro substitution.
Something like this:

  In whatever method should be "modifying" the click event:

  ThisForm.cmdMyButton.Tag = "do form(home(), 'test.scx') "+ ;
    "with substr(thisform.label"+ALLTRIM(y)+", 5,3)"

  Then in the click code for that button:

   LOCAL lcMyCode

   IF !EMPTY(This.Tag)
     lcMyCode = ALLTRIM(This.Tag)
     &lcMyCode
     This.Tag = ""
   ENDIF

This would allow you to slap any code (within reason) into
the button's click event.

-- TRW


Quote:

> hello everybody,

> I'm able to create labels during execution with the
> thisform.addobject("label1",'label') statement.

> What i am trying to do is during execution declare the click event something
> like Thisform.label1.click="do form(home(), 'test.scx') with
> substr(thisform.label&y, 5,3), so i can execute a form with a specific
> record number from a database.

> Everytime i get a message like click is a readonly property and can't be
> modified.

> Does anybody know how to get aroung this problem???

> John van den Heuvel



--
_______________________________________
My e-mail:  t r w 7

_______________________________________


Fri, 31 Oct 2003 22:42:39 GMT  
 modify the click event during execution
You might also subclass the command button and add a custom property to it,
and in the code have it use the property as the form name which you can set
at runtime.

--
Cy Welch
Senior Programmer
MetSYS Inc
http://metsys.metsysinc.com

Quote:
> I've kind of lost him on this one also.  Why would you want to modify code
"on
> the fly" in a situation like that.  You can just use a do case and run the
> appropriate methods which can be coded at design time.  However, it is
possible
> to compile prg code "on the fly" but it doesn't sound like his situation
would
> need that.  Seems like a few do cases with some methods should be just
fine.

> Regards,

> >Subject: Re: modify the click event during execution

> >Date: 5/13/2001 6:38 AM Pacific Daylight Time

> >Sorry, no go for this one. You must either subclass the label and type
the
> >proper code in the Click event or you must manually add the label to the
> >form in designtime and code the click event there. If you have more than
one
> >Click events that you want to fire, you must use a DO CASE - ENDCASE or
IF -
> >ENDIF switch in the Click event.
> >--
> >Eric den Doop
> >www.foxite.com - The Home Of The Visual FoxPro Experts

> Mike



Sat, 01 Nov 2003 05:42:06 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. modifying click events

2. modifying click events

3. Adding a field during execution without setup

4. Memorizing form configuration during program execution

5. Creating textboxes during program execution

6. Stop click event executing on double click

7. DODEFAULT() - VFP events VS. Method execution VS. Scope Resolution

8. - How to prevent keyboard events from interrupting execution?

9. HELP: Interesting CHANGE in EVENT SEQUENCE execution !!

10. Override tab during keypress event (VFP5.0)

11. timer event does not fire during query

12. events not firing - during typeahead

 

 
Powered by phpBB® Forum Software