diff options
author | Felipe Heidrich <fheidric> | 2006-08-15 16:13:53 +0000 |
---|---|---|
committer | Felipe Heidrich <fheidric> | 2006-08-15 16:13:53 +0000 |
commit | ef298d554ac828fdc69fb5418d674a71f4527544 (patch) | |
tree | 61aa3d7074f43d4614dba31145e3f57913029f18 | |
parent | 024d0120d0f8131e2e7626829f6723fee0ad2af0 (diff) | |
download | eclipse.platform.swt-ef298d554ac828fdc69fb5418d674a71f4527544.tar.gz eclipse.platform.swt-ef298d554ac828fdc69fb5418d674a71f4527544.tar.xz eclipse.platform.swt-ef298d554ac828fdc69fb5418d674a71f4527544.zip |
backport Bug 152129
-rwxr-xr-x | bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MenuItem.java | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MenuItem.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MenuItem.java index 11b0f73cec..d3adfcb786 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MenuItem.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MenuItem.java @@ -669,7 +669,20 @@ public void setEnabled (boolean enabled) { info.fState |= bits; } success = OS.SetMenuItemInfo (hMenu, id, false, info); - if (!success) error (SWT.ERROR_CANNOT_SET_ENABLED); + if (!success) { + /* + * Bug in Windows. For some reason SetMenuItemInfo(), + * returns a fail code when setting the enabled or + * selected state of a default item, but sets the + * state anyway. The fix is to ignore the error. + * + * NOTE: This only happens on Vista. + */ + if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION (6, 0)) { + success = id == OS.GetMenuDefaultItem (hMenu, OS.MF_BYCOMMAND, OS.GMDI_USEDISABLED); + } + if (!success) error (SWT.ERROR_CANNOT_SET_ENABLED); + } } } parent.destroyAccelerators (); @@ -915,7 +928,20 @@ public void setSelection (boolean selected) { info.fState &= ~OS.MFS_CHECKED; if (selected) info.fState |= OS.MFS_CHECKED; success = OS.SetMenuItemInfo (hMenu, id, false, info); - if (!success) error (SWT.ERROR_CANNOT_SET_SELECTION); + if (!success) { + /* + * Bug in Windows. For some reason SetMenuItemInfo(), + * returns a fail code when setting the enabled or + * selected state of a default item, but sets the + * state anyway. The fix is to ignore the error. + * + * NOTE: This only happens on Vista. + */ + if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION (6, 0)) { + success = id == OS.GetMenuDefaultItem (hMenu, OS.MF_BYCOMMAND, OS.GMDI_USEDISABLED); + } + if (!success) error (SWT.ERROR_CANNOT_SET_SELECTION); + } } parent.redraw (); } |