From 25c7397dbd75110f249e44c4b2146cc8df871f3e Mon Sep 17 00:00:00 2001 From: Brad Nelson Date: Sat, 26 Mar 2022 11:03:29 -0700 Subject: [PATCH] Added DPI awareness option. --- examples/bezier_test.fs | 3 ++- windows/windows_core.fs | 1 + windows/windows_user.fs | 8 ++++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/examples/bezier_test.fs b/examples/bezier_test.fs index 7473987..cb83ebe 100755 --- a/examples/bezier_test.fs +++ b/examples/bezier_test.fs @@ -14,6 +14,7 @@ \ See the License for the specific language governing permissions and \ limitations under the License. +windows dpi-aware also graphics also structures @@ -21,7 +22,7 @@ struct ScanSpan ptr field ->next ptr field ->edge -1024 constant max-scanlines +2048 constant max-scanlines create scanlines max-scanlines cells allot scanlines max-scanlines cells erase 0 value free-edges diff --git a/windows/windows_core.fs b/windows/windows_core.fs index 24b4db4..4361fa8 100644 --- a/windows/windows_core.fs +++ b/windows/windows_core.fs @@ -27,6 +27,7 @@ windows does> dup @ swap cell+ @ execute ; : dll ( z "name" -- ) LoadLibraryA dup 0= throw create , does> @ sofunc ; +: contains? ( z 'lib -- f ) >body @ swap GetProcAddress ; z" Kernel32.dll" dll Kernel32 diff --git a/windows/windows_user.fs b/windows/windows_user.fs index 451ef77..d4bf9c6 100644 --- a/windows/windows_user.fs +++ b/windows/windows_user.fs @@ -170,4 +170,12 @@ IDI_ASTERISK constant IDI_INFORMATION 18 constant VK_ALT +( Check for Windows 10 DPI awareness ) +z" SetThreadDpiAwarenessContext" ' User32 contains? [IF] + z" SetThreadDpiAwarenessContext" 1 User32 SetThreadDpiAwarenessContext + : dpi-aware -2 SetThreadDpiAwarenessContext drop ; +[ELSE] + : dpi-aware ; +[THEN] + only forth definitions