Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Adding objects
Message
De
07/04/2003 23:35:21
Gerry Schmitz
GHS Automation Inc.
Calgary, Alberta, Canada
 
 
À
07/04/2003 17:28:13
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Titre:
Divers
Thread ID:
00774920
Message ID:
00774991
Vues:
20
>I have been trying to add command buttons to a form on the fly. I have the command button names in a table and want the form to create the buttons.
>Problem: How do I tell the click event what I want it to do. I am trying to do this inside the form and it will not allow me to set information to the click. Any ideas?

Try this:
   o1 = CREATEOBJECT( "Form" )

   o1.AddObject( "cmd1", "My_Button" )
   o1.AddObject( "cmd2", "My_Button" )

   o1.cmd1.Caption = "Move"
   o1.cmd1.C_Script = ;
      "LPARAMETERS PO_Sender" + CHR( 10 ) + ;
      "PO_Sender.Top = PO_Sender.Top + 10" + CHR( 10 ) + ;
      "PO_Sender.Left = PO_Sender.Left + 10"

   o1.cmd2.Top = 20
   o1.cmd2.Caption = "Exit"
   o1.cmd2.C_Script = ;
      "LPARAMETERS PO_Sender" + CHR( 10 ) + ;
      "IF MESSAGEBOX( 'Are you sure ?', 4 ) = 6" + CHR( 10 ) + ;
         "CLEAR EVENTS" + CHR( 10 ) + ;
      "ENDIF"

   o1.Show()

   READ EVENTS

DEFINE CLASS My_Button AS CommandButton
   Visible = .T.
   C_Script = ""
PROCEDURE Click
   WITH THIS
      IF !EMPTY( .C_Script )
         = EXECSCRIPT( .C_Script, THISFORM )
      ENDIF
   ENDWITH
ENDDEFINE
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform