How to Resize a Form When the Application Window Is Resized (138162)



The information in this article applies to:

  • Microsoft Visual FoxPro for Windows 3.0

This article was previously published under Q138162

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.

Modification Type:MajorLast Reviewed:12/11/1999
Keywords:KB138162