KnowledgeBase Archive

An Archive of Early Microsoft KnowledgeBase Articles

View on GitHub

Q138162: How to Resize a Form When the Application Window Is Resized

Article: Q138162
Product(s): Microsoft FoxPro
Version(s): WINDOWS:3.0
Operating System(s): 
Keyword(s): 
Last Modified: 11-DEC-1999

-------------------------------------------------------------------------------
The information in this article applies to:

- Microsoft Visual FoxPro for Windows, version 3.0 
-------------------------------------------------------------------------------

SUMMARY
=======

When you resize an application's window, a form in the application window is not
resized accordingly. To resize a form relative to the size of the application
window, you can use a timer control.

MORE INFORMATION
================


Step-by-Step Example
--------------------

1. Create a new form.

2. Add two new properties called OldWidth and OldHeight. To do this, on the Form
  menu, click New Property.

3. In the Init event of the form, place this code:

     THISFORM.oldwidth  =  _SCREEN.width
     THISFORM.oldheight =  _SCREEN.height

4. Add a timer control to the form.

5. In the Timer event of the Timer control, place this code:

     x=_SCREEN.width
     y=_SCREEN.height
     IF ((x!=THISFORM.oldwidth) or (y!=THISFORM.oldheight))
        THIS.parent.width=_SCREEN.width-25
        THIS.parent.height=_SCREEN.height-25
        THISFORM.oldwidth  =  _SCREEN.width
        THISFORM.oldheight =  _SCREEN.height
        THISFORM.AutoCenter=.t.
        THISFORM.Refresh
     ENDIF

6. Change the Interval property of the Timer control to 100.

7. Run the form. Notice how when you resize the main application window, the
  form is automatically resized.

Additional query words: VFoxWin form window resize timer

======================================================================
Keywords          :  
Technology        : kbVFPsearch kbAudDeveloper kbVFP300
Version           : WINDOWS:3.0

=============================================================================

THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Copyright Microsoft Corporation 1986-2002.