From 9cb9ce86bd8f67dd200fbb74183f1bdbead61101 Mon Sep 17 00:00:00 2001 From: Rafael Kitover Date: Tue, 23 Oct 2018 06:19:34 -0700 Subject: [PATCH] fix Windows XP Compatibility #315 Use the IsWindowsVistaOrGreater() function from VersionHelpers.h, which fortunately is part of mingw, to check for the availability of the comctl32 LoadIconWithScaleDown API, which we use to fix issues with the app icon, like the icon being too big in the volume mixer. --- src/wx/guiinit.cpp | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/src/wx/guiinit.cpp b/src/wx/guiinit.cpp index bc423b6b..6091fafa 100644 --- a/src/wx/guiinit.cpp +++ b/src/wx/guiinit.cpp @@ -2537,6 +2537,7 @@ void MainFrame::MenuOptionIntRadioValue(const char* menuName, int& field, int va #ifdef __WXMSW__ #include + #include #include #include typedef int (WINAPI *func_LoadIconWithScaleDown)(HINSTANCE, LPCWSTR, int, int, HICON*); @@ -2544,22 +2545,24 @@ void MainFrame::MenuOptionIntRadioValue(const char* menuName, int& field, int va void MainFrame::BindAppIcon() { #ifdef __WXMSW__ - wxDynamicLibrary comctl32("comctl32", wxDL_DEFAULT | wxDL_QUIET); - func_LoadIconWithScaleDown load_icon_scaled = reinterpret_cast(comctl32.GetSymbol("LoadIconWithScaleDown")); - int icon_set_count = 0; + if (IsWindowsVistaOrGreater()) { + wxDynamicLibrary comctl32("comctl32", wxDL_DEFAULT | wxDL_QUIET); + func_LoadIconWithScaleDown load_icon_scaled = reinterpret_cast(comctl32.GetSymbol("LoadIconWithScaleDown")); + int icon_set_count = 0; - HICON hIconLg; - if (load_icon_scaled && SUCCEEDED(load_icon_scaled(wxGetInstance(), _T("AAAAA_MAINICON"), ::GetSystemMetrics(SM_CXICON), ::GetSystemMetrics(SM_CYICON), &hIconLg))) { - ::SendMessage(GetHandle(), WM_SETICON, ICON_BIG, reinterpret_cast(hIconLg)); - ++icon_set_count; - } - HICON hIconSm; - if (load_icon_scaled && SUCCEEDED(load_icon_scaled(wxGetInstance(), _T("AAAAA_MAINICON"), ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), &hIconSm))) { - ::SendMessage(GetHandle(), WM_SETICON, ICON_SMALL, reinterpret_cast(hIconSm)); - ++icon_set_count; - } + HICON hIconLg; + if (load_icon_scaled && SUCCEEDED(load_icon_scaled(wxGetInstance(), _T("AAAAA_MAINICON"), ::GetSystemMetrics(SM_CXICON), ::GetSystemMetrics(SM_CYICON), &hIconLg))) { + ::SendMessage(GetHandle(), WM_SETICON, ICON_BIG, reinterpret_cast(hIconLg)); + ++icon_set_count; + } + HICON hIconSm; + if (load_icon_scaled && SUCCEEDED(load_icon_scaled(wxGetInstance(), _T("AAAAA_MAINICON"), ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), &hIconSm))) { + ::SendMessage(GetHandle(), WM_SETICON, ICON_SMALL, reinterpret_cast(hIconSm)); + ++icon_set_count; + } - if (icon_set_count == 2) return; + if (icon_set_count == 2) return; + } // otherwise fall back to Wx method of setting icon #endif wxIcon icon = wxXmlResource::Get()->LoadIcon(wxT("MainIcon"));