From 189cdb8e396e284fb4b11920ed5e485c65cd0f33 Mon Sep 17 00:00:00 2001 From: Zachary Spriggs Date: Mon, 22 Mar 2021 15:51:54 -0400 Subject: [PATCH 1/3] Fix bug with DPI, Width, and Height (Win) Fixes a bug that would make QB64 return the incorrect size monitor/desktop size when the resolution is scaled. Also, the last fix I added that set `_Source` to `_Console` automatically caused an issue with `_Width` and `_Height`, causing them to return only the console's image dimensions rather than the image that is passed. --- internal/c/libqb.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/internal/c/libqb.cpp b/internal/c/libqb.cpp index da64aff9e..d3455df52 100644 --- a/internal/c/libqb.cpp +++ b/internal/c/libqb.cpp @@ -18464,6 +18464,20 @@ void sub_put2(int32 i,int64 offset,void *element,int32 passed){ //Creating/destroying an image surface: int32 func__newimage(int32 x,int32 y,int32 bpp,int32 passed){ + #ifdef QB64_WINDOWS + static bool j; + if(j != 1){ + FARPROC dpiaware; + HMODULE user32 = LoadLibrary(TEXT("user32.dll")); + if(user32 != NULL){ + dpiaware = GetProcAddress(user32, "SetProcessDPIAware"); + if(NULL != dpiaware){ + (dpiaware) (); + j = 1; + } + } + } + #endif static int32 i; if (new_error) return 0; if (x<=0||y<=0){error(5); return 0;} @@ -18824,7 +18838,7 @@ void sub_put2(int32 i,int64 offset,void *element,int32 passed){ if (new_error) return 0; #ifdef QB64_WINDOWS - if (read_page->console||i==console_image){ + if (i==console_image){ SECURITY_ATTRIBUTES SecAttribs = {sizeof(SECURITY_ATTRIBUTES), 0, 1}; HANDLE cl_conout = CreateFileA("CONOUT$", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, & SecAttribs, OPEN_EXISTING, 0, 0); CONSOLE_SCREEN_BUFFER_INFO cl_bufinfo; @@ -18853,7 +18867,7 @@ void sub_put2(int32 i,int64 offset,void *element,int32 passed){ if (new_error) return 0; #ifdef QB64_WINDOWS - if (read_page->console||i==console_image){ + if (i==console_image){ SECURITY_ATTRIBUTES SecAttribs = {sizeof(SECURITY_ATTRIBUTES), 0, 1}; HANDLE cl_conout = CreateFileA("CONOUT$", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, & SecAttribs, OPEN_EXISTING, 0, 0); CONSOLE_SCREEN_BUFFER_INFO cl_bufinfo; From c727abd6674860026b115f209512b9a37ff5c212 Mon Sep 17 00:00:00 2001 From: Zachary Spriggs Date: Wed, 24 Mar 2021 00:09:33 -0400 Subject: [PATCH 2/3] Check for XP using WINVER in func__newimage and sub__consolefont This can re-enable `_ConsoleFont` by checking if the version of Windows is greater than XP. Also, for the DPI awareness. --- internal/c/libqb.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/internal/c/libqb.cpp b/internal/c/libqb.cpp index d3455df52..4f13a60f9 100644 --- a/internal/c/libqb.cpp +++ b/internal/c/libqb.cpp @@ -18464,7 +18464,7 @@ void sub_put2(int32 i,int64 offset,void *element,int32 passed){ //Creating/destroying an image surface: int32 func__newimage(int32 x,int32 y,int32 bpp,int32 passed){ - #ifdef QB64_WINDOWS + #ifdef QB64_WINDOWS && WINVER > 0x0501 //this block is not compatible with XP static bool j; if(j != 1){ FARPROC dpiaware; @@ -29847,8 +29847,7 @@ void sub__numlock(int32 options){ } void sub__consolefont(qbs* FontName, int FontSize){ - /* - #ifdef QB64_WINDOWS + #ifdef QB64_WINDOWS && WINVER > 0x0501 //this block is not compatible with XP SECURITY_ATTRIBUTES SecAttribs = {sizeof(SECURITY_ATTRIBUTES), 0, 1}; HANDLE cl_conout = CreateFileA("CONOUT$", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, & SecAttribs, OPEN_EXISTING, 0, 0); static int OneTimePause; @@ -29870,7 +29869,6 @@ void sub__consolefont(qbs* FontName, int FontSize){ SetCurrentConsoleFontEx(cl_conout, NULL, &info); #endif - */ } From ad3afb56b830b6b6f3a2e80cc9a9d2a281dadaa8 Mon Sep 17 00:00:00 2001 From: Zachary Spriggs Date: Wed, 24 Mar 2021 00:14:19 -0400 Subject: [PATCH 3/3] Changed #if blocks to be greater than or equal to Vista version --- internal/c/libqb.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/c/libqb.cpp b/internal/c/libqb.cpp index 4f13a60f9..a3bb895ce 100644 --- a/internal/c/libqb.cpp +++ b/internal/c/libqb.cpp @@ -18464,7 +18464,7 @@ void sub_put2(int32 i,int64 offset,void *element,int32 passed){ //Creating/destroying an image surface: int32 func__newimage(int32 x,int32 y,int32 bpp,int32 passed){ - #ifdef QB64_WINDOWS && WINVER > 0x0501 //this block is not compatible with XP + #ifdef QB64_WINDOWS && WINVER >= 0x0600 //this block is not compatible with XP static bool j; if(j != 1){ FARPROC dpiaware; @@ -29847,7 +29847,7 @@ void sub__numlock(int32 options){ } void sub__consolefont(qbs* FontName, int FontSize){ - #ifdef QB64_WINDOWS && WINVER > 0x0501 //this block is not compatible with XP + #ifdef QB64_WINDOWS && WINVER >= 0x0600 //this block is not compatible with XP SECURITY_ATTRIBUTES SecAttribs = {sizeof(SECURITY_ATTRIBUTES), 0, 1}; HANDLE cl_conout = CreateFileA("CONOUT$", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, & SecAttribs, OPEN_EXISTING, 0, 0); static int OneTimePause;