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?
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
On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
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.
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?
Last edited by Pteranodon; Mar 20th, 2013 at 08:49 AM.
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)?
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?
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.
Last edited by Pteranodon; Mar 21st, 2013 at 06:23 AM.
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!