RamonUnch / GreenPad

Fork from roytam1 fork from original GreenPad
22 stars 0 forks source link

Add Per-monitor DPI awareness #68

Closed RamonUnch closed 1 year ago

RamonUnch commented 1 year ago

1) We must add dpi-awarev2 flag to the .manifest file, be sure also to state that we are compatible with Windows 10 (GUID). We only use PerMonitorV2 so we do not have to worry about scaling the non-client area nor dialog boxes. 2) We must setup the actual size of the font in the Painter constructor, so that when when deleting/creating the Painter, the font size is adjusted for the actual window. For this I created a myGetDpiForWindow() that returns dpix/dpiy 3) initialization of the fontsize made at the moment of config reading must be removed (it was based on device caps of GetDC(NULL)!), The font still has to be scaled properly for the printer using the printer's DC, like before. 4) WM_DPICHANGED message must be handled, in the main hwnd handler we must resize the main window with the RECT provided in lParam, We must also update the Painter calling SetFont( vConfig() ). 5) The brush thickness must adjust with dpi scaling (1px would look too small on high dpi monitors). Even better we directly scale the thickness with regards to the actual font height in pixels, I used 1/16th of font height (seems more or less fine to me). Also the ZSP/HSP height was set to 1/4th of font height (again seems more or less fine to me). I did not fine-tune this a lot; improvements might come later.

Whoops: I realize I also changed DragQueryFiles to myDragQueryFile, should have been a different PR (NT3. beta stuff).

RamonUnch commented 1 year ago

Unfortunately I no longer have a working Win10 environment, so It will have to wait more for actual testing.