Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Problem with BindEvents
Message
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Problem with BindEvents
Divers
Thread ID:
00768729
Message ID:
00768729
Vues:
54
Using VFP 8 RTM. You can BINDEVENT to _screen.ActiveForm but not to _screen.ActiveForm.ActiveControl. Here is code to reproduce this, just change the value of llTest to .F. to get the error. Why is this? Anyone know how to get this to work so the second form comes up when you RightClick on an object in the first form? This has to be done in this context because the first form has to be running [DO FORM] and not being edited [MODIFY FORM]. The reason is to use a builder [the 2nd form] to dynamically set properties for the object that was RightClicked on the running form. A reference to the object on the first form is also needed by the second form. TIA!
LOCAL llTest1
llTest1 = .T.
PRIVATE oForm1, oForm2, oTranslate
oForm1 = CREATEOBJECT('frmRunningForm')
oForm2 = CREATEOBJECT('frmTranslator')
oTranslate = CREATEOBJECT('Translate')
oForm1.Show()
IF llTest1
   BINDEVENT(_screen.ActiveForm, [RightClick], oTranslate, [DoForm])
ELSE
   BINDEVENT(_screen.ActiveForm.ActiveControl, [RightClick], oTranslate, [DoForm])
ENDIF
READ EVENTS
oForm1 = .null.
oForm2 = .null.
oTranslate = .null.
RETURN

DEFINE CLASS Translate AS Custom
   PROCEDURE DoForm
      oForm2.Show()
   ENDPROC
ENDDEFINE
DEFINE CLASS frmRunningForm AS form

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

   ADD OBJECT label1 AS label WITH ;
      AutoSize = .T., ;
      Caption = "RightClick on This Label", ;
      Height = 17, ;
      Left = 84, ;
      Top = 45, ;
      Width = 136, ;
      TabIndex = 1, ;
      Name = "Label1"

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

   ADD OBJECT text1 AS textbox WITH ;
      Height = 23, ;
      Left = 94, ;
      TabIndex = 2, ;
      Top = 75, ;
      Width = 100, ;
      Name = "Text1"

   PROCEDURE cmdExit.Click
      THISFORM.Release()
   ENDPROC
   PROCEDURE Destroy
      CLEAR EVENTS
   ENDPROC
ENDDEFINE
DEFINE CLASS frmTranslator AS form

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

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

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

Click here to load this message in the networking platform