Home » U++ Library support » Draw, Display, Images, Bitmaps, Icons » Native DPI
Re: Native DPI [message #44702 is a reply to message #44699] |
Fri, 29 May 2015 10:16   |
 |
mirek
Messages: 14265 Registered: November 2005
|
Ultimate Member |
|
|
Tom1 wrote on Thu, 28 May 2015 09:47Hi,
This is what I tried.
Added file manifest.xml to the ide package to enable per-monitor DPI awareness:
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3" >
<asmv3:application>
<asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
<dpiAware>True/PM</dpiAware>
</asmv3:windowsSettings>
</asmv3:application>
</assembly>
This also needs a Custom build step to be added for WIN32 - post-link to be effective:
mt.exe -manifest manifest.xml -outputresource:$(EXEPATH);1
Then added two Size variables to TopWindow class in TopWindow.h:
Size currentdpi;
Size primarydpi;
Finally added two new cases to TopWindow::WindowProc in TopWin32.cpp:
case WM_CREATE:{
HDC hdc=GetDC(hwnd);
primarydpi=Size(GetDeviceCaps(hdc,LOGPIXELSX),GetDeviceCaps(hdc,LOGPIXELSY)); // Returns primary display DPI
ReleaseDC(hwnd,hdc);
// RLOG(Format("WM_CREATE: primary DPI(%d,%d)",primarydpi.cx,primarydpi.cy));
break;
}
case 0x02E0: // WM_DPICHANGED -- e.g. moved window to another monitor with different DPI
// WndSetPos(Rect(*(RECT*)lParam)); // LPARAM: RECT* of suggested new window pos -- non-optimal
currentdpi=Size(LOWORD(wParam),HIWORD(wParam)); // Get DPI setting for current display monitor
// RLOG(Format("WM_DPICHANGED: current DPI(%d,%d)",currentdpi.cx,currentdpi.cy));
if(primarydpi.cy&¤tdpi.cy){
String face;
int height;
GetStdFontSys(face,height);
SetStdFont(GetStdFont().Height(height*currentdpi.cy/primarydpi.cy));
GUI_HiDPI_Write(currentdpi.cx>150?1:0); // This does not work optimally here.
}
break;
Possible DPI values returned by Windows depending on scaling set in Control Panel / Display:
96 DPI = 100% scaling
120 DPI = 125% scaling
144 DPI = 150% scaling
192 DPI = 200% scaling
... but there may be even more available. I think I saw 250% somewhere already.(?)
---
The result is that Font size scales properly when moving the window between the two monitors with different DPI -- 192 and 96 in my case.
There are problems though:
- Line spacing in lists does not adjust according to the StdFontSize while the actual fonts in the lists do.
- Check boxes, radio buttons, scroll bars and spin control arrows in dialogs remain in the HI-DPI mode regardless the change in the mode.
- Manually set font sizes in TheIDE do not scale according to the changes in StdFontSize. In fact, it would be very useful to just declare a scaling percentage e.g. 25... 400 in comparison to the StdFontSize for these fonts instead of their actual sizes. This would keep them proportionally sized even in single monitor scenarios where display scaling is changed in Windows Control Panel.
Further on I think all controls should be scaled and drawn based directly on a per TopWindow defined StdFontSize. This becomes evident when opening a new dialog on a different monitor or moving it onto another monitor. Then scaling really gets out of control.
Best regards,
Tom
I am afraid that per-window scaling is a massive change. We will do it eventually, but for the next release, I would concentrate on 'Vista style' DPI awareness (means primary UHD display scaled by us, secondary non-UHD display scaled down by windows).
(Note that HiDPI is not the primary focus of next release; new Assist++ parser, better support for C++11 are main topics).
Mirek
|
|
|
 |
|
Native DPI
By: Tom1 on Thu, 21 May 2015 11:45
|
 |
|
Re: Native DPI
By: mirek on Sat, 23 May 2015 20:23
|
 |
|
Re: Native DPI
By: Tom1 on Sun, 24 May 2015 10:29
|
 |
|
Re: Native DPI
By: mirek on Sun, 24 May 2015 21:16
|
 |
|
Re: Native DPI
By: Tom1 on Mon, 25 May 2015 10:05
|
 |
|
Re: Native DPI
By: Tom1 on Mon, 25 May 2015 16:54
|
 |
|
Re: Native DPI
By: mirek on Mon, 25 May 2015 23:13
|
 |
|
Re: Native DPI
|
 |
|
Re: Native DPI
By: Tom1 on Tue, 26 May 2015 10:22
|
 |
|
Re: Native DPI
By: mirek on Wed, 27 May 2015 10:03
|
 |
|
Re: Native DPI
By: mirek on Wed, 27 May 2015 10:14
|
 |
|
Re: Native DPI
By: Tom1 on Wed, 27 May 2015 13:32
|
 |
|
Re: Native DPI
By: mirek on Wed, 27 May 2015 14:13
|
 |
|
Re: Native DPI
By: Tom1 on Thu, 28 May 2015 09:47
|
 |
|
Re: Native DPI
By: mirek on Fri, 29 May 2015 10:16
|
 |
|
Re: Native DPI
By: mirek on Fri, 29 May 2015 13:27
|
 |
|
Re: Native DPI
By: Tom1 on Fri, 29 May 2015 17:23
|
 |
|
Re: Native DPI
By: mirek on Sat, 06 June 2015 07:37
|
 |
|
Re: Native DPI
By: Tom1 on Mon, 08 June 2015 10:31
|
 |
|
Re: Native DPI
By: mirek on Sat, 13 June 2015 17:04
|
 |
|
Re: Native DPI
By: Tom1 on Mon, 15 June 2015 00:00
|
 |
|
Re: Native DPI
By: mirek on Mon, 15 June 2015 14:01
|
 |
|
Re: Native DPI
By: Tom1 on Tue, 16 June 2015 22:13
|
 |
|
Re: Native DPI
By: mirek on Tue, 16 June 2015 23:37
|
 |
|
Re: Native DPI
By: Tom1 on Wed, 17 June 2015 10:02
|
 |
|
Re: Native DPI
By: mirek on Fri, 19 June 2015 08:26
|
 |
|
Re: Native DPI
By: Tom1 on Mon, 22 June 2015 11:52
|
 |
|
Re: Native DPI
By: Tom1 on Fri, 26 June 2015 09:13
|
 |
|
Re: Native DPI
By: mirek on Mon, 03 August 2015 20:11
|
 |
|
Re: Native DPI
By: Tom1 on Wed, 05 August 2015 13:03
|
 |
|
Re: Native DPI
By: mirek on Wed, 05 August 2015 14:56
|
 |
|
Re: Native DPI
By: Tom1 on Wed, 05 August 2015 15:50
|
 |
|
Re: Native DPI
By: mirek on Sun, 09 August 2015 13:22
|
 |
|
Re: Native DPI
By: Tom1 on Mon, 10 August 2015 11:12
|
 |
|
Re: Native DPI
By: Tom1 on Thu, 13 August 2015 12:22
|
 |
|
Re: Native DPI
By: mirek on Tue, 18 August 2015 20:10
|
 |
|
Re: Native DPI
By: Tom1 on Wed, 19 August 2015 13:07
|
 |
|
Re: Native DPI
By: mirek on Wed, 19 August 2015 22:35
|
 |
|
Re: Native DPI
By: Tom1 on Sat, 22 August 2015 09:56
|
 |
|
Re: Native DPI
By: mirek on Sun, 23 August 2015 12:23
|
 |
|
Re: Native DPI
By: Tom1 on Sat, 29 August 2015 13:54
|
 |
|
Re: Native DPI
By: mirek on Sat, 29 August 2015 18:26
|
 |
|
Re: Native DPI
By: Tom1 on Mon, 31 August 2015 10:24
|
 |
|
Re: Native DPI
By: Tom1 on Mon, 31 August 2015 14:38
|
 |
|
Re: Native DPI
By: mirek on Wed, 02 September 2015 16:11
|
 |
|
Re: Native DPI
By: Tom1 on Thu, 03 September 2015 09:07
|
 |
|
Re: Native DPI
By: mirek on Fri, 04 September 2015 08:51
|
 |
|
Re: Native DPI
By: Tom1 on Fri, 04 September 2015 10:10
|
 |
|
Re: Native DPI
By: mirek on Sun, 06 September 2015 07:35
|
 |
|
Re: Native DPI
By: Tom1 on Mon, 07 September 2015 10:55
|
 |
|
Re: Native DPI
By: mirek on Sun, 04 October 2015 08:07
|
Goto Forum:
Current Time: Sat Jul 05 10:38:17 CEST 2025
Total time taken to generate the page: 0.03863 seconds
|