That is a good idea!
I'm going to try it and let you know
Thank you
Rafael Copquin

El 11/12/2013 11:12, Thierry Nivelet escribió:
Rafael,
You might want to try using BindEvent() ...

modify command cmgBindEvent

* ======================================

local o as cmgBindEvent
o = CreateObject('cmgBindEvent', 5)
o.Buttons[2].click
o.Buttons[3].click

* ======================================
define class cmgBindEvent as CommandGroup

* -------------------------------
procedure Init(nButton as Integer) as Boolean

this.ButtonCount = Evl(m.nButton, 0)
if this.ButtonCount > 0

    local iButton as Integer
    for iButton = 1 to m.this.ButtonCount
        BindEvent(;
              m.this.Buttons(m.iButton);
            , 'Click';
            , m.this;
            , 'btnClick'; && see below
            )
    endfor
endif
endproc

* -------------------------------
procedure btnClick as Boolean && this.Buttons.Click() delegate

if m.this.ButtonCount > 0

    local laEvent[1];
    , oButton as CommandButton;
    , iButton as Integer

    AEvents(laEvent, 0)
    oButton = laEvent[1]

    for iButton = 1 to m.this.ButtonCount
        if m.this.Buttons[m.iButton] = m.oButton
            MessageBox(Textmerge([Button # <<m.iButton>> was clicked!]))
            do case
            case m.iButton = 1
            case m.iButton = 2
            * ...
            case m.iButton = 9
            endcase
            return
        endif
    endfor
endif

endproc

enddefine
* ======================================



Thierry Nivelet
FoxInCloud
Give your VFP app a second life in the cloud
http://foxincloud.com/

Le 10/12/13 21:36, Rafael Copquin a écrit :
I am creating a class that adds a commandgroup to a form, with a quantity of buttons and their captions that are given to the class as parameters.

However, I also want to send the code the click events of the buttons should fire

I would put the code in an array or a string and send it to the class.
Then the class would create the command group with as many buttons as sent as parameters and the class would then read the array or the string with the commands and place those commands in the click events of the buttons.

Like

cCommands= [do form one,do form two, do form three,.......]

for i = 1 to nButtonsQty

        click event of command i

                 getwordnum(cCommands,i,[,])
endfor


Since the number of buttons varies the class does not know what code to put in the click events of the buttons.

I thought about the writemethod, which I never used, but am very confused on how to use it I read the Hacker's guide but the light it shed seems to be black light, because I can't make any sense of it.

Can anyone help on this?

Rafael Copquin




[excessive quoting removed by server]

_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: 
http://leafe.com/archives/byMID/profox/[email protected]
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to