plashenkov / TBX

Themeable toolbars, menus and controls for Delphi
MIT License
45 stars 19 forks source link

Element sizes on High-Definition Displays (Windows scaling is 200% or above) DPI is not 96 #10

Open maximmasiutin opened 7 years ago

maximmasiutin commented 7 years ago

Thank you for maintaining the great TBX software.

Please consider adding support for High-definition monitors. Nowadays, lot of users have Windows interface scaling level set to 200% and more, to accommodate to 4K displays, so the screen density is no longer 96 DPI. In Toolbar2000, all item sizes are programmed in physical pixels, not adjusted to screen DPI, so the items like toolbar grips, chevrons, arrows look very small.

So the adjustments are needed to multiply element size to actual screen DPI and divide by 96 (normal DPI). It is usually obtaining by using MulDiv instruction.

For example, see how GetTBXDragHandleSize from TBXThemes.pas will look like:

function GetTBXDragHandleSize(const ADC: HDC; const ToolbarInfo: TTBXToolbarInfo): Integer; const FDragHandleSizes: array [Boolean, 0..2] of Integer = ((9, 0, 6), (14, 14, 14)); begin with ToolbarInfo do begin if AllowDrag then Result := MulDiv(FDragHandleSizes[(CloseButtonState and CDBS_VISIBLE) <> 0, DragHandleStyle], GetDeviceCaps(ADC, LOGPIXELSY), 96) else Result := 0; end; end;

Please consider adding support for custom DPI, other than 96, to accommodate modern high resolution monitors.

I have made a few changes to the code, but it would be better if you fully implement custom DPI support in the main code base.

Thank you very much again for maintaining the TBX library.

plashenkov commented 6 years ago

Hey, sorry for such late reply. GitHub did not notify me about the issues and I was wonder when discovered them here.

Yes, HiDPI is important thing. If you can help with it, please consider making a pull request.

WangPingGang commented 4 years ago

There any progress in this problem? In 4K Resolution display, the Windows scaling is 250%, some icon is really tiny(eg. checkbox, submenu arrow).