[RESOLVED] Scaling of forms is off
A client got a new computer, Windows 7 with an HP TouchSmart screen. Our VB6 app is being cut off on the left and bottom on almost all screens/forms. The screen resolution is currently set to 1600 x 900 but this appears to be at any resolution and any theme, even Windows Classic.
Does anyone have any experience with this or how to resolve this issue?
Re: Scaling of forms is off
Check Left & Top properties of each form, they must be 0 if StartFormPosition is different from CenterScreen
1 Attachment(s)
Re: Scaling of forms is off
You can ensure that your Form perfectly fits in the desktop's work area by resizing it using the attached class module:
Code:
Private Sub Form_Load() 'All WorkArea* properties are in Twips
With New clsGetWorkArea
Move .WorkAreaLeft, .WorkAreaTop, .WorkAreaWidth, .WorkAreaHeight
End With
End Sub
Re: Scaling of forms is off
I suspect you have just stumbled into the world of High DPI.
For a very long time display technologies were stabilized at a fixed 96 DPI in both horizontal and vertical dimensions, for most users as far back as Windows 95. Before that programs had to deal with screens having many diffrent resolutions and even rectangular pixels. VB accommodated that by providing separate X and Y scaling and pixel-independent scale modes such as HiMetrics, Twips, and Points.
High DPI settings have been an option for a long time but were not used very often. Now with the proliferation of large monitors and overly dense resolutions readability has become a problem.
In Windows 7 Microsoft took a hand here. When a new user logs on the first time Windows 7 looks at the display resolution and if over a certain density it will automatically choose a High DPI setting.
This can have many consequences to a naive application.
The screen is no longer 96 DPI, which can throw off programs that used ScaleMode set to Pixels. Depending on the version of Windows and a few settings various appcompat adaptations get applied to programs that are not marked DPI Aware. Those adaptations can produce blurry text, distorted bitmap images (icons and buttons mostly), label text cut off in various controls, and more.
Just marking your application DPI Aware does not solve the problem. You have to actually rework your UI to be DPI Aware and adjust things like UI element dimensions, font sizes, select alternative bitmap images or manually rescale them, etc.
Programmers who tried to force-maximize without actually maximizing and then manually scale their UI will tend to see windows cut off at various edges. This is often because of sizing calculations that have hard coded metrics (e.g. 15 twips/pixel). It's a curse of many "clever" auto-scaling libraries and code found on the Web, which fail in the real world.
Re: Scaling of forms is off
I'm afraid dilettante is closest to the real answer here.
The forms are smaller than the work area. The work area is huge, as you can imagine, at such a high resolution. And no matter where the form is positioned, it is still cut off on the left and bottom. So .move or trying to resize to fit the work area is not going to resolve this since the forms are all far smaller than the work area, which has plenty of empty space.
Another possibility I'm thinking is that there's a very wide "border" around screens (like the difference between Form.Width and Form.ScaleWidth is very high) and therefore parts of the form are obscured. I can try this with one form to see if this is the solution. Also, my forms use Twips, not pixels, as the scalemode, although I have no idea if this should make a difference either way.
I've also noticed that some screen elements end up in funny places. Like menus go to the left - instead of a menu dropping down below and to the right from where you click, it drops all the way to the left of the form/window. Some combo boxes look funny too - their drop button is not all the way to the right of the box but mostly to the right, with a bit of space between the drop button and the right edge of the combobox. Etc.
What are the other options?
Re: Scaling of forms is off
Might be something else in terms of UI customization by the user. At least pixel-based dimensions can be ruled out.
This sure does seem to get weirder and weirder.
Take a look at Windows 7 - Application Menus drop to LEFT instead of right. It might be part of the puzzle here.
Screens don't have a border. Normally the only thing that can get cut off if you move a Form to (0, 0) of a screen are thick window border areas. The client area of the Form shouldn't be positioned offscreen thuogh.
Or are you saying "screen" when you mean "window" (such as a Form)?
Quote:
The forms are smaller than the work area. The work area is huge, as you can imagine, at such a high resolution. And no matter where the form is positioned, it is still cut off on the left and bottom. So .move or trying to resize to fit the work area is not going to resolve this since the forms are all far smaller than the work area, which has plenty of empty space.
Are you saying that even if you drag the Form to the center of the screen parts are cut off?
Re: Scaling of forms is off
ScreenShot would be perfect
2 Attachment(s)
Re: Scaling of forms is off
Screenshot below. See that menu has dropped to left. See that buttons on right of underneath form are cut off on right - they do not extend full width. See that one topmost form, form is cut off on left, some textboxes are "falling out" of their frames, most of the boxes on the right like Race, Ethnicity, Language, Maritalstatus are comboboxes but the drop button is not visible. Frames are "falling off" the tab control. Not the large space available in the work area. Bottom screenshot is for comparison.
Attachment 97999
Attachment 97997
Re: Scaling of forms is off
Oh, an MDI application. Is the parent Form intact aside from the left-dropping menus? It seems to look ok above.
I also see right and bottom clipping in the child Forms but no left or top clipping as you said earlier.
Have you checked the DPI settings? If not, try making sure they are at 96dpi ("100%"). Then try running the application again.
At least it is worth ruling it out and on Win7 it doesn't require rebooting.
Writing High-DPI Win32 Applications provides some background and discusses some of the impact of not handling high DPI.
Re: Scaling of forms is off
Goshblimey. This is so embarrassing. I meant to say right and bottom. Right and bottom. Right and bottom. I always get my lefts and rights confused (drove the driving instructor crazy...). Yes, the left is always fine, and the parent window is fine as well.
dilettante, right on! I changed the DPI settings from 110% to 100% and now everything looks normal. Thank you so much!