Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to check the current screen resolution?
Message
 
 
À
29/11/2021 13:50:25
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01682835
Message ID:
01682860
Vues:
49
Thank you very much for the code. I will see how to apply it to my form.

>For one of my clients, the base form class includes a method that checks the form size against the VFP viewport and, if necessary, resizes the form to fit inside the viewport. (It works together with my code for changing font size when the form size changes.) Here's the code that resizes the form:
>
>
>* Check whether this form fits inside the available space.
>* If not, shrink it.
>
>LOCAL lnAvailHeight, lnAvailWidth
>LOCAL lnDesiredHeight, lnDesiredWidth, llResize
>LOCAL lnResizeRatio, lnTop
>
>lnAvailHeight = _screen.ViewPortHeight
>lnAvailWidth = _screen.ViewPortWidth
>llResize = .F.
>
>* Include a little fudge factor
>IF This.Height > lnAvailHeight - 50
>	lnDesiredHeight = m.lnAvailHeight - 50
>	llResize = .T.
>ELSE
>	lnDesiredHeight = This.Height
>ENDIF
>
>*-- TEG 6/7/2021 
>* Don't need fudge factor for width. We don't put anything on the sides.
>IF This.Width > m.lnAvailWidth && - 50
>	lnDesiredWidth = m.lnAvailWidth - 50 
>	llResize = .T.
>ELSE
>	lnDesiredWidth = This.Width
>ENDIF
>
>
>IF m.llResize
>	lnTop = This.Top
>	
>	* Figure out which dimension is more cramped
>	IF m.lnDesiredHeight/This.Height < m.lnDesiredWidth/This.Width
>		lnResizeRatio = m.lnDesiredHeight/This.Height
>	ELSE
>		lnResizeRatio = m.lnDesiredWidth/This.Width
>	ENDIF
>	
>	This.Height = FLOOR(m.lnResizeRatio * This.Height)
>	This.Width = FLOOR(m.lnResizeRatio * This.Width)
>
>	* Now make sure top is visible
>	IF This.AutoCenter
>		This.AutoCenter = .F.
>		This.AutoCenter = .T.
>	ELSE
>		This.Top = m.lnTop
>	ENDIF
>	
>ENDIF
>
>RETURN 
>
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform