Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Microsoft: FoxPro FAQ

Forms & Screen

How can I add .Resize() and .Moved() methods to _SCREEN? by ChrisRChamberlain
Posted: 31 Oct 03 (Edited 9 Jan 04)

If you want to manipulate child forms in relation to _SCREEN and _SCREEN in relation to child forms, and start your application in the last position on screen, you need to add both .Resize() and .Moved() methods to _SCREEN.

In the root of main.prg put

DO ScreenResizeClass

Then create a procedure :-

* *********************************
* Procedure: ScreenResizeClass
*    Syntax: DO ScreenResizeClass
* *********************************
PROC ScreenResizeClass

* IF you are using VFP 8.0 SP1, replace the first 6 lines of the procedure with the following code

* PUBLIC oScreenHandler
* oScreenHandler = NEWOBJECT([ScreenHandler])

* BINDEVENT(_SCREEN,[Resize],oScreenHandler,[ResizeScreen])

* DEFINE CLASS ScreenHandler AS Session
*   PROCEDURE ResizeScreen
*        WITH _SCREEN
*            .LockScreen =     .T.
*            && Code

DEFINE CLASS Resizer AS Custom
    oScreen = _SCREEN

    PROCEDURE oScreen.Resize
        WITH _SCREEN
            .LockScreen =     .T.
            && Code            
            .LockScreen =     .F.            

        IF VARTYPE(oMain)         = [O]
            WITH oMain
                .LockScreen     = .T.
                && Code
                .LockScreen     = .F.
        IF VARTYPE(oChild1)         = [O]
            WITH oChild1
                .LockScreen     = .T.
                && Code
                .LockScreen     = .F.

        IF VARTYPE(oChild2)         = [O]
            WITH oChild2
                .LockScreen     = .T.
                && Code
                .LockScreen     = .F.

        IF VARTYPE(oStatusBar)    = [O]
            WITH oStatusBar
                .LockScreen     = .T.
                && Code
                .LockScreen     = .F.

If you are not using VFP 8.0 SP1, in the .Load() event of your main form put :-


As you can see, you can add a .Moved() method which enables you to write the coordinates of _SCREEN to a table so that the app always starts in the last position.

The code for the procedure, ScreenMovedClass, (_SCREEN.Moved()), should follow the style of the ScreenResizeClass procedure, excepting that you only need a code segment for _SCREEN.

In the example code above, you will find a reference to oStatusBar - see 'How can I create my own statusbar?' - FAQ184-3155 for details.

What other code do you put in these methods?

_SCREEN.Resize() should only be called from a resizable child forms' .Resize() event so that _SCREEN can be resized in relation to the dimensions of the child form.

You will find it easier to perform the resizing/positioning of controls in all the child forms of an application in the _SCREEN.Resize() method.

Equally, _SCREEN.Resize() should contain code to resize all child forms when you resize _SCREEN.

To prevent recursive calls to resizable child forms, add a new property, .lInProcess, to each resizable child form.

In the .Resize() event of the resizable child form, put :-

IF THIS.lInProcess = .F.

In the first line of _SCREEN.Resize(), put :-

oChild1.lInProcess = .T.

In the last line of _SCREEN.Resize(), put :-

oChild1.lInProcess = .F.

After the code segments for the individual objects in _SCREEN.Resize(), you can write the relevant coordinates of child forms and their controls and _SCREEN to a table.

When you initialise the application next time, use the coordinates from the table to position and size _SCREEN, position and size child forms, and position and size controls in child forms.

Additional discussion of this FAQ can be found at Thread184-742923

Have fun!

Back to Microsoft: FoxPro FAQ Index
Back to Microsoft: FoxPro Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close