How do you fix scaling issues with MPLABXIDE (with MCC) in Windows 10 when using a HiDef display? - mplab

MPLAB X IDE (Ver 5.30) starts scaled to a proper resolution reflecting the scaling settings in Windows; but, when the MCC plugin is started it results in the refresh of the Window and the window shrinking back to 100% scaling with MCC parts alone scaled to the system settings. This makes the IDE unusable on those displays.

Fixing this is a multi step process.
Set the underlying Netbeans IDE to be DPI aware, by adding -J-Dsun.java2d.dpiaware=true to end of the default_options line in mplab config file at C:\Program Files (x86)\Microchip\MPLABX\v5.xx\mplab_platform\etc\mplab_ide.conf.
Then change the system settings for scaling MPLAB to be correct
Right click on MPLAB icon on desktop.
Choose Properties.
Go to Compatibility tab.
Click on the Change high DPI settings button
Tick Overide high DPI scaling and choose System or System (Enhanced) in the dropbox.
Click OK then Apply
This worked on Windows 10 19.05 on a Surface Book

Related

Delphi 11 - scaling and font size problems

I have a VCL application that works fine with D10.4. Created with D11, all elements of the form are displayed greatly enlarged at runtime.
Depending on the project settings (Project/Options/Manifest) you can make the program run on the development computer with a 4K monitor in the specified font (everything set to 8 points).
If you start the same program on an HD monitor, all elements except the main menu (!) are displayed in a larger font.
Windows settings on the 4K: 200% scaling, on the HD: 100%
The Delphi has all patches up to 2/22.
The exe, created with 10.4, runs perfectly on both test computers.
Is there a solution for this or do I actually have to build an own environment for VCL apps?
Is there maybe a hidden option to disable all this scaling stuff?
Thanks for every hint!
Many greetings

Scaling DbGrid Indicator and DbNavigator Icons on 4K display

I am using DPro Rio 10.3 on an HP Spectre x360, which has a 4K display. The indicator on DbGrids and icons for DbNavigator controls scale fine at 1980 X 1080, but are almost invisible at 4K resolution. Text scales fine at any resolution.
I looked at the source code for both components and they contain methods which use LoadfromResource to load the appropriate graphic from the executable. TDbNavigator calls LoadfromResourse in a virtual method, SetButtonGlyph at runtime.
In addition, the DbGrid code seems to make an effort to scale the indicator in one of its methods. This, however, does not work, at least on my laptop.
FYI, I have set the form's Scaled property to TRUE. I have also tried several settings in the manifest, but none make a difference.
How can I fix this problem. Is it because these controls use a 16 x 16 graphic or is there some other cause? Is there a way to replace the graphics for each component with ones of higher resolution either in the executable resource file or programatically at runtime?
I stumbled across the answer from a post on the TMS Software website. In order to display properly on 4k screens, DPI awareness must be set to none. I tested this both in Rio and Tokyo, and it works. For Rio, you would select Project|Options and go to the Application section. Select Manifest and from the dropdown box for DPI Awareness, select None.
For Tokyo, also Project|Options, go to Application and uncheck Enable DPI.

Delphi program resolution

We have a Delphi 7 program running on Windows 7 Professional SP1, developed approximately 10 years ago. On the current system, it became unusable as some form elements have incorrect size so the text they contain doesn't fit there or the graph overflows the bottom of the window:
Picture 1: Table rows have incorrect size (or the text is bigger than it should be)
Picture 2: There is a graph in the window but the bottom part of the graph isn't visible. And there are no scrollbars...
We have no source code nor we do we have contact with the people who developed the software. We think the software was built in Delphi 7 because it uses several xxxx70.bpl libraries.
We tried to change resolution of the screen and change compatibility mode used to run the program with no luck.
Is there anything we can try?
Your program is not DPI aware, and you are running with font scaling settings that mean the application is asked to scale. The application font is scaled automatically but your Delphi application does not adapt.
I can see some options for you:
Run your machine with 100% font scaling.
Run your machine with >125% font scaling. Then DPI virtualization will kick in which should fix the issue. Although the app may appear fuzzy as it will suffer aliasing when scaled.
Try to find a compat setting that forces DPI virtualization. Don't know if such a thing exists.
Edit the .dfm resources in the executable to set the Scaled property to true. This would require a resource editor that understands Delphi. For instance XN resource editor. I've no idea whether or not this will work. If it does work, each form will re-scale themselves according to the font scaling.
Update
Forcing DPI virtualization won't help, on second thoughts. The system will tell your app that the font scaling is 125% and scale from there. But your app won't even handle 125% scaling correctly it seems. So you have little option other than to disable all font scaling or perhaps try with the Scaled property.

Incorrect screen width and height reported by Delphi 3

I have a Delphi 3 app which has been distributed far and wide for at least a decade. Today I received a report that the app is not functioning properly on an Asus Transformer T100TA-C1-GR(S) Windows 8 tablet. Specifically, the app is refusing to run because it detects a screen resolution too small for the app to properly display itself. In the app, I have the following conditional check:
if (Screen.Width < 800) or (Screen.Height < 600) then begin
// display a message reporting screen resolution too low
ShowMessage('blah blah...');
Application.Terminate;
When I compiled a special version of my app to help debug the problem, and gave the app to the complaining user, they report back the following numbers:
Width: 980
Height: 550
Here is the extra code I added the special compilation that I then gave to the user:
ShowMessage('Width: ' + IntToStr(Screen.Width) + #13#10 +
'Height: ' + IntToStr(Screen.Height));
The user, however, swears that their tablet is configured to 1368x768. They even switched to 1024x768 and the same incorrect numbers are being reported by Delphi.
All TForm.Scaled properties are set to False.
One clue that might help... The screen width and height detection code (above) is run within the following procedure:
procedure TForm1.WMDisaplayChange(var m: TWMDisplayChange);
Any idea what might be going on?
Your application is subject to DPI virtualization. Your app has not indicated to the system that it is aware of and supports high DPI display devices. The machine in question uses a font scaling of greater than 125%. That's the high DPI cut off point. Beyond that scaling, the system virtualizes the font scaling for non DPI aware apps. From the documentation:
Windows Vista introduced a feature called DPI virtualization, which provides a level of automatic scaling support to applications that are not DPI–aware. With this feature, Windows scales the size of the text and UI elements of applications that are not DPI-aware so that they are appropriately sized on high DPI settings without changes in the application. This prevents potential usability and readability issues that occur when applications render too small on high DPI screens.
In Windows Vista through Windows 8, this feature provides "virtualized" system metrics and UI elements to not DPI–aware applications, as if they are running at 96 DPI. The application then renders to a 96 DPI off-screen surface and DWM scales the resulting application window to match the DPI setting. For example, if the DPI display setting is 144, DWM scales the application's window by 150%, or 144/96.
A consequence of this is that the system fakes the screen dimensions. When your application is DPI virtualized the system reports the virtualized dimensions rather than the true dimensions.
Best practice is to declare your application to be high DPI aware, and scale the UI according to the user's font scaling preferences. Of course, this is going to be quite a change for you. Possibly not one that you wish to take one.
Another option is to ask the user to use a reduced font scaling. They probably won't be very keen on that either.
Yet another option would be to manifest your app to be high DPI aware and continue not to scale it. Then it would certainly run, but it would fail to respect the user's font scaling preferences. Again, I imagine that the user would be non-plussed.
If you don't currently manifest your app, then doing so now will result in it not being virtualized. And by that I mean app virtualization rather than DPI virtualization. Whilst you really should not still be running virtualized, you may run into trouble if you disable virtualization.
And Sertac suggests another option. Get the user to apply compatibility settings for your app to disable DPI virtualization. You could apply that to the app as it is today, without re-compiling and at least your user would be able to make progress.
Fundamentally, there is a problem with your user's machine setup. If it has 768 vertical pixels and around 140% scaling, that really is a 100% scaled equivalent of 550 pixels. That's not very many pixels. Your application is objecting because the screen is too small and, well, perhaps that really is the case.
This various answers here may be useful to you: How do I make my GUI behave well when Windows font scaling is greater than 100%

Windows 7-compatible icon set in a Delphi 2007 application

What is the right way to define a win7-compatible icon set in a Delphi application ? ( variable size on desktop )
I have designed a 256*256 icon then made the 16*16, 24*24, 48*48 variants. ( in Microsoft UX guide, they seem to say that these sizes should be included for a correct display on the desktop).
I've put all icons variations in a multiple layer document in Gimp and exported the whole stuff as an ico. Then I've put it as the application icon in the project options, following the straight way to assign an icon to an application.
FInally I've put a shorcut on Win desktop (win7) but when making "Ctrl+Wheel" (resizing of desktop icons, if you don't know it yet...) on the desktop (Win 7), correct icon is not displayed, after 48*48 it keeps the same size ( I suspect that only the 48*48 version is used).
The 256px sized icon should be a compressed PNG icon. I suspect that the resource compiler shipped with Delphi 2007 won't like that format so you'll need to use the MS resource compiler, rc. The icon should be named MAINICON. That said, I suspect that a 256px bitmap will work, it will just be exceedingly large.
What's more, IIRC, the Delphi IDE doesn't like 256px PNG icons so it's no good adding the icon to the project through the IDE. You need to build the .res file yourself and link it with a {$R ...} directive.
Finally, its possible that your .ico file may not be correct. The 256px image is actually stored with width and height equal to 0 because that field is byte sized and 0 was formerly invalid. Perhaps this is what the IDE gags on. Check the .ico file out in a different tool, e.g. IcoFX.
There may be other problems—these are just the ones I can recall encountering over the years. If I had to guess as to which issue was biting you, I'd say it was the inability of the IDE to handle 256px icons.
I believe that the IDE has got progressively better in this area in more recent versions, but even in D2010 which I currently use, it's not perfect.

Resources