Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Problem with BindEvents
Message
 
 
À
21/03/2003 17:05:39
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00768729
Message ID:
00768823
Vues:
17
Here's code that puts a hundred labels on the form, and it performs fine for me
PUBLIC oForm1, oForm2, oTranslate
oForm1 = CREATEOBJECT('frmRunningForm')
oForm2 = CREATEOBJECT('frmTranslator')
oTranslate = CREATEOBJECT('Translate')
oForm1.Show()
LOCAL loObject
FOR EACH loObject IN _Screen.ActiveForm.Objects
   BINDEVENT(loObject, [RightClick], oTranslate, [DoForm])
ENDFOR
RETURN

DEFINE CLASS Translate AS Custom

   PROCEDURE DoForm
      AMOUSEOBJ(laObject, 1)
      loObj = laObject(1)
      oForm2.txtName.Value = loObj.Name
      oForm2.Show()
   ENDPROC
ENDDEFINE

DEFINE CLASS frmRunningForm AS form

   Caption = "Running Form"
   Name = "frmRunningForm"
   Top = 0
   Left = 0
   Width = 620

   ADD OBJECT cmdExit AS commandbutton WITH ;
      Top = 1, ;
      Left = 1, ;
      Height = 27, ;
      Width = 84, ;
      Caption = "Exit", ;
      TabIndex = 3, ;
      Name = "cmdExit"

   PROCEDURE cmdExit.Click
      THISFORM.Release()
   ENDPROC
   PROCEDURE Init
      lnTop = 1
      lnLeft = 1
      FOR lnI = 1 TO 100
         THIS.AddObject([Label_] + TRANSFORM(lnI), [Label])
         loLabel = EVALUATE([THIS.Label_] + TRANSFORM(lnI))
         WITH loLabel
            .Caption = [Label_] + TRANSFORM(lnI)
            .AutoSize = .t.
            IF lnTop = 1
               .Top = lnTop * 30
            ELSE
               .Top = (lnTop * 20) + 10
            ENDIF
            .Left = lnLeft
            .Visible = .T.
         ENDWITH
         lnTop = lnTop + 1
         IF MOD(lnI,10) = 0
            lnTop = 1
            lnLeft = lnLeft + 60
         ENDIF
      ENDFOR
   PROCEDURE Destroy
      CLEAR EVENTS
   ENDPROC
ENDDEFINE
DEFINE CLASS frmTranslator AS form

   Caption = "Translator Form"
   Name = "frmTranslator"
   AutoCenter = .T.
   Closable = .F.

   ADD OBJECT txtName as textbox WITH ;
      TOP = 10, ;
      LEFT = 10, ;
      WIDTH = 100, ;
      HEIGHT = 24, ;
      NAME = "txtName"

   ADD OBJECT cmdExit AS commandbutton WITH ;
      Top = 139, ;
      Left = 154, ;
      Height = 27, ;
      Width = 84, ;
      Default = .T., ;
      Caption = "Exit", ;
      Name = "cmdExit"

   PROCEDURE cmdExit.Click
      THISFORM.Hide()
   ENDPROC
ENDDEFINE
Mark McCasland
Midlothian, TX USA
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform