Index: dlls/user32/dialog.c
===================================================================
RCS file: /home/wine/wine/dlls/user32/dialog.c,v
retrieving revision 1.2
diff -u -p -u -r1.2 dialog.c
--- dlls/user32/dialog.c	20 Nov 2006 11:57:08 -0000	1.2
+++ dlls/user32/dialog.c	23 Dec 2006 12:44:59 -0000
@@ -1166,8 +1166,19 @@ BOOL WINAPI IsDialogMessageW( HWND hwndD
 
         case VK_CANCEL:
         case VK_ESCAPE:
-            SendMessageW( hwndDlg, WM_COMMAND, IDCANCEL, (LPARAM)GetDlgItem( hwndDlg, IDCANCEL ) );
+    {
+            HMENU Mn;
+            MENUITEMINFOA ItemInfo;
+        
+            ZeroMemory(&ItemInfo, sizeof(MENUITEMINFOA));
+            ItemInfo.cbSize=sizeof(ItemInfo);
+            ItemInfo.fMask=MIIM_STATE;
+            Mn=GetSystemMenu(hwndDlg,0);
+            if(!GetMenuItemInfoA(Mn,SC_CLOSE,0,&ItemInfo))
+                SendMessageW( hwndDlg, WM_COMMAND, IDCANCEL, (LPARAM)GetDlgItem( hwndDlg, IDCANCEL ) );
+           
             return TRUE;
+    }
 
         case VK_EXECUTE:
         case VK_RETURN: