_Screen.AddProperty("oo") _Screen.oo = createobject("ADODB.Connection") _Screen.NewObject("oSH", "ScreenHook") _Screen.oo.Open("DSNConnection","User","Password") _Screen.oo.WillConnect("Something...") DEFINE CLASS ScreenHook AS CUSTOM o = _Screen.oo PROCEDURE o.WillConnect() lparameters pConnectionString, pUserID, pPassword, pOptions, padStatus, ppConnection * * Code to handle the main VFP screen being resized * WAIT WINDOW NOWAIT "Connecting... " + pConnectionString ENDPROC ENDDEFINEStrange, but code runs without errors. WillConnect Event of the ADO Connection object is not fired by ADO. However, you can call that method directly from VFP.
lcObjectPath = "_Screen.ot" _Screen.AddProperty("ot") _Screen.ot = CreateObject("TextBox") _Screen.NewObject("or", "ScreenH") _Screen.ot.Value = "Something" DEFINE CLASS ScreenH AS CUSTOM oRS = eval(lcObjectPath) PROCEDURE oRS.ProgrammaticChange() * * Code to handle the main VFP screen being resized * WAIT WINDOW NOWAIT "!!!!!!!!!!" ENDPROC ENDDEFINEIn above code ProgrammaticChange event of the textbox fired correctly. As you see, you can make such hooks universal by passing an object to them as expression.
>* >* ScreenMethods.PRG >* >* Fred Taylor - ElZorro 4/10/2001 www.elzorro.org >* >* Use the following to modify _SCREEN methods: >* >* For VFP6 & 7: >* >* _SCREEN.NewObject("oSH","ScreenHook","screenmethods.prg") >* >* For VFP3 & 5: >* >* SET PROCEDURE TO screenmethods ADDITIVE >* _SCREEN.AddObject("oSH","ScreenHook") >* >* Any of the main VFP screen methods can be hooked into in this manner. >* A similar technique can also be used to hook methods of grid >* headers, etc., at run-time. >* >DEFINE CLASS ScreenHook AS CUSTOM >oScr = _SCREEN >PROCEDURE oScr.Resize() > * > * Code to handle the main VFP screen being resized > * > WAIT WINDOW NOWAIT TRANSFORM(this.Width)+" "+TRANSFORM(this.Height) >ENDPROC >PROCEDURE oScr.RightClick > * > * Code to do a "shortcut" menu on main VFP screen RightClick > * > DO testmenu.mpr >ENDPROC >ENDDEFINE