Why does scaling of controls differ between PC's? - delphi

I try to give the user a 'clean and simple' interface by hiding some elements. Only a small arrow denotes that he can expand some part of the main menu bar. When all is closed it looks like this:
When you open all it looks like this:
Each arrow is a SpeedButton thats sits on the left side of a panel. By clicking on the button the Width is toggled between the width of the Speedbutton (closed) and the width of the panel at design time (open). The width of the panel at designtime is stored as a constant. The procedure show_hide_controls handles this:
procedure TCompose_Main.show_hide_controls (key: string; Button: TSpeedButton; Panel: TPanel; width: Int32);
begin
if GPA.iKey [key] = 1
then Panel.Width := width // show panel, set panel to design width
else Panel.Width := Button.Width; // hide panel, set with to button width
Button.Glyph.Assign (nil);
Images_Left_Right.GetBitmap (GPA.iKey [key], Button.Glyph);
end; // show_hide_controls //
This routine is called as follows:
show_hide_controls ('Show Play Controls', // index to panel to show/hide
Enlarge_Play, // Speedbutton requesting the enlargement/hide
Panel_Play, // Panel to show/hide
cPlayWidth); // Width of panel when shown
Now several users report that part of the panel is hidden, like:
It seems that the operating system (Windows 7) plays some tricks with scaling. I'm not able to duplicate this error. Does anyone understand what is happening here? And is there a neat way to program against this in a settings independent way?
Update As GDF rightly pointed out in his answer it has to do with the scaling of the fonts (control panel > Display). This behaves somewhat weird on my machine. Changing it to 150% has a minor impact while changing it to 125% has a major impact. As you might have guessed I tested the first and not the second scaling. Only when a user reported that scaling back from 125% to 100% I could replicate his error on my machine.
I could not find a relation between fonts and the troubles I have as was suggested by several respendents. My system is still suffering from all the tests I did with Courier (not new), Segoe UI, Tahoma and MS Sans Serif :-D. Maybe indirectly because the controls are probably resized to accomodate the text.
How to handle this? I don't know, I'll start experimenting and will let you know if I find something.
Thanks to you all for your help!

If your problem is what I believe, you just stated the answer. Windows 7 plays with scaling certain fonts. When you install Win7 on a PC it checks the size of your monitor and makes the "default" scale setting either 100% or 125% depending on your monitor size. The problem is that at this same time it installs font files onto the computer. It uses a different font file for the different "default" for some of the fonts.
My guess is your app is using MS Sans Serif... this is one of the fonts that gets different font file installs depending on what scale Win7 is using as the (default).
To verify this have your users tell you want scale is set as the default, you can view this by right clicking the desktop and selecting "personalize" then "Display" at the bottom left.
The following link shows you how to change the in-use-font file back to the original
http://www.rlvision.com/misc/windows_7_font_bug.asp
However, I would make an attempt to get off of this font and update the layout elements to work as desired on Win7 as well as past OSes
This is what I think you are dealing with given the limited amount of information you have provided...
Update
Since you reminded me when you mentioned the different looks between 125% v 150%. I just wanted to make sure you were aware that the two different MS Sans Serif files looks better at different scales. One of the font files looks great at 100% and 150% but horrible at 125%. The other font file looks great at 125%, but horrible at 100 and 150%.
I don't quite remember which font file is which, but I know the 2 culprits are
1) SSERIFF.FON
2) SSERIFE.FON

Related

Delphi 11.2 Patch 1 frames and High-DPI

I have encountered a problem with Delphi's multi monitor high-DPI support that I would welcome any insights you might have. I am using Delphi 11.2 patch 1 on a 5K monitor with Delphi's form designed set to Automatic (Screen PPI)
I have a small test project with a TDBAdvGrid and a TDBNavigator at the top of the form and a separate Tframe at the bottom of that form added at design time also having a TDBNavigator and a TDBAdvGrid on it. When I run the program initially it all looks fine.
As I said,I am designing on a 5K monitor (5120x2880) at 200% font scaling and I have a second monitor attached (1920x1080) at 100% font scaling. If I drag the form onto the second monitor the grid and navigator on the form appear to respond nearly as they should (just doesn't get the column widths quite correct) but the grid and the navigator in the TFrame don't.
Then if I drag the form back to the main monitor the TFrame is even more messed up
Do you have any recommendations on how to handle this? Should I be doing something with the main form's onBefore/OnAfterMonitorDPIChange events?
This high-DPI stuff all seems very much work in progress. And if I wanted to persist the column widths in an ini file, how would that work? Would I have to save it separately for each monitors PPI settings?

Delphi - how to customize IDE layout

Delphi 2010 - all patches, Win 8.1 64 bit. Reinstalled EVERYTHING... windows,etc, so functionally a new machine. Installed D2010, then installed GExperts and CnPack Wizards, as I had used them both before a really liked them.
I have 2 monitors, so I changed my layout to Classic Undocked. The default is to have the component palette at the top right of the Delphi main window.
In my previous release, I was able to change the HEIGHT of this window to double whatever it is now, and drag the palette UNDERNEATH the glyphs from the File / Edit / Search area, so that way my component palette went across the whole screen. For whatever reason, I cannot do this now. When I move my mouse to the BOTTOM of the delphi window area, I get the "expand window up and down" cursor, like I should, but the window refuses to increase in height. There is some setting preventing me from increasing this windows height, but I can't find it. What setting am I looking for in order to be able to increase the height, so I can drag/drop my palette to the bottom LEFT corner of this window?
Thanks
The size of the main undocked window cannot be modified by resizing it manually. It is sized so that it is exactly large enough to contain its children. So, you can do what you want by moving the component palette to the desired location. When you do so the main window will increase in size so that the component palette fits.
Judging by your screenshot, your toolbars are drawn in a way to indicate that they are locked and cannot be dragged. That's not functionality that is present in the plain vanilla Delphi IDE, so I suspect that you have used functionality from either GExperts or CnPack to lock your toolbars. Obviously you'll need to unlock them in order to move them.
Finally, I should point out that the inability to resize the main window vertically is not new. Classic Delphi versions (e.g. Delphi 7) behaved in exactly the same way. So I think that the fundamental issue is not related to a Delphi version upgrade, but rather is related to you having locked your toolbars.

Greyed TWebBrowser control

When TWebBrowser control is too small it becomes greyed.
If TWebBrowser control is aligned to alClient and there are no other controls on the form I can make it really small (50x10 for example). However, when I add other controls like panels, toolbar, main menu and so on which all float on top (alTop) - the more controls I add it seems, the smaller window of TWebBrowser I can get without greying itself. When window is resized to become larger, then it becomes ungreyed again.
In this example I placed TToolBar with 2 buttons aligned to alTop, and TWebBrowser aligned to alClient. If I make toolbar invisible, I can make web browser really small. However, with toolbar visible it greys itself. The more controls I add it seems to have less and less usable space before greying itself.
As you can see in last example web browser is even smaller than in second example but still visible and everything is the same except there is no toolbar on top. Same applies if used on Windows 7 or 8 or with Internet Explorer 10 or 11.
The examples here are just examples. I don't have a problem with having 100x100 control as minimum size. The problem is that when I place quite a bit of controls then it doesn't allow me to have smaller control than 550x250, which is quite large.
Can anyone enlighten me why other controls have an effect on web browser not being able to use smaller size when it can do this perfectly normally when there are no other controls on form?
Many thanks to bummi in the comments up there for finding a following workaround:
It appears that the problem with greyed control doesn't appear in XE3 and later but can be reproduced in earlier versions like XE2, XE, 2010 and 2009.
For these earlier versions the workaround is to place TWebBrowser on another control such as TPanel and then align both controls to alClient (so that the TWebBrowser fills entire TPanel and TPanel fills entire area previously filled by TWebBrowser). Of course, alignment here is not an issue but the workaround is just to place one control on another.
The same works for TEmbeddedWB and probably other controls that host Internet Explorer ActiveX control.
When placed on container control like TPanel, web browser can be resized to any size without the problem described above.

How to make my Deskband's (Taskbar Toolbar) Form transparent

I'm working on a Windows Deskband in Delphi XE2 for Windows XP, Vista and 7 (Win32 and Win64)...
I've implemented all the necessary interfaces (ITrayDeskBand, IDeskBandInfo, IDeskBand2, IDeskBand) in my code, and that all works exactly as it should (there are no warnings on Vista/7 complaining about compatibility as others have experienced).
The problem I have is that my Deskband Form appears with a non-transparent band. Also, only certain Controls are displaying (in this case TBitBtn and TImage containing a PNG). I need it to display TEdit and TComboBox objects properly too, but they won't appear at all.
I've tried enabling GlassFrame and SheetOfGlass properties on my Form, but this doesn't help one bit.
Furthermore, the Form itself is exceeding the top boundary of the Taskbar, meaning you cannot (for example) resize the Taskbar if the cursor is in-line with the top of the Taskbar immediately above my Deskband.
I believe there is something Delphi's VCL TForm type is doing behind the scenes which renders the TForm type incompatible as a Deskband container... but this is just a suspicion.
Here's a screenshot illustrating the various problems:
As you can see (above), the Deskband's Form is pale (instead of Transparent), it overlaps the top of the Taskbar (preventing resizing and Autohide triggering when the Taskbar is "hidden")
Any ideas?
UPDATE 1
Okay, I have been playing around and noticed that a totally different behaviour is observed when creating a TToolBar control to be used for the Deskband, rather than a form:
Notice there are three TToolButton controls (with their text virtually invisible due to the Glass theme)? There should also be a TEdit and TComboBox between two separators, but these refuse to display at all.
Also notice the artefacting (the repetition of actual Taskbar Icons)?
I'm not sure if this is a step in the right direction or not, but it might help you (or others) to deduce a solution!
Okay... I've finally figured this out, and it is the most absurd thing I've ever come across.
I'm posting my findings here for the benefit of others (to save you going through the nuisance I've just been through).
To get all of the controls on your Deskband Form to display and function properly, simply set the Visible property of your Form (in the IDE designer) to True.
Ridiculous, I know, but it works and is easily repeatable.

Delphi apps, form size varies on different machines

I've got a Delphi 7 app, on the WinXP development machine the form size is the same as it was designed.
However, running the app on a Vista machine, some forms have been enlarged 20-30%, leaving big blank spaces on the right and bottom edge of forms.
On one of our client's WinXP machine, the forms have shrink, causing scroll bars to show up on the forms.
On most other machines, it shows up OK.
The app does remember the form size that was last used on some forms, and uses it next time the form is opened, however even removing these settings, the default form size is still different to how it was designed.
Any ideas?
This sounds like a well known issue with Delphi forms and interactions with system font sizes.
The default behaviour of a Delphi form is to attempt to scale to respect the (runtime) user's desktop environment. This can have unintended and undesirable side effects however, and your "symptoms" sound like this could be what's going on in your case.
But all is not lost! The Scaled property (TRUE by default) can be set FALSE to prevent this, but I recommend you read that first article, and also consider The information in this article in order to determine whether this is the right solution in your case.
Large Fonts versus Small Fonts on the Vista machine maybe?
Use this code in OnCreate event for every your form:
if Win32Platform = VER_PLATFORM_WIN32_NT then
Font.Name := 'MS Shell Dlg 2'
else
Font.Name := 'MS Shell Dlg';

Resources