changeset 912:0c39705ddd4a

Removed a bunch of code that had been used to support Win95/NT/98/ME which are now unsupported. Windows 2000 and above are supported, so added a macro to test for XP or higher to enable advanced features.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Thu, 21 Apr 2011 11:27:09 +0000
parents 1ac9669caf86
children 81059acce901
files win/dw.c
diffstat 1 files changed, 45 insertions(+), 85 deletions(-) [+]
line wrap: on
line diff
--- a/win/dw.c	Thu Apr 21 06:37:16 2011 +0000
+++ b/win/dw.c	Thu Apr 21 11:27:09 2011 +0000
@@ -44,16 +44,12 @@
 
 #define PACKVERSION(major,minor) MAKELONG(minor,major)
 
-#define IS_IE5PLUS (dwComctlVer >= PACKVERSION(5,80))
-#define IS_WINNTOR95 (((LOBYTE(LOWORD(dwVersion))) < 5) && (HIBYTE(LOWORD(dwVersion)) < 10))
+#define IS_XPPLUS (dwComctlVer >= PACKVERSION(5,82))
 
 #ifndef MIN
 #define MIN(a, b) (((a) < (b)) ? (a) : (b))
 #endif
 
-static BOOL (WINAPI* MyGetMenuInfo)(HMENU, LPCMENUINFO) = 0;
-static BOOL (WINAPI* MySetMenuInfo)(HMENU, LPCMENUINFO) = 0;
-
 FILE *dbgfp = NULL;
 
 int main(int argc, char *argv[]);
@@ -569,23 +565,19 @@
 
 void _free_menu_data(HMENU menu)
 {
-   if (!IS_WINNTOR95 )
-   {
-      int i, count = GetMenuItemCount(menu);
-
-      for(i=0;i<count;i++)
-      {
-         MENUITEMINFO mii;
-
-         mii.cbSize = sizeof(MENUITEMINFO);
-         mii.fMask = MIIM_SUBMENU;
-
-         if ( GetMenuItemInfo( menu, i, TRUE, &mii )
-         && mii.hSubMenu )
+    int i, count = GetMenuItemCount(menu);
+
+    for(i=0;i<count;i++)
+    {
+        MENUITEMINFO mii;
+
+        mii.cbSize = sizeof(MENUITEMINFO);
+        mii.fMask = MIIM_SUBMENU;
+
+        if ( GetMenuItemInfo( menu, i, TRUE, &mii ) && mii.hSubMenu )
             _free_menu_data(mii.hSubMenu);
-      }
-   }
-   dw_signal_disconnect_by_name((HWND)menu, DW_SIGNAL_CLICKED);
+    }
+    dw_signal_disconnect_by_name((HWND)menu, DW_SIGNAL_CLICKED);
 }
 
 /* Convert to our internal color scheme */
@@ -1607,7 +1599,7 @@
    mi.cbSize = sizeof(MENUINFO);
    mi.fMask = MIM_MENUDATA;
 
-   if ( MyGetMenuInfo( menu, &mi ) )
+   if ( GetMenuInfo( menu, &mi ) )
       return (HMENU)mi.dwMenuData;
    return (HMENU)0;
 }
@@ -2127,7 +2119,7 @@
                            tmp = NULL;
                         }
                      }
-                     else if (!IS_WINNTOR95 && tmp->id && passthru == tmp->id)
+                     else if (tmp->id && passthru == tmp->id)
                      {
                         HMENU hwndmenu = GetMenu(hWnd), menuowner = _menu_owner((HMENU)tmp->window);
 
@@ -2728,10 +2720,7 @@
 
                position = atol(tempbuf);
 
-               if(IS_IE5PLUS)
-                  SendMessage(hWnd, UDM_SETPOS32, 0, (LPARAM)position);
-               else
-                  SendMessage(hWnd, UDM_SETPOS, 0, (LPARAM)MAKELONG((short)position, 0));
+               SendMessage(hWnd, UDM_SETPOS32, 0, (LPARAM)position);
             }
          }
          break;
@@ -2918,10 +2907,7 @@
             {
                long val;
 
-               if(IS_IE5PLUS)
-                  val = (long)SendMessage(cinfo->buddy, UDM_GETPOS32, 0, 0);
-               else
-                  val = (long)SendMessage(cinfo->buddy, UDM_GETPOS, 0, 0);
+               val = (long)SendMessage(cinfo->buddy, UDM_GETPOS32, 0, 0);
 
                sprintf(tmpbuf, "%ld", val);
                SetWindowText(hWnd, tmpbuf);
@@ -3822,16 +3808,6 @@
       _PointerOnWnd[z] = 0;
    }
 
-   if ( !IS_WINNTOR95 )
-   {
-      /* Get function pointers for the Win2k/98 menu functions */
-      HANDLE huser = LoadLibrary("user32");
-
-      MyGetMenuInfo = (void*)GetProcAddress(huser, "GetMenuInfo");
-      MySetMenuInfo = (void*)GetProcAddress(huser, "SetMenuInfo");
-      FreeLibrary(huser);
-   }
-
    /* Initialize Security for named events and memory */
    InitializeSecurityDescriptor(&_dwsd, SECURITY_DESCRIPTOR_REVISION);
    SetSecurityDescriptorDacl(&_dwsd, TRUE, (PACL) NULL, FALSE);
@@ -4095,14 +4071,10 @@
 {
    HWND parent = GetParent(handle);
    Box *thisbox = (Box *)GetWindowLongPtr(parent, GWLP_USERDATA);
-
-   if(!IS_WINNTOR95)
-   {
-      HMENU menu = GetMenu(handle);
-
-      if(menu)
-         _free_menu_data(menu);
-   }
+   HMENU menu = GetMenu(handle);
+
+   if(menu)
+      _free_menu_data(menu);
 
    if(parent != HWND_DESKTOP && thisbox && thisbox->count)
    {
@@ -4794,19 +4766,15 @@
 HMENUI API dw_menubar_new(HWND location)
 {
    HMENUI tmp;
+   MENUINFO mi;
 
    tmp = (HMENUI)CreateMenu();
 
-   if (!IS_WINNTOR95)
-   {
-      MENUINFO mi;
-
-      mi.cbSize = sizeof(MENUINFO);
-      mi.fMask = MIM_MENUDATA;
-      mi.dwMenuData = (ULONG_PTR)1;
-
-      MySetMenuInfo( (HMENU)tmp, &mi );
-   }
+   mi.cbSize = sizeof(MENUINFO);
+   mi.fMask = MIM_MENUDATA;
+   mi.dwMenuData = (ULONG_PTR)1;
+
+   SetMenuInfo( (HMENU)tmp, &mi );
 
    dw_window_set_data(location, "_dw_menu", (void *)tmp);
 
@@ -4912,19 +4880,15 @@
    sprintf(buffer, "_dw_isdisabled%ld", id);
    dw_window_set_data( DW_HWND_OBJECT, buffer, (void *)is_disabled );
 
-   if (!IS_WINNTOR95)
-   {
-      /* According to the docs this will only work on Win2k/98 and above */
-      if (submenu)
-      {
-         MENUINFO mi;
-
-         mi.cbSize = sizeof(MENUINFO);
-         mi.fMask = MIM_MENUDATA;
-         mi.dwMenuData = (ULONG_PTR)mymenu;
-
-         MySetMenuInfo( (HMENU)submenu, &mi );
-      }
+   if (submenu)
+   {
+      MENUINFO mi;
+
+      mi.cbSize = sizeof(MENUINFO);
+      mi.fMask = MIM_MENUDATA;
+      mi.dwMenuData = (ULONG_PTR)mymenu;
+
+      SetMenuInfo( (HMENU)submenu, &mi );
    }
 
    if (IsWindow(menux) && !IsMenu((HMENU)menux))
@@ -5142,6 +5106,12 @@
 
    SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo);
    dw_window_set_font(tmp, DefaultFont);
+   /* If we are running XP or higher... */
+   if(IS_XPPLUS)
+   {
+      /* Enable double buffering to prevent flicker */
+      ListView_SetExtendedListViewStyleEx(tmp, LVS_EX_DOUBLEBUFFER, LVS_EX_DOUBLEBUFFER);
+   }
    return tmp;
 }
 
@@ -7214,10 +7184,7 @@
    if(cinfo && cinfo->buddy)
       SetWindowText(cinfo->buddy, tmpbuf);
 
-   if(IS_IE5PLUS)
-      SendMessage(handle, UDM_SETPOS32, 0, (LPARAM)position);
-   else
-      SendMessage(handle, UDM_SETPOS, 0, (LPARAM)MAKELONG((short)position, 0));
+   SendMessage(handle, UDM_SETPOS32, 0, (LPARAM)position);
 }
 
 /*
@@ -7229,11 +7196,7 @@
  */
 void API dw_spinbutton_set_limits(HWND handle, long upper, long lower)
 {
-   if(IS_IE5PLUS)
-      SendMessage(handle, UDM_SETRANGE32, (WPARAM)lower,(LPARAM)upper);
-   else
-      SendMessage(handle, UDM_SETRANGE32, (WPARAM)((short)lower),
-               (LPARAM)((short)upper));
+   SendMessage(handle, UDM_SETRANGE32, (WPARAM)lower,(LPARAM)upper);
 }
 
 /*
@@ -7254,10 +7217,7 @@
  */
 long API dw_spinbutton_get_pos(HWND handle)
 {
-   if(IS_IE5PLUS)
-      return (long)SendMessage(handle, UDM_GETPOS32, 0, 0);
-   else
-      return (long)SendMessage(handle, UDM_GETPOS, 0, 0);
+   return (long)SendMessage(handle, UDM_GETPOS32, 0, 0);
 }
 
 /*