Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Click procedure for programmatically created command but
Message
De
01/10/1999 13:45:41
 
 
À
01/10/1999 09:47:21
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00271497
Message ID:
00271658
Vues:
16
>I have been able to programmatically (init within a form) create and display command buttons from table data with the following suggested code:
>
>table ttype
>lncount = 0
>lnaddcount = 0
>lntop = 4
>lnleft = 20
>scan
> lncount = lncount + 1
> lnaddcount = lnaddcount + 1
> cmdbutton = 'cmdprod' + alltrim(str(lnaddcount))
> thisform.Addobject(cmdbutton, "Commandbutton")
> with eval("thisform." + cmdbutton)
> .visible = .t.
> .caption = alltrim(ttype.type)
> .top = lntop
> .height = 5
> .left = lnleft
> .width = 25
> endwith
> if lncount = 4
> lncount = 0
> lntop = lntop + 7
> lnleft = 20
> else
> lnleft = lnleft + 35
> endif
>endscan
>
>The buttons display on the form, but I have not been able to successfully assign a click procedure to each button. Clicking on a button does nothing. Any help or coding suggestions will be appreciated.

Somewhere in your code, probably at the bottom, you would define your own class of button:

DEFINE CLASS myButton AS commandbutton
FUNCTION Click
MessageBox('My Command Button has been clicked!')
ENDFUNC
ENDDEFINE

Then you would use your new command button class instead of the base class:

thisform.Addobject(cmdbutton, "myButton")
Fred
Microsoft Visual FoxPro MVP

foxcentral.net
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform