Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: George Kelly
  Where is George Kelly?
 Dromore
 United Kingdom
 George Kelly
 To: Marcia Akins
  Where is Marcia Akins?
 Akorn
 Ohio - United States
 Marcia Akins
 Tags
Subject: RE: maximizing my applications main screen
Thread ID: 110937 Message ID: 113089 # Views: 5 # Ratings: 0
Version: Visual FoxPro 9 Category: Forms
Date: Wednesday, November 15, 2006 10:53:09 AM         
   


> i want that when i run my appliction it shoul be maximized on the screen how can i do this and plz clear me about the screen settings of the application
>
> I am assuming that you want to resize and re-position all the controls on the form as well. If this is the case, you need to base your forms on a common form class with this code in its init():
>
>
> LOCAL loControl
> 
> WITH THISFORM
>   *** Determine the ratio needed to maximize the form
>   *** depending on screen resolution and store it to form properties
>   .WidthRatio = SYSMETRIC( 1 ) / 640
>   .HeightRatio = SYSMETRIC( 2 ) / 480
>   *** If resolution is higher than 640 x 480, reposition
>   *** and maximize the form
>   IF .WidthRatio > 1
>     .TOP = 0
>     .LEFT = 0
>     .WIDTH = .WIDTH * .WidthRatio
>     .HEIGHT = .HEIGHT * .HeightRatio
>     *** And resize each control contained in the form
>     FOR EACH loControl IN .CONTROLS
>       .ResizeControls( loControl )
>     ENDFOR
>   ENDIF
> ENDWITH
> 

>
> And this code in its custom ResizeControls() method:
>
>
> LPARAMETERS toControl
> LOCAL loPage, loControl, loColumn, lnColumnWidths[1], lnCol
> 
> IF PEMSTATUS( toControl, 'Width', 5 )
>   toControl.WIDTH = toControl.WIDTH * THISFORM.WidthRatio
> ENDIF
> IF PEMSTATUS( toControl, 'Height', 5 )
>   toControl.HEIGHT = toControl.HEIGHT * THISFORM.HeightRatio
> ENDIF
> IF PEMSTATUS( toControl, 'Top', 5 )
>   toControl.TOP = toControl.TOP * THISFORM.HeightRatio
> ENDIF
> IF PEMSTATUS( toControl, 'Left', 5 )
>   toControl.LEFT = toControl.LEFT * THISFORM.HeightRatio
> ENDIF
> *** Now resize the font of the control, grid (naturally <g>) is a special case because
> *** resizing the font resizes the column widths of the grid, so save and restore them
> IF UPPER( ALLTRIM( toControl.BASECLASS ) ) = 'GRID'
>   DIMENSION lnColumnWidths[toControl.ColumnCount]
>   FOR lnCol = 1 TO toControl.COLUMNCOUNT
>     lnColumnWidths[lnCol] = toControl.COLUMNS[lnCol].WIDTH
>   ENDFOR
>   toControl.FONTSIZE = INT( toControl.FONTSIZE * THISFORM.WidthRatio )
>   FOR lnCol = 1 TO toControl.COLUMNCOUNT
>     toControl.COLUMNS[lnCol].WIDTH = lnColumnWidths[lnCol]
>   ENDFOR
> ELSE
>   IF PEMSTATUS( toControl, 'Fontsize', 5 )
>     toControl.FONTSIZE = INT( toControl.FONTSIZE * THISFORM.WidthRatio )
>   ENDIF
> ENDIF
> DO CASE
>   CASE UPPER( toControl.BASECLASS ) = 'PAGEFRAME'
>     FOR EACH loPage IN toControl.PAGES
>       THISFORM.ResizeControls( loPage )
>     ENDFOR
> 
>   CASE INLIST( UPPER( toControl.BASECLASS ), 'PAGE', 'CONTAINER' )
>     FOR EACH loControl IN toControl.CONTROLS
>       THISFORM.ResizeControls( loControl )
>     ENDFOR
> 
>   CASE UPPER( toControl.BASECLASS ) = 'GRID'
>     WITH toControl
>       .ROWHEIGHT     = .ROWHEIGHT * THISFORM.HeightRatio
>       .HEADERHEIGHT  = .HEADERHEIGHT * THISFORM.HeightRatio
>       FOR EACH loColumn IN .COLUMNS
>         loColumn.WIDTH = loColumn.WIDTH * THISFORM.WidthRatio
>       ENDFOR
>     ENDWITH
> 
>   CASE INLIST( UPPER( toControl.BASECLASS ), 'COMBOBOX', 'LISTBOX' )
>     LOCAL lnCol, lnStart, lnEnd, lnLen, lcColumnWidths
>     WITH toControl
>       IF .COLUMNCOUNT < 2
>         .COLUMNWIDTHS = ALLTRIM( STR( .WIDTH ) )
>       ELSE
>         lcColumnWidths = ''
>         lnStart = 1
>         FOR lnCol = 1 TO .COLUMNCOUNT - 1
>           lnEnd = AT( ',', .COLUMNWIDTHS, lnCol )
>           lnLen = lnEnd - lnStart
>           lcColumnWidths = lcColumnWidths + IIF( EMPTY( lcColumnWidths ), '', ',' ) + ALLTRIM( STR( VAL (SUBSTR( .COLUMNWIDTHS, lnStart, lnLen ) ) * THISFORM.WidthRatio ) )
>           lnStart = lnEnd + 1
>         ENDFOR
>         lnLen = LEN( .COLUMNWIDTHS ) - lnStart + 1
>         lcColumnWidths = lcColumnWidths + ',' + ALLTRIM( STR( VAL (SUBSTR( .COLUMNWIDTHS, lnStart, lnLen ) ) * THISFORM.WidthRatio ) )
>         .COLUMNWIDTHS = lcColumnWidths
>       ENDIF
>     ENDWITH
> 
>   CASE INLIST( UPPER( ALLTRIM( toControl.BASECLASS ) ), 'COMMANDGROUP', 'OPTIONGROUP' )
>     LOCAL lnButton
>     FOR lnButton = 1 TO toControl.BUTTONCOUNT
>       THISFORM.ResizeControls( toControl.BUTTONS[lnButton] )
>     ENDFOR
> 
>   OTHERWISE
>     *** There is no otherwise...I think we got all cases
> ENDCASE
> 

>
>
> Regards,
> Marcia G. Akins
> Tightline Computers, Inc.


Thanks for that magnificent code Marcia.
Ive worked it into a few test screens. It was sheer simplicity, and it works absolutely brilliantly!

I had to make one change. Please correct me if I'm wrong:
Ive remmed out a line which cause me a problem and inserted what I think is a correction in the ResizeControls() method:

IF PEMSTATUS( toControl, 'Left', 5 )
*toControl.LEFT = toControl.LEFT * THISFORM.HeightRatio
toControl.LEFT = toControl.LEFT * THISFORM.widthRatio
ENDIF

i.e. Multiply by WidthRatio rather than HeightRatio
This was in VFP7 environment.

I will me moving to VFP9 soon.
Does the same code apply in VFP9?

Thanks again Marcia. You are a star!

George

ENTIRE THREAD

maximizing my applications main screen Posted by Jahangir Khan @ 10/24/2006 10:41:17 AM
RE: maximizing my applications main screen Posted by Kiran Kumar Singh @ 10/24/2006 10:57:45 AM
RE: maximizing my applications main screen Posted by Saeed Afshari @ 10/24/2006 10:58:31 AM
RE: maximizing my applications main screen Posted by Borislav Borissov @ 10/24/2006 10:58:32 AM
RE: maximizing my applications main screen Posted by Dave Crozier @ 10/24/2006 10:59:29 AM
RE: maximizing my applications main screen Posted by Marcia Akins @ 10/24/2006 12:19:34 PM
RE: maximizing my applications main screen Posted by George Kelly @ 11/15/2006 10:53:09 AM
RE: maximizing my applications main screen Posted by Marcia Akins @ 12/6/2006 11:55:15 PM
RE: maximizing my applications main screen Posted by George Kelly @ 12/7/2006 10:52:23 AM
RE: maximizing my applications main screen Posted by Marcia Akins @ 12/7/2006 12:40:34 PM
RE: maximizing my applications main screen Posted by George Kelly @ 12/7/2006 1:08:03 PM
RE: maximizing my applications main screen Posted by Ken Murphy @ 12/7/2006 1:44:55 PM
RE: maximizing my applications main screen Posted by tushar @ 12/7/2006 3:26:59 PM
RE: maximizing my applications main screen Posted by Ken Murphy @ 12/7/2006 3:31:52 PM
RE: maximizing my applications main screen Posted by George Kelly @ 12/7/2006 4:51:26 PM
RE: maximizing my applications main screen Posted by Ken Murphy @ 12/7/2006 6:07:40 PM
RE: maximizing my applications main screen Posted by George Kelly @ 12/7/2006 9:23:25 PM
RE: maximizing my applications main screen Posted by Don Higgins @ 12/7/2006 11:20:46 PM
RE: maximizing my applications main screen Posted by George Kelly @ 12/8/2006 11:21:35 AM
RE: maximizing my applications main screen Posted by Ken Murphy @ 12/7/2006 3:29:56 PM
RE: maximizing my applications main screen Posted by Don Higgins @ 12/7/2006 11:22:33 PM
RE: maximizing my applications main screen Posted by George Kelly @ 12/6/2006 1:14:45 PM
RE: maximizing my applications main screen Posted by Barbara Peisch @ 10/24/2006 10:16:51 PM
RE: maximizing my applications main screen Posted by Mike Gagnon @ 10/25/2006 11:43:05 AM