winecfg: improve user experience by adding all Windows versions and accompanying error message

Jason Overland jasonoverland at gmail.com
Fri Mar 27 00:03:14 CDT 2015


Hi,
This patch is a resubmission of and supersedes my previous patch "winecfg: add note about 32 bit prefixes to dialog".  Thanks to everyone who provided feedback on that one.

In this patch, winecfg's Application settings tab now includes all Windows versions in the combobox.  If the user is running from a 64 bit prefix and selects a version of Windows that requires a 32 bit prefix, the selection will revert to the previous selection and a modal dialog containing an error message will appear:

"""
This Wine prefix is built to support 64 bit applications. Because the Windows version you selected does not support 64 bit applications, this prefix cannot be configured to mimic that version of Windows.

Please refer to "How do I create a 32 bit wineprefix on a 64 bit system?" in the "Using Wine" section of the Wine FAQ (http://wiki.winehq.org/FAQ) for instructions on how to create a 32 bit Wine prefix.
"""

In addition, I noticed two File Open dialogs in winecfg which should be modal but are not modal.  I made these modal by setting the appropriate owner window.  While a separate issue, this seemed like a trivial enough change to include in this patch.

---
  programs/winecfg/appdefaults.c | 53 +++++++++++++++++++++++++++---------------
  programs/winecfg/resource.h    |  2 ++
  programs/winecfg/theme.c       |  2 +-
  programs/winecfg/winecfg.rc    |  2 ++
  4 files changed, 39 insertions(+), 20 deletions(-)

diff --git a/programs/winecfg/appdefaults.c b/programs/winecfg/appdefaults.c
index 66085f4..4d70e24 100644
--- a/programs/winecfg/appdefaults.c
+++ b/programs/winecfg/appdefaults.c
@@ -47,29 +47,30 @@ static const struct
      WORD        wServicePackMajor;
      WORD        wServicePackMinor;
      const char *szProductType;
+    BOOL        bRequires32BitPrefix;
  } win_versions[] =
  {
-    { "win81",       "Windows 8.1",       6,  3, 0x2580,VER_PLATFORM_WIN32_NT, " ", 0, 0, "WinNT"},
-    { "win8",        "Windows 8",         6,  2, 0x23F0,VER_PLATFORM_WIN32_NT, " ", 0, 0, "WinNT"},
-    { "win2008r2",   "Windows 2008 R2",   6,  1, 0x1DB1,VER_PLATFORM_WIN32_NT, "Service Pack 1", 1, 0, "ServerNT"},
-    { "win7",        "Windows 7",         6,  1, 0x1DB1,VER_PLATFORM_WIN32_NT, "Service Pack 1", 1, 0, "WinNT"},
-    { "win2008",     "Windows 2008",      6,  0, 0x1772,VER_PLATFORM_WIN32_NT, "Service Pack 2", 2, 0, "ServerNT"},
-    { "vista",       "Windows Vista",     6,  0, 0x1772,VER_PLATFORM_WIN32_NT, "Service Pack 2", 2, 0, "WinNT"},
-    { "win2003",     "Windows 2003",      5,  2, 0xECE, VER_PLATFORM_WIN32_NT, "Service Pack 2", 2, 0, "ServerNT"},
+    { "win81",       "Windows 8.1",       6,  3, 0x2580,VER_PLATFORM_WIN32_NT, " ", 0, 0, "WinNT", FALSE},
+    { "win8",        "Windows 8",         6,  2, 0x23F0,VER_PLATFORM_WIN32_NT, " ", 0, 0, "WinNT", FALSE},
+    { "win2008r2",   "Windows 2008 R2",   6,  1, 0x1DB1,VER_PLATFORM_WIN32_NT, "Service Pack 1", 1, 0, "ServerNT", FALSE},
+    { "win7",        "Windows 7",         6,  1, 0x1DB1,VER_PLATFORM_WIN32_NT, "Service Pack 1", 1, 0, "WinNT", FALSE},
+    { "win2008",     "Windows 2008",      6,  0, 0x1772,VER_PLATFORM_WIN32_NT, "Service Pack 2", 2, 0, "ServerNT", FALSE},
+    { "vista",       "Windows Vista",     6,  0, 0x1772,VER_PLATFORM_WIN32_NT, "Service Pack 2", 2, 0, "WinNT", FALSE},
+    { "win2003",     "Windows 2003",      5,  2, 0xECE, VER_PLATFORM_WIN32_NT, "Service Pack 2", 2, 0, "ServerNT", FALSE},
  #ifdef _WIN64
-    { "winxp64",     "Windows XP",        5,  2, 0xECE, VER_PLATFORM_WIN32_NT, "Service Pack 2", 2, 0, "WinNT"},
+    { "winxp64",     "Windows XP",        5,  2, 0xECE, VER_PLATFORM_WIN32_NT, "Service Pack 2", 2, 0, "WinNT", FALSE},
  #else
-    { "winxp",       "Windows XP",        5,  1, 0xA28, VER_PLATFORM_WIN32_NT, "Service Pack 3", 3, 0, "WinNT"},
-    { "win2k",       "Windows 2000",      5,  0, 0x893, VER_PLATFORM_WIN32_NT, "Service Pack 4", 4, 0, "WinNT"},
-    { "winme",       "Windows ME",        4, 90, 0xBB8, VER_PLATFORM_WIN32_WINDOWS, " ", 0, 0, ""},
-    { "win98",       "Windows 98",        4, 10, 0x8AE, VER_PLATFORM_WIN32_WINDOWS, " A ", 0, 0, ""},
-    { "win95",       "Windows 95",        4,  0, 0x3B6, VER_PLATFORM_WIN32_WINDOWS, "", 0, 0, ""},
-    { "nt40",        "Windows NT 4.0",    4,  0, 0x565, VER_PLATFORM_WIN32_NT, "Service Pack 6a", 6, 0, "WinNT"},
-    { "nt351",       "Windows NT 3.51",   3, 51, 0x421, VER_PLATFORM_WIN32_NT, "Service Pack 5", 5, 0, "WinNT"},
-    { "win31",       "Windows 3.1",       3, 10,     0, VER_PLATFORM_WIN32s, "Win32s 1.3", 0, 0, ""},
-    { "win30",       "Windows 3.0",       3,  0,     0, VER_PLATFORM_WIN32s, "Win32s 1.3", 0, 0, ""},
-    { "win20",       "Windows 2.0",       2,  0,     0, VER_PLATFORM_WIN32s, "Win32s 1.3", 0, 0, ""}
+    { "winxp",       "Windows XP",        5,  1, 0xA28, VER_PLATFORM_WIN32_NT, "Service Pack 3", 3, 0, "WinNT", TRUE},
  #endif
+    { "win2k",       "Windows 2000",      5,  0, 0x893, VER_PLATFORM_WIN32_NT, "Service Pack 4", 4, 0, "WinNT", TRUE},
+    { "winme",       "Windows ME",        4, 90, 0xBB8, VER_PLATFORM_WIN32_WINDOWS, " ", 0, 0, "", TRUE},
+    { "win98",       "Windows 98",        4, 10, 0x8AE, VER_PLATFORM_WIN32_WINDOWS, " A ", 0, 0, "", TRUE},
+    { "win95",       "Windows 95",        4,  0, 0x3B6, VER_PLATFORM_WIN32_WINDOWS, "", 0, 0, "", TRUE},
+    { "nt40",        "Windows NT 4.0",    4,  0, 0x565, VER_PLATFORM_WIN32_NT, "Service Pack 6a", 6, 0, "WinNT", TRUE},
+    { "nt351",       "Windows NT 3.5",   3, 51, 0x421, VER_PLATFORM_WIN32_NT, "Service Pack 5", 5, 0, "WinNT", TRUE},
+    { "win31",       "Windows 3.1",       3, 10,     0, VER_PLATFORM_WIN32s, "Win32s 1.3", 0, 0, "", TRUE},
+    { "win30",       "Windows 3.0",       3,  0,     0, VER_PLATFORM_WIN32s, "Win32s 1.3", 0, 0, "", TRUE},
+    { "win20",       "Windows 2.0",       2,  0,     0, VER_PLATFORM_WIN32s, "Win32s 1.3", 0, 0, "", TRUE}
  };
  
  #define NB_VERSIONS (sizeof(win_versions)/sizeof(win_versions[0]))
@@ -327,7 +328,7 @@ static void on_add_app_click(HWND dialog)
    static const WCHAR pathC[] = { 'c',':','\\',0 };
  
    OPENFILENAMEW ofn = { sizeof(OPENFILENAMEW),
-		       0, /*hInst*/0, 0, NULL, 0, 0, NULL,
+		       dialog, /*hInst*/0, 0, NULL, 0, 0, NULL,
  		       0, NULL, 0, pathC, 0,
  		       OFN_SHOWHELP | OFN_HIDEREADONLY | OFN_ENABLESIZING,
                         0, 0, NULL, 0, NULL };
@@ -404,6 +405,20 @@ static void on_winver_change(HWND dialog)
  {
      int selection = SendDlgItemMessageW(dialog, IDC_WINVER, CB_GETCURSEL, 0, 0);
  
+#ifdef _WIN64
+    if (win_versions[selection-1].bRequires32BitPrefix)
+    {
+        WCHAR prefixErrorStr[1000];
+        WCHAR prefixTitleStr[100];
+        LoadStringW(GetModuleHandleW(NULL), IDS_PREFIX_ERROR, prefixErrorStr,
+            sizeof(prefixErrorStr)/sizeof(prefixErrorStr[0]));
+        LoadStringW(GetModuleHandleW(NULL), IDS_PREFIX_ERROR_TITLE, prefixTitleStr,
+            sizeof(prefixTitleStr)/sizeof(prefixTitleStr[0]));
+        MessageBoxW(dialog, prefixErrorStr, prefixTitleStr, MB_OK | MB_ICONERROR);
+        update_comboboxes(dialog);
+        return;
+    }
+#endif
      if (current_app)
      {
          if (!selection)
diff --git a/programs/winecfg/resource.h b/programs/winecfg/resource.h
index 3118fb6..97997a8 100644
--- a/programs/winecfg/resource.h
+++ b/programs/winecfg/resource.h
@@ -135,6 +135,8 @@
  #define IDC_APP_LISTVIEW                1200
  #define IDC_APP_ADDAPP                  1201
  #define IDC_APP_REMOVEAPP               1202
+#define IDS_PREFIX_ERROR_TITLE          1203
+#define IDS_PREFIX_ERROR                1204
  
  /* audio tab */
  #define IDC_AUDIO_TEST                  1300
diff --git a/programs/winecfg/theme.c b/programs/winecfg/theme.c
index 6db602f..8ffc9bb 100644
--- a/programs/winecfg/theme.c
+++ b/programs/winecfg/theme.c
@@ -635,7 +635,7 @@ static void on_theme_install(HWND dialog)
        title, sizeof (title) / sizeof (title[0]));
  
    ofn.lStructSize = sizeof(OPENFILENAMEW);
-  ofn.hwndOwner = 0;
+  ofn.hwndOwner = dialog;
    ofn.hInstance = 0;
    ofn.lpstrFilter = filter;
    ofn.lpstrCustomFilter = NULL;
diff --git a/programs/winecfg/winecfg.rc b/programs/winecfg/winecfg.rc
index 6fc1c26..7a8597c 100644
--- a/programs/winecfg/winecfg.rc
+++ b/programs/winecfg/winecfg.rc
@@ -61,6 +61,8 @@ BEGIN
      IDS_EXECUTABLE_FILTER   "Wine Programs (*.exe; *.exe.so)"
      IDS_USE_GLOBAL_SETTINGS "Use global settings"
      IDS_SELECT_EXECUTABLE   "Select an executable file"
+    IDS_PREFIX_ERROR_TITLE  "Error: Invalid selection"
+    IDS_PREFIX_ERROR        "This Wine prefix is built to support 64 bit applications. Because the Windows version you selected does not support 64 bit applications, this prefix cannot be configured to mimic that version of Windows.\n\nPlease refer to \"How do I create a 32 bit wineprefix on a 64 bit system?\" in the \"Using Wine\" section of the Wine FAQ (http://wiki.winehq.org/FAQ) for instructions on how to create a 32 bit Wine prefix."
  END
  
  STRINGTABLE
-- 
1.9.1




More information about the wine-patches mailing list