diff --git a/CapsLockIndicatorV3/BetterCheckBox.cs b/CapsLockIndicatorV3/BetterCheckBox.cs index b22ad1d..d2e6915 100644 --- a/CapsLockIndicatorV3/BetterCheckBox.cs +++ b/CapsLockIndicatorV3/BetterCheckBox.cs @@ -44,6 +44,20 @@ public BetterCheckBox() : base() SetStyle(ControlStyles.SupportsTransparentBackColor, true); } + protected override void OnMouseDown(MouseEventArgs mevent) + { + base.OnMouseDown(mevent); + if (_darkMode) + Invalidate(); + } + + protected override void OnMouseUp(MouseEventArgs mevent) + { + base.OnMouseUp(mevent); + if (_darkMode) + Invalidate(); + } + protected override void OnPaint(PaintEventArgs e) { var bgColor = Parent?.BackColor ?? BackColor; @@ -63,7 +77,7 @@ protected override void OnPaint(PaintEventArgs e) } else { - var scaling = DPIHelper.GetScalingFactorPercent(); + var scaling = DPIHelper.GetScalingFactorPercent(Handle); var border = N_Border; var background = N_Background; var check = N_Check; diff --git a/CapsLockIndicatorV3/BetterTabControl.cs b/CapsLockIndicatorV3/BetterTabControl.cs index 1a0c2cd..1c024fd 100644 --- a/CapsLockIndicatorV3/BetterTabControl.cs +++ b/CapsLockIndicatorV3/BetterTabControl.cs @@ -419,6 +419,7 @@ protected override void OnCreateControl() base.OnCreateControl(); FindUpDown(); + ItemSize = new Size(ItemSize.Width, (int)(24 * DPIHelper.GetScalingFactorPercent(Handle))); } private void FlatTabControl_ControlAdded(object sender, ControlEventArgs e) diff --git a/CapsLockIndicatorV3/DPIHelper.cs b/CapsLockIndicatorV3/DPIHelper.cs index 1071381..df5604b 100644 --- a/CapsLockIndicatorV3/DPIHelper.cs +++ b/CapsLockIndicatorV3/DPIHelper.cs @@ -20,9 +20,9 @@ private enum DeviceCap DESKTOPVERTRES = 117 } - internal static decimal GetScalingFactorPercent() + internal static decimal GetScalingFactorPercent(IntPtr handle) { - var g = Graphics.FromHwnd(IntPtr.Zero); + var g = Graphics.FromHwnd(handle); try { var desktop = g.GetHdc(); diff --git a/CapsLockIndicatorV3/IconPackBrowser.cs b/CapsLockIndicatorV3/IconPackBrowser.cs index 145a962..fdad680 100644 --- a/CapsLockIndicatorV3/IconPackBrowser.cs +++ b/CapsLockIndicatorV3/IconPackBrowser.cs @@ -244,7 +244,7 @@ private void IconPackBrowser_DarkModeChanged(object sender, EventArgs e) ControlScheduleSetDarkMode(webBrowser1, dark); - webBrowser1.Navigate("https://cli.jonaskohl.de/icongallery/embedded.php?dark=" + (dark ? "true" : "false") + "&scale=" + ((int)(DPIHelper.GetScalingFactorPercent() * 100)).ToString()); + webBrowser1.Navigate("https://cli.jonaskohl.de/icongallery/embedded.php?dark=" + (dark ? "true" : "false") + "&scale=" + ((int)(DPIHelper.GetScalingFactorPercent(Handle) * 100)).ToString()); } } } diff --git a/CapsLockIndicatorV3/IndicatorOverlay.cs b/CapsLockIndicatorV3/IndicatorOverlay.cs index 5659a7d..7908a5d 100644 --- a/CapsLockIndicatorV3/IndicatorOverlay.cs +++ b/CapsLockIndicatorV3/IndicatorOverlay.cs @@ -25,9 +25,10 @@ public partial class IndicatorOverlay : Form static extern int GetWindowLongInt(IntPtr hWnd, int nIndex); [DllImport("user32.dll")] static extern int SetWindowLong(IntPtr hWnd, int nIndex, uint dwNewLong); - [DllImport("user32.dll")] - static extern int GetDpiForWindow(IntPtr hWnd); + //[DllImport("user32.dll")] + //static extern int GetDpiForWindow(IntPtr hWnd); + /* static float GetDisplayScaleFactor(IntPtr windowHandle) { try @@ -39,6 +40,7 @@ static float GetDisplayScaleFactor(IntPtr windowHandle) return 1; } } + */ const int GWL_EXSTYLE = -20; const uint WS_EX_LAYERED = 0x80000; @@ -111,7 +113,7 @@ void UpdatePosition() { Rectangle workingArea = Screen.GetWorkingArea(Cursor.Position); - var factor = GetDisplayScaleFactor(Handle); + //var factor = DPIHelper.GetScalingFactorPercent(Handle); Size = new Size( Width, @@ -167,8 +169,10 @@ protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); + var factor = DPIHelper.GetScalingFactorPercent(Handle); + if (BorderSize > 0) - e.Graphics.DrawRectangle(new Pen(BorderColour, BorderSize), e.ClipRectangle); + e.Graphics.DrawRectangle(new Pen(BorderColour, (int)(BorderSize * factor)), e.ClipRectangle); using (var sf = new StringFormat() { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center }) using (var b = new SolidBrush(contentLabel.ForeColor)) diff --git a/CapsLockIndicatorV3/MainForm.cs b/CapsLockIndicatorV3/MainForm.cs index 28fe778..0f50a37 100644 --- a/CapsLockIndicatorV3/MainForm.cs +++ b/CapsLockIndicatorV3/MainForm.cs @@ -235,7 +235,7 @@ public MainForm() private void TabControl1_SelectedIndexChanged(object sender, EventArgs e) { var sz = ClientSize; - sz.Height = (int)(int.Parse(tabControl1.SelectedTab.Tag.ToString()) * DPIHelper.GetScalingFactorPercent()); + sz.Height = (int)(int.Parse(tabControl1.SelectedTab.Tag.ToString()) * DPIHelper.GetScalingFactorPercent(Handle)); ClientSize = sz; } diff --git a/CapsLockIndicatorV3/Properties/AssemblyInfo.cs b/CapsLockIndicatorV3/Properties/AssemblyInfo.cs index 9f3aa4e..fa76f3b 100644 --- a/CapsLockIndicatorV3/Properties/AssemblyInfo.cs +++ b/CapsLockIndicatorV3/Properties/AssemblyInfo.cs @@ -24,6 +24,6 @@ // // You can specify all the values or you can use the default the Revision and // Build Numbers by using the '*' as shown below: -[assembly: AssemblyVersion("3.13.4.0")] -[assembly: AssemblyFileVersion("3.13.4.0")] +[assembly: AssemblyVersion("3.13.5.0")] +[assembly: AssemblyFileVersion("3.13.5.0")] [assembly: Guid ("6f54c357-0542-4d7d-9225-338bc3cd7834")]