Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to I make something Resize when the _SCREEN.Resize event fires?

Forms & Screen

How to I make something Resize when the _SCREEN.Resize event fires?

by  wgcs  Posted    (Edited  )
This has been tackled in a number of ways... the most common being creating a timer on the child form that repeatedly checks to see if _SCREEN.Height and _SCREEN.Width have changed.

VFP8's BINDEVENT() probably is going to be the "Documented" way of doing this.
Update: VFP8 SP1 Deliberately disables the method of hooking the _SCREEN events described here due to instability of VFP when using this method.

However, still, the most elegant and simplest method I've seen is best demonstrated with code:
Code:
*Credit for this method must be given to the following:
*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
*
* In your main program:
_Screen.AddObject("oResizer", "Resizer")

DEFINE CLASS Resizer AS Custom
  oScreen = _Screen
  KeyPreview = .t.

  PROCEDURE oScreen.Resize
    WAIT window "Resizing" NOWAIT
  ENDPROC

  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 "QueryUnload!"
  ENDPROC

  PROCEDURE oScr.RightClick && Works
    DO testmenu.mpr
  ENDPROC

  *-------------------------------
  PROCEDURE oScr.MyMethod && Works
    * This fires on _SCREEN.MyMethod() !!
    wait window "my method fired!"
  ENDPROC

ENDDEFINE

See also: http://fox.wikis.com/wc.dll?Wiki~ScreenMethods
and http://fox.wikis.com/wc.dll?Wiki~ScreenResize
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top