High DPI Help lazarus / 39-Graphics ---------------------------------------------------------------------- Weitentaaal · 2021-08-18 12:54 Hello Guys I tried this Tutorial : https://wiki.lazarus.freepascal.org/High_DPI/d e#SCHRITT_1_-_Deklarieren_Sie_High_DPI_Awareness But it did just work half way. If windows is trying to Scale the Application it gets blurred (if i don't mistake  ... sorry heard of this the first time today). i will add some attachements with Pictures how it looks. I do achiev to get a Sharp(non blurred) picture, but thats all. I did not Fully understand the Tutorail so i wanted to ask if some1 could tell me how i should handle every Single Control in relation to the Scaling. I did Position every Single Component with "Anchors". here some Code which might impact this Form Resize Procedure: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TStartUp.FormResize(Sender: TObject);var   i : Integer;begin   // Größe und Position der Steuerelemente anpassen   GroupBox1.Width := Self.Width - 16;   TxProjectNr.Width := round(160 + (GroupBox1.Width - 920) / 3);   TxClient.Width := TxProjectNr.Width;   TxPosition.Width := TxProjectNr.Width;   TxBuilding.Width := TxProjectNr.Width;   TxArrange.Width := TxProjectNr.Width;    // Devicedata Box   ZLDeviceData.Width := round((Self.Width - 24) / 2);   ALDeviceData.Width := ZLDeviceData.Width;    //Zuluft   TxSUairflow.Width := round((ZLDeviceData.Width - (920 / 2)) / 3.5);   LblSUtype.Width := TxSUairflow.Width;   TxSUdpext.Width:= round((ZLDeviceData.Width - (920 / 2)) / 3.5);   TxSUdptot.Width:= TxSUairflow.Width;   CBSUacc.Width:= TxSUairflow.Width;   CBSUconn.Width:= TxSUairflow.Width;   BtnSUsize.Width:= round((TxSUdptot.Width / 3) * 2) - 4;   SUSize.Width:= round(TxSUdptot.Width / 3) - 4;    //Abluft   TxEXairflow.Width := round((ZLDeviceData.Width - (920 / 2)) / 3.5);   LblEXtype.Width := TxEXairflow.Width;   TxEXdpext.Width:= round((ZLDeviceData.Width - (920 / 2)) / 3.5);   TxEXdptot.Width:= TxEXairflow.Width;   CBEXacc.Width:= TxEXairflow.Width;   CBEXconn.Width:= TxEXairflow.Width;   BtnEXsize.Width:= round((TxEXdptot.Width / 3) * 2) - 4;   EXSize.Width:= round(TxEXdptot.Width / 3) - 4;    // Zeichenfläche   Drw.Top:= ZLDeviceData.Top + ZLDeviceData.Height + 8;   Drw.Width := Self.Width - 24 - GBAirDir.Width;   Drw.Height := Self.Height - Drw.top - 30;    // Skalierung der Zeichenfläche anpassen   ScaleDRW;    // Größe der Icons anpassen (müssen nochmals neu geladen werden)   InitBTLIcons;   InitBTLWkzIcons;end;  Wrote this in FormCreate of MainForm (Just to test on main Form) : ScaleDPI(Self, 96); // 96 DesignTime DPI Wert Any Help would be Welcome (Excuse my English ... still young, still learning) Ps: Pictures Size was to large --> 4 Pics in the Zip ---------------------------------------------------------------------- wp · 2021-08-18 13:55 Lazarus v1.8+ has built-in High-DPI support. All you have to do is to check the "Use LCL scaling" box in the project options, and on Windows, select one of the "on" choices in the "DPI awareness" combobox. Do not use the scaling routines of the wiki article, read the English article (https://wiki.lazarus.freepascal.org/High_DPI#High _DPI_in_Lazarus_1.8_and_above), the German translation is outdated (a severe problem in the wiki infrastructure...). ---------------------------------------------------------------------- Weitentaaal · 2021-08-18 14:26 Thnak you very much wp Does it rescale my Application if i change DPI at runtime ? Edit: Tested it but did not work(Attached Picture of Settings). Form is Scaled but i gueass by Windows because everything is blurry on 125% and 150% is just a mess. My Customers need both. Any idea what i could have done wrong ? Does setting Font Size at DesignTime a Difference (its 0 so should i set it to 9) ? ---------------------------------------------------------------------- wp · 2021-08-18 15:20 When fonts are blurred then Windows does not reckognize that the application is scaled and does the scaling itself. IIRC there is a Highi-DPI compatibility option in the properties of the application: right-click on the application in the explorer to open the Properties dialog of the app, select page "Compatibility". In Win10, there is a "Change High-DPI settings" button. In the next dialog nothing is checked on my system. There is also a link "Open extended scaling settings" into the system settings which contains a button "Windows can try to correct blurred app" which is checked on my system. I remember that the exact steps have changed during the evolution of Win10. (Note that the Windows texts are translated to English and may be slightly different in reality). In the attachment I show a screenshot of the MyDBFStudio application which was compiled at 96ppi; the screenshot was taken at 144ppi and is perfectly clear. ---------------------------------------------------------------------- Weitentaaal · 2021-08-18 15:22 Love to See it .. thanks for your time i will update this Post and tell if it worked ---------------------------------------------------------------------- Weitentaaal · 2021-08-19 05:33 Quote from: wp on August 18, 2021, 05:20:27 pmWhen fonts are blurred then Windows does not reckognize that the application is scaled and does the scaling itself. IIRC there is a Highi-DPI compatibility option in the properties of the application: right-click on the application in the explorer to open the Properties dialog of the app, select page "Compatibility". In Win10, there is a "Change High-DPI settings" button. In the next dialog nothing is checked on my system. There is also a link "Open extended scaling settings" into the system settings which contains a button "Windows can try to correct blurred app" which is checked on my system. I remember that the exact steps have changed during the evolution of Win10. (Note that the Windows texts are translated to English and may be slightly different in reality). In the attachment I show a screenshot of the MyDBFStudio application which was compiled at 96ppi; the screenshot was taken at 144ppi and is perfectly clear. "In the next dialog nothing is checked on my system." "There is also a link "Open extended scaling settings" into the system settings which contains a button "Windows can try to correct blurred app" which is checked on my system." Same here Only time it worked was when i used the old code from this :  https:// wiki.lazarus.freepascal.org/High_DPI/de#SCHRITT_1_- _Deklarieren_Sie_High_DPI_Awareness I did change Settings to let Lazarus handle High DPI Porpertys  of exe are the same as u described yours what did i forget ? is there some danger in using the old Code ? Mybe this CodeLine has an impact : "Application.Scaled:=True;"? ---------------------------------------------------------------------- Weitentaaal · 2021-08-19 05:41 Update : Got it Now I just played around in the Settings but do not know exactly what was wrong. Any Tips on how i should Handle the Sizes of the different Components. I positioned them with Anchor Docking but the width i calculate on my own, without success. ---------------------------------------------------------------------- dseligo · 2021-08-19 05:54 Try to create new project and then set 'Use LCL scaling (Hi-DPI)' and 'DPI awareness'. 'Scaled' property of form must be true - it is default value. Then change DPI of your system and see if your application is scaled. I suggest to create new project because I had problems when I transferred one project from computer with different DPI. There is property of form - 'DesignTimePPI', you can't see it in Object inspector, only in .lfm. It could be that your form's DPI is different from your system's DPI. After I changed all forms' DPI to my current DPI it all worked. ---------------------------------------------------------------------- dseligo · 2021-08-19 05:56 Quote from: Weitentaaal on August 19, 2021, 07:41:30 amAny Tips on how i should Handle the Sizes of the different Components. I positioned them with Anchor Docking but the width i calculate on my own, without success. From https://wiki.lazarus.freepascal.org/High_DPI#High_DPI_in_Lazarus_ 1.8_and_above: QuoteIf you create controls run-time, scale all coordinates, sizes etc that have to be DPI-aware with TControl.Scale96ToForm() or ScaleDesignToForm() (depending on your choice of default PPI) or prepare your container (e.g. panel with controls) as it was with 96 PPI and then call TControl.AutoAdjustLayout(lapAutoAdjustForDPI, 96, ParentFormOfTheContainer.PixelsPerInch, 0, 0); ---------------------------------------------------------------------- Weitentaaal · 2021-08-19 06:43 Thanks @dseligo, already got it Working but thanks for your replys. I will do it and make Sure it works everywhere perfect. EDIT: In Some Forms i do get Access Violation and it Tells me That Some Labels aren't floats ? Error only occurs when im on high DPI like 150% ---------------------------------------------------------------------- dseligo · 2021-08-19 08:03 Quote from: Weitentaaal on August 19, 2021, 08:43:33 amEDIT: In Some Forms i do get Access Violation and it Tells me That Some Labels aren't floats ? Error only occurs when im on high DPI like 150% Please post exact errors you are getting. Do you also manipulate controls' sizes in your code? ---------------------------------------------------------------------- Weitentaaal · 2021-08-19 09:05 No but i just tested the High DPI for my main Form i will just go from form to form and make everything again with anchor Sides, maybe it Fixes the problem because i just drag and dropped all other Forms  (First Lazarus Project Sorrry ). But another Question: What could i do if some of my Controls are not Always Visible ? Bc then it wont work like it Should. EDIT: I Did Some Screenshots of the Error. EDIT2: "Est1" is a TLabel EDIT3: Does the LCL Scaling check if Form is in Window Mode or in FullScreen Mode ? Looks like the Windows Taskbar is not considered. ---------------------------------------------------------------------- wp · 2021-08-19 11:18 AFAIK, LCL scaling only looks for changes in the DPI of the used monitor. When there are issues with Window or FullScreen mode, then these are issues of your layout. As long as you use the same OS version there is no need to anchor the controls, because text and controls grow or shrink with the same factor. But when you move to a different OS or a different theme, the font may have a different size and could no longer fit to the size of the controls (this is a general issue, it happens also in non-high-dpi screens). Therefore, it is always a good idea to use the anchor editor to attach the controls to each other. ---------------------------------------------------------------------- Weitentaaal · 2021-08-19 12:12 Thanks wp and dseligo ... very helpfull !!!