Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Writing a real DPI-aware VFP application
Message
From
06/02/2021 06:29:42
Walter Meester
HoogkarspelNetherlands
 
 
To
05/02/2021 17:15:13
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
01678100
Message ID:
01678111
Views:
84
Hi Antonio,

I've started the same a few years ago. The principle works, but It was too much work in order to implement it in my current project so I had to let it go for now.

As for menus, I'm using the commandbars library from Alex Grigorev. In my menu (and toolbar) builder I'd used different sized images (16, 20, 24 and 32 pixels) depending on the dpi.

A few characteristics from my approach.

1. Each control I use has a Zoomlevel property.
2. Each control has a GUI handler property, which points to an GUIHandler on the form.
3. Each control calls the guihandler object for initializing and refreshing its. This allows for changing themes and objects adjust to it.
4. The guihandler is responsible for resizing the form and the objects within it. Objects will have their original locations stored in .oldleft, oldwidth, oldHeight and .oldtop properties. Those will be used to multiply the zoomlevel to calculate the new position as size.
5. Using the anchor property is still permitted. The Guihandler uses smart resizing by applying the zoomlevel to the entire form/container, then zooming the controls and then resizing the form/container to its original size.

Compare the attached screenshots.
The two upper left buttons are not resized as their class did not have the guihandler handling implemented. The rest is automatically adapted to the new size.

BTW, its not directly driven by the screens DPI, but rather a zooming mechanism that works independedly. Only the menu fonts and size are determined by the screens DPI setting

Walter,







>Dear All,
>
>By integrating a manifest into our executable applications, we know how to avoid the nasty effects of DPI scaling in modern Windows. Our screens won't be looking fuzzy, and our 9.0 reports will be displayed as designed.
>
>A manifest, however, solves only part of the problem. Our applications still render at 100% DPI scaling, and we're failing to honor the settings of choice of the users.
>
>I was thinking of adapting one of the available resizer class to (preferably automatically) adjust the size of forms and controls to the current display scaling. Instead of reacting to the windows' resizing, the target is to set the controls' dimensional and positional properties once the application instantiates a form.
>
>Even if I expect some challenging hurdles, like adjusting the menu system, I'm looking for recommendations on the resizer class of your preference. Or authoring! I don't mind a full code rewrite - in reality, I'm also expecting it - but I will welcome good, stable, and tested ideas, no matter their current form, together with a discussion and guidance on this topic.
>
>The result, if successful, will be available in open-source, with all due credits.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform