# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1074666701 0 # Node ID f1998a89a4d51e7ca743b2d96386ff23b4f3a81d # Parent 2ecbb7963011c714294e21cbc1dafabc049ad5ca Load the Win2K/98 functions dynamically so the same DW.DLL binary will work on Windows 95 and NT with the enhanced menu functionality automatically disabled. diff -r 2ecbb7963011 -r f1998a89a4d5 win/dw.c --- a/win/dw.c Sun Jan 18 06:52:50 2004 +0000 +++ b/win/dw.c Wed Jan 21 06:31:41 2004 +0000 @@ -8,11 +8,7 @@ * */ #define _WIN32_IE 0x0500 -#ifdef WINNT_COMPAT -#define WINVER 0x400 -#else #define WINVER 0x500 -#endif #include #include #include @@ -35,11 +31,15 @@ #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)) #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; + int main(int argc, char *argv[]); #define ICON_INDEX_LIMIT 200 @@ -420,21 +420,22 @@ void _free_menu_data(HMENU menu) { -#ifndef WINNT_COMPAT - int i, count = GetMenuItemCount(menu); - - for(i=0;iid && passthru == tmp->id) + else if(!IS_WINNTOR95 && tmp->id && passthru == tmp->id) { HMENU hwndmenu = GetMenu(hWnd), menuowner = _menu_owner((HMENU)tmp->window); @@ -1774,7 +1772,6 @@ tmp = NULL; } } /* Make sure it's the right window, and the right ID */ -#endif else if(tmp->window < (HWND)65536 && command == tmp->window) { result = clickfunc(popup ? popup : tmp->window, tmp->data); @@ -3242,6 +3239,16 @@ _hBrush[z] = CreateSolidBrush(_foreground[z]); } + 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); + } + return 0; } @@ -3461,12 +3468,14 @@ { HWND parent = GetParent(handle); Box *thisbox = (Box *)GetWindowLongPtr(parent, GWLP_USERDATA); -#ifndef WINNT_COMPAT - HMENU menu = GetMenu(handle); - - if(menu) - _free_menu_data(menu); -#endif + + if(!IS_WINNTOR95) + { + HMENU menu = GetMenu(handle); + + if(menu) + _free_menu_data(menu); + } if(parent != HWND_DESKTOP && thisbox && thisbox->count) { @@ -3962,7 +3971,7 @@ tmp = (HMENUI)CreateMenu(); -#ifndef WINNT_COMPAT + if(!IS_WINNTOR95) { MENUINFO mi; @@ -3970,9 +3979,8 @@ mi.fMask = MIM_MENUDATA; mi.dwMenuData = (ULONG_PTR)1; - SetMenuInfo((HMENU)tmp, &mi); - } -#endif + MySetMenuInfo((HMENU)tmp, &mi); + } dw_window_set_data(location, "_dw_menu", (void *)tmp); @@ -4013,9 +4021,7 @@ { MENUITEMINFO mii; HMENU mymenu = (HMENU)menux; -#ifndef WINNT_COMPAT char buffer[15]; -#endif if(IsWindow(menux) && !IsMenu(mymenu)) mymenu = (HMENU)dw_window_get_data(menux, "_dw_menu"); @@ -4051,22 +4057,23 @@ InsertMenuItem(mymenu, 65535, TRUE, &mii); -#ifndef WINNT_COMPAT - sprintf(buffer, "_dw_id%d", id); - dw_window_set_data(DW_HWND_OBJECT, buffer, (void *)mymenu); - - /* 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; - - SetMenuInfo((HMENU)submenu, &mi); - } -#endif + if(!IS_WINNTOR95) + { + sprintf(buffer, "_dw_id%d", id); + dw_window_set_data(DW_HWND_OBJECT, buffer, (void *)mymenu); + + /* 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(IsWindow(menux) && !IsMenu((HMENU)menux)) DrawMenuBar(menux);