From ff05d12729ab6c9820cc63afea72f466c82a6b24 Mon Sep 17 00:00:00 2001 From: brandoncomputer Date: Mon, 18 Apr 2022 08:56:02 -0500 Subject: [PATCH] --- examples/calc.ps1 | 4 +++- examples/cursor.ps1 | 2 ++ examples/vds-ide-noscale.ps1 | 2 ++ examples/vds-ide.ps1 | 18 ++---------------- vds.psm1 | 23 +++++++++++++++++++++++ 5 files changed, 32 insertions(+), 17 deletions(-) diff --git a/examples/calc.ps1 b/examples/calc.ps1 index c5d5af9..978362b 100644 --- a/examples/calc.ps1 +++ b/examples/calc.ps1 @@ -1,4 +1,6 @@ - $calc = dialog create "Admin Calculator" 0 0 148 229 +DPIAware +VisualStyle + $calc = dialog create "Admin Calculator" 0 0 148 229 $calc.FormBorderStyle = 6 $calc.maximumsize = new-object System.Drawing.Size((148 * $(screeninfo scale)),(229 * $(screeninfo scale))) diff --git a/examples/cursor.ps1 b/examples/cursor.ps1 index 5ad552f..5195868 100644 --- a/examples/cursor.ps1 +++ b/examples/cursor.ps1 @@ -1,3 +1,5 @@ +DPIAware +VisualStyle $Form = dialog create "TEST CURSOR" 0 0 321 196 $List1 = dialog add $Form ListBox 10 10 180 144 "ListBox1" $reset = dialog add $Form Button 16 221 75 23 "reset" diff --git a/examples/vds-ide-noscale.ps1 b/examples/vds-ide-noscale.ps1 index c0eeefb..d6bea21 100644 --- a/examples/vds-ide-noscale.ps1 +++ b/examples/vds-ide-noscale.ps1 @@ -1,3 +1,5 @@ +VisualStyle + if ((Get-Module -ListAvailable vds).count -gt 1){ $global:module = $(path $(Get-Module -ListAvailable vds)[0].path) } diff --git a/examples/vds-ide.ps1 b/examples/vds-ide.ps1 index a49ea36..18a22af 100644 --- a/examples/vds-ide.ps1 +++ b/examples/vds-ide.ps1 @@ -1,19 +1,5 @@ -info $null 2>$null -$vscreen = [System.Windows.Forms.SystemInformation]::VirtualScreen.height -if ((get-host).version.major -eq 5) { -[xml]$xml = @" - - -"@ -$dum = (New-Object System.Xml.XmlNodeReader $xml) -$win = [Windows.Markup.XamlReader]::Load($dum) -} - -$screen = [System.Windows.Forms.SystemInformation]::VirtualScreen.height - -$global:ctscale = ($screen/$vscreen) +DPIAware +VisualStyle if ((Get-Module -ListAvailable vds).count -gt 1){ $global:module = $(path $(Get-Module -ListAvailable vds)[0].path) diff --git a/vds.psm1 b/vds.psm1 index 1045d4c..36878db 100644 --- a/vds.psm1 +++ b/vds.psm1 @@ -6,8 +6,20 @@ using System.Drawing; using System.Runtime.InteropServices; using System.Windows.Forms; using System.ComponentModel; +using System.Collections.Generic; public class vds { + + public static void SetCompat() + { + // SetProcessDPIAware(); + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + } + + [System.Runtime.InteropServices.DllImport("user32.dll")] + public static extern bool SetProcessDPIAware(); + [DllImport("user32.dll")] public static extern bool InvertRect(IntPtr hDC, [In] ref RECT lprc); @@ -321,6 +333,17 @@ $global:fieldsep = "|" $global:database = new-object System.Data.Odbc.OdbcConnection set-alias run invoke-expression +function VisualStyle() { + [vds]::SetCompat() +} + +function DPIAware($a) { +$vscreen = [System.Windows.Forms.SystemInformation]::VirtualScreen.height +[vds]::SetProcessDPIAware() +$screen = [System.Windows.Forms.SystemInformation]::VirtualScreen.height +$global:ctscale = ($screen/$vscreen) +} + function abs($a) { <# .SYNOPSIS