_SCREEN.NewObject("oSH","ScreenHook","screenmethods.prg") *!* ScreenMethods *!* ScreenMethods *!* (Updated: 2002.12.29 06:28:17 PM) *!* Namespace: VFP *!* *!* Edit - Find RecentChanges Categories RoadMap [A-F] [G-P] [Q-Z] Random NewTopic Home *!* Search: *!* ScreenMethods is a program by FredTaylor that's been floating around Fox USENET newsgroups for a while. It demonstrates a technique that allows you to assign code to PEMs of _SCREEN, such as Resize. -- WJdeVeas *!* For the historical source and various examples of how to use this, see: *!* http://groups.google.com/groups?sourceid=navclient&q=screenmethods%2Eprg *!* -------------------------------------------------------------------------------- * * ScreenMethods.PRG * * Fred Taylor - ElZorro 4/10/2001 * www.elzorro.org * with thanks to "Michel Roy" roym@jonar.com from the * News Group microsoft.public.fox.programmer.exchange * Subject: Re: Centering Picture in _SCREEN * ( or modifying _SCREEN Methods ) * * 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") * * Most 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 KEYPREVIEW = .T. FUNCTION oScr.CLICK && Works WAIT WINDOW NOWAIT "_SCREEN.Click" ENDFUNC FUNCTION oScr.DBLCLICK && Works * Note that Click fires first! WAIT WINDOW NOWAIT "_SCREEN.DblClick" ENDFUNC PROCEDURE oScr.KEYPRESS && Works LPARAMETERS nKeyCode, nShiftStat ? nKeyCode, nShiftStat ENDPROC PROCEDURE oScr.QUERYUNLOAD NODEFAULT && Hmmm, doesn't work like a form's does. WAIT WINDOW NOWAIT "NOWAITQueryUnload!" ENDPROC PROCEDURE oScr.RESIZE() && Works * * Code to handle the main VFP screen being resized * WAIT WINDOW NOWAIT TRANSFORM(THIS.WIDTH)+" "+TRANSFORM(THIS.HEIGHT) ENDPROC PROCEDURE oScr.RIGHTCLICK && Works * * Code to do a "shortcut" menu on main VFP screen rightclick * this.mymethod() && DO testmenu.mpr ENDPROC *------------------------------- PROCEDURE oScr.MyMethod && Works WAIT WINDOW "my method fired!" ENDPROC ENDDEFINE *!* -------------------------------------------------------------------------------- *!* [NEW] As per a request, how do you know when the _screen is minimized? *!* _Screen.Newobject("sh", "sh", "e:\vfptest\screenmin.prg") DEFINE CLASS sh AS CUSTOM oScr = _SCREEN PROCEDURE INIT IF VARTYPE(_SCREEN.nLastWindowState) <> "N" _SCREEN.ADDPROPERTY("nLastWindowState") ENDIF _SCREEN.nLastWindowState = _SCREEN.WINDOWSTATE ENDPROC PROCEDURE oScr.RESIZE IF THIS.nLastWindowState <> 1 AND THIS.WINDOWSTATE = 1 _SCREEN.CAPTION = "Minimized" ELSE _SCREEN.CAPTION = "VFP" ENDIF THIS.nLastWindowState = THIS.WINDOWSTATE ENDPROC ENDDEFINE *!* -------------------------------------------------------------------------------- *!* See also: ScreenResize *!* -------------------------------------------------------------------------------- *!* CategoryCodeSamples *!* Edit - Find RecentChanges Categories RoadMap [A-F] [G-P] [Q-Z] Random NewTopic Home *!* http://wikis.com - low-impedance, fat-free - 2002.12.29 11:33:15 PM EST Search: