bitsdojo_window icon indicating copy to clipboard operation
bitsdojo_window copied to clipboard

bitsdojo_window_windows works on Windows 10 or Greater only

Open venliong opened this issue 4 years ago • 11 comments
trafficstars

GetDpiForWindow and GetSystemMetricsForDpi minimum supported client is Windows 10, version 1607.

Will this plugin support Windows 7 ?

venliong avatar Apr 01 '21 09:04 venliong

This is a known issue and a fix is planned. Didn't have any time to do it recently but it is on my to-do list.

bitsdojo avatar Apr 01 '21 13:04 bitsdojo

Please, these should be a priority fix. This is a great plugin but this makes it practically unusable if it will not work on a lot of PCs. Even if some functionalities don't work on older windows versions, at least it should not be a crashing error.

Wishmater avatar Apr 12 '21 22:04 Wishmater

I had made this plugin working on Windows 7, Windows Server 2008/2012/2016/2019 , and Windows 10.

  1. GetSystemMetricsForDpi replaced with GetSystemMetrics , and then multi with scale factor.
  2. GetDpiForWindow replaced with FlutterDesktopGetDpiForHWND which come from #include <flutter_windows.h>.
  3. DwmExtendFrameIntoClientArea can not work on Windows Server, so I change the extendIntoClientArea method into this:
    void extendIntoClientArea(HWND hwnd)
    {
        if(IsWindowsServer() && has_custom_frame == TRUE) {
            SetMenu(hwnd, NULL);
            LONG lStyle = GetWindowLong(hwnd, GWL_STYLE);
            lStyle &= ~(WS_CAPTION | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_SYSMENU | WS_DLGFRAME);
            SetWindowLong(hwnd, GWL_STYLE, lStyle);
            LONG flags = SWP_FRAMECHANGED;
            SetWindowPos(hwnd, NULL, 0, 0, 0, 0, flags);
        } else {
            MARGINS margins = { 0, 0, 1, 0 };
            DwmExtendFrameIntoClientArea(hwnd, &margins);
        }
    }

IsWindowsServer() is come from #include <VersionHelpers.h> 5. bitsdojo_window_windows/lib/src/window.dart has a GetDpiForWindow FFI invoke, it's hard to find something to replace it, so just using 96.

venliong avatar Apr 13 '21 04:04 venliong

Having the same issue, when will this get fix?

iampopal avatar Jun 12 '21 01:06 iampopal

me too

Maged12 avatar Aug 08 '21 18:08 Maged12

Coming in the next update.

bitsdojo avatar Aug 13 '21 09:08 bitsdojo

I've just submitted a PR #100 which resolves this. I confess I did the work before checking whether it was already under development. Feel free to take that patch or wait for the official one from @bitsdojo.

abutcher-gh avatar Sep 03 '21 19:09 abutcher-gh

Mark this issue! Old windows 7 is needed because my company uses it.

SteveCruise avatar Nov 23 '21 08:11 SteveCruise

For Windows 7, use @abutcher-gh solution above, the PR #100. I've tested in on Windows 7 and it works fine. If you clone this repo to local, don't forget to update all pubspec.yaml dependencies to local path also (project, platform interface, and the windows specific).

aldycool avatar Nov 23 '21 08:11 aldycool

I've just submitted a PR #100 which resolves this. I confess I did the work before checking whether it was already under development. Feel free to take that patch or wait for the official one from @bitsdojo.

Thanks for your contribution,. It truly solved my problem but only on flutter of 2.0.4. When I update my flutter to 2.10.1, It doesn't work any more. Have you updated your fltter version? And does it work?

sunjhtrustmobi avatar Apr 24 '22 07:04 sunjhtrustmobi

I had made this plugin working on Windows 7, Windows Server 2008/2012/2016/2019 , and Windows 10.

  1. GetSystemMetricsForDpi replaced with GetSystemMetrics , and then multi with scale factor.
  2. GetDpiForWindow replaced with FlutterDesktopGetDpiForHWND which come from #include <flutter_windows.h>.
  3. DwmExtendFrameIntoClientArea can not work on Windows Server, so I change the extendIntoClientArea method into this:
    void extendIntoClientArea(HWND hwnd)
    {
        if(IsWindowsServer() && has_custom_frame == TRUE) {
            SetMenu(hwnd, NULL);
            LONG lStyle = GetWindowLong(hwnd, GWL_STYLE);
            lStyle &= ~(WS_CAPTION | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_SYSMENU | WS_DLGFRAME);
            SetWindowLong(hwnd, GWL_STYLE, lStyle);
            LONG flags = SWP_FRAMECHANGED;
            SetWindowPos(hwnd, NULL, 0, 0, 0, 0, flags);
        } else {
            MARGINS margins = { 0, 0, 1, 0 };
            DwmExtendFrameIntoClientArea(hwnd, &margins);
        }
    }

IsWindowsServer() is come from #include <VersionHelpers.h> 5. bitsdojo_window_windows/lib/src/window.dart has a GetDpiForWindow FFI invoke, it's hard to find something to replace it, so just using 96.

After the form is minimized,to restore, the form background is black!

zijiaxing avatar Jun 16 '22 04:06 zijiaxing