VFP 9 resizing forms automatically

Bart-Rouan
Bart-Rouan used Ask the Experts™
on
As I understand VFP9 can resize the forms depending on the resolution of the screen. I have also done some searching and it seems there are some dll's that you can download but I thought you could do this by changing a property on the form??
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
CaptainCyrilFounder, Software Engineer, Data Scientist

Commented:
You can base the form on a class and in that class detect resolution and resize. Or you can call a function in the Init Function to resize the screen.

? SYSMETRIC(1)
? SYSMETRIC(2)

These give you screen width and height. You can make your triangulation and resize accordingly.

What I do is either have fixed window or design it to open to the maximum specially if it has a grid or a webbrowser control whereby the user can benefit from the maximized window.
There is a property called windowstate

Also all objects on the form have a property called anchor to decide their location and size when the form is resized.
CaptainCyrilFounder, Software Engineer, Data Scientist

Commented:
You can assign the Window Size to be Max.

You can also assign AutoCenter = .T. no matter the resolution.
Fundamentals of JavaScript

Learn the fundamentals of the popular programming language JavaScript so that you can explore the realm of web development.

SYSMETRIC() functions will return the physical screen dimensions without any impact of System Taskbar or VFP toolbars which is not good in many cases.

Better approach is to maximize the screen for a moment and save the maximized dimensions of the _screen (or your main window) and then use them to determine your forms sizes.

To resize VFP forms is also easy - simply assign numeric values to following properties: Top, Left, Widht, and Height.  To switch the form into its Max state is easier, of course.

LOCAL lnState, lnWidth, lnHeight

IF _screen.WindowState <> 2
  lnState = _screen.WindowState
  _screen.LockScreen = .T.
  _screen.WindowState = 2
  lnWidth = _screen.Width
  lnHeight = _screen.Height
  _screen.WindowState = lnState
  _screen.LockScreen = .F.
ELSE
  lnWidth = _screen.Width
  lnHeight = _screen.Height
ENDIF

? "Available area resolution: ", TRANSFORM(lnWidth), " x ", TRANSFORM(lnHeight)

Open in new window

Software Developer
Commented:
You can set the Anchor property of controls to specify how they should react to resizing. It's a bit of work for a each form, but worth it, as it means the form does not just react to other screen resolutions by magnifying everything.

Double click on the Anchor property in the Property window and you get a property editor helping you set the Anchor value.

Bye, Olaf.
CaptainCyrilFounder, Software Engineer, Data Scientist

Commented:
As for SYSMETRIC, what I was trying to say is that if you build your screen to 1024x768 or 800x600 and you wish to resize to higher resolution, you use the triangulation formula to resize while retaining shape. Take the smaller ratio of triangulation for width and height increase.
I just did not read your post carefully...

BTW, if we are talking about the "resizing" did somebody of you ever try to resize fonts based on the object size? Me not.
Olaf DoschkeSoftware Developer

Commented:
Actually there are a few resizer classes you simply drop on a form which do also set fontsizes higher. See here for example from Marcia Akins (last post includes full code) http://www.tek-tips.com/viewthread.cfm?qid=1426615&page=9

But Anchoring gives more options and better resize behavior in my opinion.

Bye, Olaf.
Good. And thanks!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial