Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How To: Add code to _Screen.Hide and _Screen.custom met
Message
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Miscellaneous
Thread ID:
00814430
Message ID:
00850858
Views:
17
Hi Rodney

>Could you share how you got this to work? I take that code and it errors every time on "Unknown member oScr". I even went back to the help and put in the exact example with no luck either...

Actually the client then dropped the idea and I was not required to go forward with the logic but this is the code that I have saved regarding screenhooks in my R&D folder hope it help.

Maybe this was the problem
* For VFP6 & 7:
*
* _SCREEN.NewObject("oSH","ScreenHook","screenmethods.prg")
*
* For VFP3 & 5:
*
* SET PROCEDURE TO screenmethods ADDITIVE
* _SCREEN.AddObject("oSH","ScreenHook")
_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:
Regards
Bhavbhuti
___________________________________________
Softwares for Indian Businesses at:
http://venussoftop.tripod.com
___________________________________________
venussoftop@gmail.com
___________________________________________
Previous
Reply
Map
View

Click here to load this message in the networking platform