Size of Application Window in FoxPro

One of my old applications is now running on a computer with a much bigger monitor than I used before. And now, there is a lot of white space between my forms and the frame of the application window (which is not maximized). Apparently, it was not noticeable before because the size of the forms fit the old screen exactly, and the size of the application automatically fit the size of the screen. Now, there is a mismatch. How can I fix that? I would like the application window to frame my forms perfectly and to be centered on the screen.

Thank you.
VitalyNagyAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
pcelbaConnect With a Mentor Commented:
Just a short clarification: You cannot execute  This.ShowWindow = 2  because ShowWindow property is read/only at run-time. So you have to decide about the window type during the design time.

Top Level Form also requires special handling of the system menu if you use it.

The _screen dimensions change seems to be the easiest change you can do... and you could do it even without any programming because the size of main application window is handled by Windows so if you start your app, resize the main app window into the size required and exit the app then Windows should remember the window position and dimensions for future use.

Of course, to change _screen dimensions programmatically is more sophisticated approach and you may adjust it in your form Init method the following way:

_screen.Height = THISFORM.Height + SYSMETRIC(9) + 2*SYSMETRIC(4)
_screen.Width = THISFORM.Width + 2*SYSMETRIC(3)

You could also think about the _screen Resize event binding to your code which will resize the main form. Code sample is under the BINDEVENT() function in VFP 9 help.  The latest help file is available here: http://vfpx.codeplex.com/wikipage?title=VFP%209%20SP2%20Help%20File&referringTitle=Home
0
 
basrajConnect With a Mentor Commented:
Is the application Visual Foxpro? If yes, please check this:

http://fox.wikis.com/wc.dll?Wiki~AutomaticWindowResizing
0
 
chanderpal singh rathoreConnect With a Mentor Microsoft Exchange EngineerCommented:
There are two options.

First, in the Init of the form, put the following code:

CODE

WITH _Screen
  .Height = 400
  .Width = 600
ENDWITH


That will resize the outer window (the one with the blue bar) to 400 x 600 pixels. Obviously, you can put whatever figures you like here. But don't make it smaller than your form, otherwise the form will be clipped.

But I wonder if this is what you really want. If the outer window is not relevant to your application (in other words, if you only have the one form, and no other user interface such as menus or toolbars), it would be better to make the outer window invisible. So, put this into the Init of the form:

CODE

This.ShowWindow = 2
_Screen.Visible = .F.


And in the Destroy of the form:

CODE

_Screen.Visible = .T.


That way, the user will only see your form, and nothing else.

Mike
 

__________________________________
OR you can use this


If you are using a "config.fpw", it should contain a line with :

screen = off

make sure this file is included in your project. In other words, go tot he 'Other' tap on your project window. Under 'Text Files' the "config.fpw" should be present. If not "add" it to the project.

Set the property "ShowWindow" = 2 - As Top Level Form

compile and test
0
 
VitalyNagyAuthor Commented:
Thank you. I have several forms and a toolbar. So, I would not like a windowless application.

How can I also ensure that the window is centered on the screen? (I am still using Visual FoxPro 6, by the way).
0
 
pcelbaConnect With a Mentor Commented:
To center the main VFP window just issue following command (after setting its dimensions):

_screen.AutoCenter = .t.

Hope this property is available in VFP 6. If not then you have to calculate _screen.Top and _screen.Left from SYSMETRIC(1) and SYSMETRIC(2):

_screen.Top = (SYSMETRIC(2) - _screen.Height) / 2
_screen.Left = (SYSMETRIC(1) - _screen.Width) / 2

To create several Top level forms each one having its own menu and toolbar is also an option. (Which requires some additional programming...)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.