Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Problem with BindEvents
Message
De
21/03/2003 15:30:19
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00768729
Message ID:
00768758
Vues:
18
>Thanks for that tip which gets me a little closer with the following code. The next problem is I have to be able to fire the DoForm method whan ANY object on the running form is RightClicked including lables, command buttons and anything else that would have a caption.
>RELEASE ALL
>CLEAR ALL
>PUBLIC oForm1, oForm2, oTranslate
>oForm1 = CREATEOBJECT('frmRunningForm')
>oForm2 = CREATEOBJECT('frmTranslator')
>oTranslate = CREATEOBJECT('Translate')
>oForm1.Show()
>BINDEVENT(_screen.ActiveForm, [MouseMove], oTranslate, [NewBindEvent])
>RETURN
>
>DEFINE CLASS Translate AS Custom
>
>   lBound = .F.
>
>   PROCEDURE DoForm
>      oForm2.Show()
>   ENDPROC
>   PROCEDURE NewBindEvent
>      LPARAMETERS uParm1, uParm2, uParm3, uParm4, uParm5, uParm6
>      IF TYPE("_screen.ActiveForm.ActiveControl") = [O]
>         BINDEVENT(_screen.ActiveForm.ActiveControl, [RightClick], oTranslate, [DoForm])
>         THIS.lBound = .T.
>      ELSE
>         IF THIS.lBound
>            UNBINDEVENT(_screen.ActiveForm.ActiveControl, [RightClick], oTranslate, [DoForm])
>            THIS.lBound = .F.
>         ENDIF
>      ENDIF
>   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.
>   Closable = .F.
>
>   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
>
I've always dealt with something that has to have control over everything like that by putting a transparent shape object over top of everything and passing and clicks, etc., to the control under the shape as needed. I don't have access to any example code for that at the moment, but that's probably a lot easier than trying to bind to everything at runtime.
Fred
Microsoft Visual FoxPro MVP

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

Click here to load this message in the networking platform