Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calculation for size of VFP Desktop area?

Status
Not open for further replies.

jrjernigan

Programmer
Nov 12, 2002
12
US
Does anyone have (or know of) a formula/calculation to determine the height and width of the VFP Desktop area. This would be the space below the menu bar (if any) and above the status bar (if turned on).

I know SYSMETRIC() could be used to help calculate this, but I'm not sure of everything to include. I also know that _Screen.Height and _Screen.Width will help, but this is the size of the whole desktop (including title bar, menu bar, status bar, etc.)

REASON: My application allows the users to adjust the height of some forms inside the application. The application saves these sizes and uses them the next time the form is opened. I also do the same for the desktop (_screen). If the user shrinks the desktop to it's minimum size (that I allow) or changes screen resolution (users [wink] <g>), then the form could extend past the size of the desktop. I want to know what space I have so that I can make the sizing of the form smarter, shrink it automatically when necessary.

Thanks in advance,
James Jernigan
Nashville, TN USA
jrjernigan@hotmail.com
 
jrjernigan

above the status bar (if turned on).

? sysmetric(22)

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first
 
How about:
_screen.viewportheight
_screen.viewportwidth


These seem to be undocumented in VFP6, (documented for form objects, not for _SCREEN).
 
wgcs (Programmer) Nov 15, 2002
How about:
_screen.viewportheight
_screen.viewportwidth


These seem to be undocumented in VFP6

Neither in VFP7.

BTW, I found that in VFP7 the VFP main window behaves differently when it's IDE from when it's compiled EXE.

WAW, if I have

Code:
_SCREEN.Top = 0


then in IDE it shows its upper rim at the top, but in EXE the same command sends _screen &quot;over the ceiling&quot; ( [smile] ) so that _screen's title bar and even some part of the _screen's upper area are hidden!

Any comments on that, anybody?

I got around that by issuing

Code:
_SCREEN.WindowState = 2


but it's still unpleasant! And it was not so in VFP6!

Regards,

Ilya
 
OK, was referred to documentation (duh! stupid me did not find it, ha ha) that tells us that the title bar and menu have a height of 38 and the status bar has a height of 23, SO:

desktop_height = _screen.height - 38 - 23

Then I could use desktop_height to see if my form will be too large or not.

James
 
Did you give _SCREEN.ViewportHeight a try?
It works, but isn't in the documentation.

The height of the titlebar and menu can change when the user changes the windows title bar and menu fonts.
 
My tests with _Screen.Height vs. _Screen.ViewPortHeight resulted in the same numbers (Using VFP 6.0 SP 5). So, it didn't help.

Test program:
---------------------------------------------------------
Set Status Bar On
Set SysMenu On
Show Window Standard

? &quot;Menu&quot;, &quot;Toolbar&quot;, &quot;Status Bar&quot;, &quot;Height&quot;, &quot;ViewPortHeight&quot;
Do Disp_Stat
Set SysMenu Off
Do Disp_Stat
Hide Window Standard
Do Disp_Stat
Set Status Bar Off
Do Disp_Stat

********************************************

Set Status Bar On
Set SysMenu On
Show Window Standard

********************************************

Procedure Disp_Stat
? Set(&quot;SysMenu&quot;), IIF(WVisible(&quot;Standard&quot;),&quot;Shown&quot;,&quot;Hidden&quot;), Set(&quot;Status Bar&quot;), _screen.height, _screen.viewportheight
EndProc
---------------------------------------------------------
 
ANOTHER THOUGHT

Instead of using the formula:

desktop_height = _screen.height - 38 - 23

Would probably be better to use:

desktop_height = _screen.height ;
-SysMetric(9) ;
-SysMetric(20) ;
- 23

SysMetric(9) = Height of window title
SysMetric(20) = Single-line menu bar height

At moment, my settings return 26 for SysMetric(9) and 20 for SysMetric(20), total = 46. This is only 8 than 38 mentioned in the documentation, but would be more dynamic that static numbers. The height of the status bar (23) would not be affected, me thinks.

James
 
I duplicate your results on ViewportHeight & width being the same as Height & width, but they both seem to account for the menubar and the status bar and any toolbars.

_screen.line(0,0,_screen.viewportwidth,_screen.viewportheight)
_screen.line(0,_screen.viewportheight,_screen.viewportwidth,0)

.. draws a line from the top left corner to the bottom right corner, and bottom left to top right.
 
James,
What's not been explicitly said is that VFP 5.0 & 6.0 are a bit different than 7.0 (and 8.0).
In the first two:
?_screen.width
?_vfp.width && gives same value as _screen.width

?_screen.height
?_vfp.height && gives same value as _screen.height

But in the last two, these are different values. Starting in 7.0 _Screen really is just the desktop area, where before it included the VFP menu and header.

I've used the following code to maximize the screen for a long time, and it only seems to &quot;fail&quot; when a user has resized or moved the system Taskbar.
Code:
IF SET(&quot;STATUS BAR&quot;) = &quot;ON&quot;
   SET STATUS BAR OFF
   m.lcstbar = &quot;ON&quot;
ELSE
   m.lcstbar = &quot;OFF&quot;
ENDIF
lnhoriz = SYSMETRIC(1)
lnvert  = SYSMETRIC(2)
lnAdjHeight = 0

lnvert=MIN(1200, MAX(200, lnvert))
lnhoriz=MIN(1600, MAX(320, lnhoriz))
IF lnvert > 480	&& std VGA
   lnAdjHeight = lnAdjHeight +;
     iif((&quot;3.95&quot; $ OS(1)) OR (&quot;4.00&quot; $ OS(1)) OR (&quot;4.10&quot; $ OS(1));
       OR (&quot;5.&quot; $ OS(1)),;
     2*SYSMETRIC(4)+SYSMETRIC(9), 0)
ENDIF
MODIFY WINDOW SCREEN AT 0,0 SIZE ;
   (lnvert-(SYSMETRIC(9)+SYSMETRIC(20)+2*SYSMETRIC(4)+lnAdjHeight))/ ;
          (FONTMETRIC(1)+FONTMETRIC(5)), ;
   (lnhoriz-2*SYSMETRIC(3))/FONTMETRIC(6)
IF m.lcstbar = &quot;ON&quot;
   SET STATUS BAR ON
ENDIF

Rick



 
*** WELL BLOW ME DOWN *** (as Popeye used to say)

Finally read the &quot;fine print&quot; in VFP 6.0 Documentation for Height Property.

&quot;Specifies the object's height measured in the unit of measurement specified by the ScaleMode property of the form.

Remarks

For forms, the Height measurement does not include the borders and title bar.&quot;

SO, this is the number I was looking for ALL ALONG ( [surprise] doit - supposed to be sound Homer Simpson makes when he realizes he's done something stupid) ha ha James Jernigan
Nashville, TN USA
jrjernigan@hotmail.com

&quot;Too err is human ... I should know, I get to show my humanity everyday.&quot; jrj
 
What's not been explicitly said is that VFP 5.0 & 6.0 are a bit different than 7.0 (and 8.0).
In the first two:
?_screen.width
?_vfp.width && gives same value as _screen.width

?_screen.height
?_vfp.height && gives same value as _screen.height

But in the last two, these are different values. Starting in 7.0 _Screen really is just the desktop area, where before it included the VFP menu and header.


This is almost correct.
In my tests, the various HEIGHT's always referred to the desktop area, and VFP7&8 bring to us the easy ability to get to the Total window size:

In VFP6, _SCREEN.Height=_VFP.Height= Just the Desktop Area.
In VFP7 & VFP8, _SCREEN.Height<>_VFP.Height
_SCREEN.Height = Just desktop
_VFP.Height = Desktop+menu+title+toolbars+statusbar, etc.

 
And, since I've never referred to _VFP.Height (only _Screen.Height) - this will be THE number for ME and my purposes.

Thanks all. [sunshine]
James Jernigan
Nashville, TN USA
jrjernigan@hotmail.com

&quot;Too err is human ... I should know, I get to show my humanity everyday.&quot; jrj
 
wgcs (Programmer) Nov 15, 2002

What's not been explicitly said is that VFP 5.0 & 6.0 are a bit different than 7.0 (and 8.0). Starting in 7.0 _Screen really is just the desktop area, where before it included the VFP menu and header.

That's exactly the answer to my question!
&quot;Thanks for the tip, bro!&quot; (Chris &quot;Izzy&quot; Cole)



James Jernigan
Nashville, TN USA
jrjernigan@hotmail.com

&quot;Too err is human ... I should know, I get to show my humanity everyday.&quot; jrj

&quot;To err is human... That's why they think I'm from outer space!&quot; I like this one better! [smile]

Regards,

Ilya
 
Nope. Sorry.

With 6.0 _screen.height and _vfp.height return same value, size of desktop area (not whole window)

With 7.0 _screen.height returns size of desktop, _vfp.height returns whole window size.

Way to test

1. go into each version
2. maximize the VFP window
3. ? _vfp.height, _screen.height
4. toggle status bar (if on, SET STATUS BAR OFF ...)
5. ? _vfp.height, _screen.height

In 6.0, step five will print the same number (twice), which should be different than the numbers printed in step 3

In 7.0, step five will print two different numbers, BUT the first number in both #3 and #5 should be the SAME.

That's the difference.

_SCREEN.HEIGHT = VFP desktop height (in 6.0 and 7.0)
_VFP.HEIGHT = VFP desktop height (in 6.0)
_VFP.HEIGHT = VFP window height (in 7.0)

Now - is everybody happy [2thumbsup]

(Yes, I am a bit anal when it comes to being precise with these stupid things.) ha ha

EVERYONE have a NICE WEEKEND

(and watch you card #s [sadeyes] or you could be crying)

James Jernigan
Nashville, TN USA
jrjernigan@hotmail.com

&quot;Too err is human ... I should know, I get to show my humanity everyday.&quot; jrj
 
Dear James:

I think this might help you.... too.

Since I wanted to display a report in different resolutions (that is because there are several types of monitors/video modes at the office), then I came up with a formula do define a window that would fit at any resolution, you might take the idea from the following example:

Code:
define window showreport from 0,0 to;
   sysmetric(2)/12.2,sysmetric(1)/8.02;
   in desktop
activate window showreport


I hope you can use that.
 
What exactly do the numbers 12.2 and 8.02 represent? Wouldn't these be dependent on the current font?

Rick
 
Rick:

What I was looking for was a means of defining a window that would fit in the actual screen, so after some trial I got to the conclusion that these were the numbers that fit best no matter what resulution Windows is working with. Since I wasn't looking for an &quot;exact&quot; number of rows or columns to be displayed at a time, I did not take in consideration font size. With this you only get a VFP window that would fit in the entire screen, using the maximum possible. However, I did not try these numbers with all resolution, since this depends on the video card/monitor hardware specs, so I just worked on the resolutions I had at hand.

Bye.
 
These number DO relate to font size.. they're specified in FOXELS (which is the average height or width of a character in the current font & size )

Instead of
define window showreport from 0,0 to;
sysmetric(2)/12.2,sysmetric(1)/8.02;
in desktop

explore:
define window showreport at 0,0 size 1,1 ;
in desktop name ReportWin
ReportWin.Height = _Screen.Height
ReportWin.Width = _Screen.Width
 
I have an application where all the screens and forms were built for someone using a default setting of 1024 by 768. I need these screens and forms to work for others with different default screen settings. Do you have some could that will allow them to adjust these screens I could use?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top