Index: trunk/src/user32/dbgwrap.cpp
===================================================================
--- trunk/src/user32/dbgwrap.cpp	(revision 10189)
+++ trunk/src/user32/dbgwrap.cpp	(revision 10190)
@@ -312,4 +312,5 @@
 DEBUGWRAP8(GetMenuInfo)
 DEBUGWRAP8(SetMenuInfo)
+DEBUGWRAP_LVL2_12(TranslateAcceleratorA)
 
 #undef DBG_LOCALLOG
@@ -448,5 +449,5 @@
 
 #undef DBG_LOCALLOG
-#define DBG_LOCALLOG	DBG_display
+#define DBG_LOCALLOG    DBG_display
 DEBUGWRAP8(GetMonitorInfoW)
 DEBUGWRAP8(GetMonitorInfoA)
@@ -479,5 +480,5 @@
 
 #undef DBG_LOCALLOG
-#define DBG_LOCALLOG	DBG_hook
+#define DBG_LOCALLOG    DBG_hook
 DEBUGWRAP16(CallNextHookEx)
 DEBUGWRAP8(SetWindowsHookA)
@@ -489,5 +490,5 @@
 
 #undef DBG_LOCALLOG
-#define DBG_LOCALLOG	DBG_windowmsg
+#define DBG_LOCALLOG    DBG_windowmsg
 DEBUGWRAP20(MsgWaitForMultipleObjects)
 DEBUGWRAP20(BroadcastSystemMessage)
@@ -547,5 +548,5 @@
 
 #undef DBG_LOCALLOG
-#define DBG_LOCALLOG	DBG_defwndproc
+#define DBG_LOCALLOG    DBG_defwndproc
 
 DEBUGWRAP_LVL2_16(DefDlgProcA)
@@ -560,5 +561,5 @@
 
 #undef DBG_LOCALLOG
-#define DBG_LOCALLOG	DBG_windlg
+#define DBG_LOCALLOG    DBG_windlg
 DEBUGWRAP16(SetDlgItemInt)
 DEBUGWRAP12(SetDlgItemTextA)
@@ -609,5 +610,5 @@
 
 #undef DBG_LOCALLOG
-#define DBG_LOCALLOG	DBG_winmouse
+#define DBG_LOCALLOG    DBG_winmouse
 DEBUGWRAP4(GetCursorPos)
 DEBUGWRAP8(SetCursorPos)
@@ -623,5 +624,5 @@
 
 #undef DBG_LOCALLOG
-#define DBG_LOCALLOG	DBG_caret
+#define DBG_LOCALLOG    DBG_caret
 DEBUGWRAP16(CreateCaret)
 DEBUGWRAP0(DestroyCaret)
@@ -662,5 +663,5 @@
 
 #undef DBG_LOCALLOG
-#define DBG_LOCALLOG	DBG_timer
+#define DBG_LOCALLOG    DBG_timer
 DEBUGWRAP8(KillTimer)
 DEBUGWRAP16(SetTimer)
@@ -784,5 +785,4 @@
 DEBUGWRAP8(CreateAcceleratorTableW)
 DEBUGWRAP4(DestroyAcceleratorTable)
-DEBUGWRAP12(TranslateAcceleratorA)
 DEBUGWRAP8(TranslateMDISysAccel)
 DEBUGWRAP8(LoadAcceleratorsA)
Index: trunk/src/user32/menu.c
===================================================================
--- trunk/src/user32/menu.c	(revision 10189)
+++ trunk/src/user32/menu.c	(revision 10190)
@@ -44,4 +44,6 @@
 #include "oslibmsg.h"
 #include "oslibwin.h"
+#include "heapstring.h"
+
 
 HBRUSH WIN32API GetOS2ColorBrush(int nIndex);
@@ -55,27 +57,27 @@
 DECLARE_DEBUG_CHANNEL(accel);
 
-#define HACCEL_16(h32)		(LOWORD(h32))
+#define HACCEL_16(h32)      (LOWORD(h32))
 
 /* internal popup menu window messages */
 
-#define MM_SETMENUHANDLE	(WM_USER + 0)
-#define MM_GETMENUHANDLE	(WM_USER + 1)
+#define MM_SETMENUHANDLE    (WM_USER + 0)
+#define MM_GETMENUHANDLE    (WM_USER + 1)
 
 /* Menu item structure */
 typedef struct {
     /* ----------- MENUITEMINFO Stuff ----------- */
-    UINT fType;			/* Item type. */
-    UINT fState;		/* Item state.  */
-    UINT wID;			/* Item id.  */
-    HMENU hSubMenu;		/* Pop-up menu.  */
-    HBITMAP hCheckBit;		/* Bitmap when checked.  */
-    HBITMAP hUnCheckBit;	/* Bitmap when unchecked.  */
-    LPWSTR text;			/* Item text or bitmap handle.  */
-    DWORD dwItemData;		/* Application defined.  */
-    DWORD dwTypeData;		/* depends on fMask */
-    HBITMAP hbmpItem;		/* bitmap in win98 style menus */
+    UINT fType;         /* Item type. */
+    UINT fState;        /* Item state.  */
+    UINT wID;           /* Item id.  */
+    HMENU hSubMenu;     /* Pop-up menu.  */
+    HBITMAP hCheckBit;      /* Bitmap when checked.  */
+    HBITMAP hUnCheckBit;    /* Bitmap when unchecked.  */
+    LPWSTR text;            /* Item text or bitmap handle.  */
+    DWORD dwItemData;       /* Application defined.  */
+    DWORD dwTypeData;       /* depends on fMask */
+    HBITMAP hbmpItem;       /* bitmap in win98 style menus */
     /* ----------- Wine stuff ----------- */
-    RECT      rect;		/* Item area (relative to menu window) */
-    UINT      xTab;		/* X position of text after Tab */
+    RECT      rect;     /* Item area (relative to menu window) */
+    UINT      xTab;     /* X position of text after Tab */
 } MENUITEM;
 
@@ -84,18 +86,18 @@
     WORD        wFlags;       /* Menu flags (MF_POPUP, MF_SYSMENU) */
     WORD        wMagic;       /* Magic number */
-    WORD	Width;        /* Width of the whole menu */
-    WORD	Height;       /* Height of the whole menu */
+    WORD    Width;        /* Width of the whole menu */
+    WORD    Height;       /* Height of the whole menu */
     UINT        nItems;       /* Number of items in the menu */
     HWND        hWnd;         /* Window containing the menu */
     MENUITEM    *items;       /* Array of menu items */
     UINT        FocusedItem;  /* Currently focused item */
-    HWND	hwndOwner;    /* window receiving the messages for ownerdraw */
+    HWND    hwndOwner;    /* window receiving the messages for ownerdraw */
     BOOL        bTimeToHide;  /* Request hiding when receiving a second click in the top-level menu item */
     /* ------------ MENUINFO members ------ */
-    DWORD	dwStyle;	/* Extended mennu style */
-    UINT	cyMax;		/* max hight of the whole menu, 0 is screen hight */
-    HBRUSH	hbrBack;	/* brush for menu background */
-    DWORD	dwContextHelpID;
-    DWORD	dwMenuData;	/* application defined value */
+    DWORD   dwStyle;    /* Extended mennu style */
+    UINT    cyMax;      /* max hight of the whole menu, 0 is screen hight */
+    HBRUSH  hbrBack;    /* brush for menu background */
+    DWORD   dwContextHelpID;
+    DWORD   dwMenuData; /* application defined value */
     HMENU       hSysMenuOwner;  /* Handle to the dummy sys menu holder */
 } POPUPMENU, *LPPOPUPMENU;
@@ -105,29 +107,29 @@
 #define TF_ENDMENU              0x0001
 #define TF_SUSPENDPOPUP         0x0002
-#define TF_SKIPREMOVE		0x0004
+#define TF_SKIPREMOVE       0x0004
 
 typedef struct
 {
-    UINT	trackFlags;
-    HMENU	hCurrentMenu; /* current submenu (can be equal to hTopMenu)*/
-    HMENU	hTopMenu;     /* initial menu */
-    HWND	hOwnerWnd;    /* where notifications are sent */
-    POINT	pt;
+    UINT    trackFlags;
+    HMENU   hCurrentMenu; /* current submenu (can be equal to hTopMenu)*/
+    HMENU   hTopMenu;     /* initial menu */
+    HWND    hOwnerWnd;    /* where notifications are sent */
+    POINT   pt;
 } MTRACKER;
 
 #define MENU_MAGIC   0x554d  /* 'MU' */
 
-#define ITEM_PREV		-1
-#define ITEM_NEXT		 1
+#define ITEM_PREV       -1
+#define ITEM_NEXT        1
 
   /* Internal MENU_TrackMenu() flags */
-#define TPM_INTERNAL		0xF0000000
-#define TPM_ENTERIDLEEX	 	0x80000000		/* set owner window for WM_ENTERIDLE */
-#define TPM_BUTTONDOWN		0x40000000		/* menu was clicked before tracking */
+#define TPM_INTERNAL        0xF0000000
+#define TPM_ENTERIDLEEX     0x80000000      /* set owner window for WM_ENTERIDLE */
+#define TPM_BUTTONDOWN      0x40000000      /* menu was clicked before tracking */
 #define TPM_POPUPMENU           0x20000000              /* menu is a popup menu */
 
   /* popup menu shade thickness */
-#define POPUP_XSHADE		4
-#define POPUP_YSHADE		4
+#define POPUP_XSHADE        4
+#define POPUP_YSHADE        4
 
   /* Space between 2 menu bar items */
@@ -151,13 +153,13 @@
 
 #define IS_SYSTEM_MENU(menu)  \
-	(!((menu)->wFlags & MF_POPUP) && (menu)->wFlags & MF_SYSMENU)
+    (!((menu)->wFlags & MF_POPUP) && (menu)->wFlags & MF_SYSMENU)
 
 #define IS_SYSTEM_POPUP(menu) \
-	((menu)->wFlags & MF_POPUP && (menu)->wFlags & MF_SYSMENU)
+    ((menu)->wFlags & MF_POPUP && (menu)->wFlags & MF_SYSMENU)
 
 #define TYPE_MASK (MFT_STRING | MFT_BITMAP | MFT_OWNERDRAW | MFT_SEPARATOR | \
-		   MFT_MENUBARBREAK | MFT_MENUBREAK | MFT_RADIOCHECK | \
-		   MFT_RIGHTORDER | MFT_RIGHTJUSTIFY | \
-		   MF_POPUP | MF_SYSMENU | MF_HELP)
+           MFT_MENUBARBREAK | MFT_MENUBREAK | MFT_RADIOCHECK | \
+           MFT_RIGHTORDER | MFT_RIGHTJUSTIFY | \
+           MF_POPUP | MF_SYSMENU | MF_HELP)
 #define STATE_MASK (~TYPE_MASK)
 
@@ -168,7 +170,7 @@
 static HBITMAP hBmpSysMenu = 0;
 
-static HBRUSH	hShadeBrush = 0;
-static HFONT	hMenuFont = 0;
-static HFONT	hMenuFontBold = 0;
+static HBRUSH   hShadeBrush = 0;
+static HFONT    hMenuFont = 0;
+static HFONT    hMenuFontBold = 0;
 
 static HMENU MENU_DefSysPopup = 0;  /* Default system menu popup */
@@ -217,72 +219,72 @@
 
 static void do_debug_print_menuitem(const char *prefix, MENUITEM * mp,
-				    const char *postfix)
+                    const char *postfix)
 {
     TRACE("%s ", prefix);
     if (mp) {
-	UINT flags = mp->fType;
-	int typ = MENU_ITEM_TYPE(flags);
-	DPRINTF( "{ ID=0x%x", mp->wID);
-	if (flags & MF_POPUP)
-	    DPRINTF( ", Sub=0x%x", mp->hSubMenu);
-	if (flags) {
-	    int count = 0;
-	    DPRINTF( ", Typ=");
-	    if (typ == MFT_STRING)
-		/* Nothing */ ;
-	    else if (typ == MFT_SEPARATOR)
-		MENUOUT("sep");
-	    else if (typ == MFT_OWNERDRAW)
-		MENUOUT("own");
-	    else if (typ == MFT_BITMAP)
-		MENUOUT("bit");
-	    else
-		MENUOUT("???");
-	    flags -= typ;
-
-	    MENUFLAG(MF_POPUP, "pop");
-	    MENUFLAG(MFT_MENUBARBREAK, "barbrk");
-	    MENUFLAG(MFT_MENUBREAK, "brk");
-	    MENUFLAG(MFT_RADIOCHECK, "radio");
-	    MENUFLAG(MFT_RIGHTORDER, "rorder");
-	    MENUFLAG(MF_SYSMENU, "sys");
-	    MENUFLAG(MFT_RIGHTJUSTIFY, "right");	/* same as MF_HELP */
-
-	    if (flags)
-		DPRINTF( "+0x%x", flags);
-	}
-	flags = mp->fState;
-	if (flags) {
-	    int count = 0;
-	    DPRINTF( ", State=");
-	    MENUFLAG(MFS_GRAYED, "grey");
-	    MENUFLAG(MFS_DEFAULT, "default");
-	    MENUFLAG(MFS_DISABLED, "dis");
-	    MENUFLAG(MFS_CHECKED, "check");
-	    MENUFLAG(MFS_HILITE, "hi");
-	    MENUFLAG(MF_USECHECKBITMAPS, "usebit");
-	    MENUFLAG(MF_MOUSESELECT, "mouse");
-	    if (flags)
-		DPRINTF( "+0x%x", flags);
-	}
-	if (mp->hCheckBit)
-	    DPRINTF( ", Chk=0x%x", mp->hCheckBit);
-	if (mp->hUnCheckBit)
-	    DPRINTF( ", Unc=0x%x", mp->hUnCheckBit);
-
-	if (typ == MFT_STRING) {
-	    if (mp->text)
-		DPRINTF( ", Text=%s", debugstr_w(mp->text));
-	    else
-		DPRINTF( ", Text=Null");
-	} else if (mp->text == NULL)
-	    /* Nothing */ ;
-	else
-	    DPRINTF( ", Text=%p", mp->text);
-	if (mp->dwItemData)
-	    DPRINTF( ", ItemData=0x%08lx", mp->dwItemData);
-	DPRINTF( " }");
+    UINT flags = mp->fType;
+    int typ = MENU_ITEM_TYPE(flags);
+    DPRINTF( "{ ID=0x%x", mp->wID);
+    if (flags & MF_POPUP)
+        DPRINTF( ", Sub=0x%x", mp->hSubMenu);
+    if (flags) {
+        int count = 0;
+        DPRINTF( ", Typ=");
+        if (typ == MFT_STRING)
+        /* Nothing */ ;
+        else if (typ == MFT_SEPARATOR)
+        MENUOUT("sep");
+        else if (typ == MFT_OWNERDRAW)
+        MENUOUT("own");
+        else if (typ == MFT_BITMAP)
+        MENUOUT("bit");
+        else
+        MENUOUT("???");
+        flags -= typ;
+
+        MENUFLAG(MF_POPUP, "pop");
+        MENUFLAG(MFT_MENUBARBREAK, "barbrk");
+        MENUFLAG(MFT_MENUBREAK, "brk");
+        MENUFLAG(MFT_RADIOCHECK, "radio");
+        MENUFLAG(MFT_RIGHTORDER, "rorder");
+        MENUFLAG(MF_SYSMENU, "sys");
+        MENUFLAG(MFT_RIGHTJUSTIFY, "right");    /* same as MF_HELP */
+
+        if (flags)
+        DPRINTF( "+0x%x", flags);
+    }
+    flags = mp->fState;
+    if (flags) {
+        int count = 0;
+        DPRINTF( ", State=");
+        MENUFLAG(MFS_GRAYED, "grey");
+        MENUFLAG(MFS_DEFAULT, "default");
+        MENUFLAG(MFS_DISABLED, "dis");
+        MENUFLAG(MFS_CHECKED, "check");
+        MENUFLAG(MFS_HILITE, "hi");
+        MENUFLAG(MF_USECHECKBITMAPS, "usebit");
+        MENUFLAG(MF_MOUSESELECT, "mouse");
+        if (flags)
+        DPRINTF( "+0x%x", flags);
+    }
+    if (mp->hCheckBit)
+        DPRINTF( ", Chk=0x%x", mp->hCheckBit);
+    if (mp->hUnCheckBit)
+        DPRINTF( ", Unc=0x%x", mp->hUnCheckBit);
+
+    if (typ == MFT_STRING) {
+        if (mp->text)
+        DPRINTF( ", Text=%s", debugstr_w(mp->text));
+        else
+        DPRINTF( ", Text=Null");
+    } else if (mp->text == NULL)
+        /* Nothing */ ;
+    else
+        DPRINTF( ", Text=%p", mp->text);
+    if (mp->dwItemData)
+        DPRINTF( ", ItemData=0x%08lx", mp->dwItemData);
+    DPRINTF( " }");
     } else {
-	DPRINTF( "NULL");
+    DPRINTF( "NULL");
     }
 
@@ -355,5 +357,5 @@
         POPUPMENU* menu = MENU_GetMenu(hMenu);
         menu->wFlags |= MF_SYSMENU | MF_POPUP;
-	SetMenuDefaultItem(hMenu, SC_CLOSE, FALSE);
+    SetMenuDefaultItem(hMenu, SC_CLOSE, FALSE);
 #ifdef __WIN32OS2__
         if(!fDisableOdinSysMenuItems) {
@@ -372,5 +374,5 @@
     }
     else
-	ERR("Unable to load default system menu\n" );
+    ERR("Unable to load default system menu\n" );
 
     TRACE("returning %x.\n", hMenu );
@@ -395,15 +397,15 @@
     if ((hMenu = CreateMenu()))
     {
-	POPUPMENU *menu = MENU_GetMenu(hMenu);
-	menu->wFlags = MF_SYSMENU;
-	menu->hWnd = WIN_GetFullHandle( hWnd );
-
-	if (hPopupMenu == (HMENU)(-1))
-	    hPopupMenu = MENU_CopySysPopup();
-	else if( !hPopupMenu ) hPopupMenu = MENU_DefSysPopup;
-
-	if (hPopupMenu)
-	{
-	    InsertMenuA( hMenu, -1, MF_SYSMENU | MF_POPUP | MF_BYPOSITION, hPopupMenu, NULL );
+    POPUPMENU *menu = MENU_GetMenu(hMenu);
+    menu->wFlags = MF_SYSMENU;
+    menu->hWnd = WIN_GetFullHandle( hWnd );
+
+    if (hPopupMenu == (HMENU)(-1))
+        hPopupMenu = MENU_CopySysPopup();
+    else if( !hPopupMenu ) hPopupMenu = MENU_DefSysPopup;
+
+    if (hPopupMenu)
+    {
+        InsertMenuA( hMenu, -1, MF_SYSMENU | MF_POPUP | MF_BYPOSITION, hPopupMenu, NULL );
 
             menu->items[0].fType = MF_SYSMENU | MF_POPUP;
@@ -411,8 +413,8 @@
             if ((menu = MENU_GetMenu(hPopupMenu))) menu->wFlags |= MF_SYSMENU;
 
-	    TRACE("GetSysMenu hMenu=%04x (%04x)\n", hMenu, hPopupMenu );
-	    return hMenu;
-	}
-	DestroyMenu( hMenu );
+        TRACE("GetSysMenu hMenu=%04x (%04x)\n", hMenu, hPopupMenu );
+        return hMenu;
+    }
+    DestroyMenu( hMenu );
     }
     ERR("failed to load system menu!\n");
@@ -432,7 +434,7 @@
 
     static unsigned char shade_bits[16] = { 0x55, 0, 0xAA, 0,
-					    0x55, 0, 0xAA, 0,
-					    0x55, 0, 0xAA, 0,
-					    0x55, 0, 0xAA, 0 };
+                        0x55, 0, 0xAA, 0,
+                        0x55, 0, 0xAA, 0,
+                        0x55, 0, 0xAA, 0 };
 
     /* Load menu bitmaps */
@@ -443,34 +445,34 @@
     if (hStdMnArrow)
     {
-	BITMAP bm;
-	GetObjectA( hStdMnArrow, sizeof(bm), &bm );
-	arrow_bitmap_width = bm.bmWidth;
-	arrow_bitmap_height = bm.bmHeight;
+    BITMAP bm;
+    GetObjectA( hStdMnArrow, sizeof(bm), &bm );
+    arrow_bitmap_width = bm.bmWidth;
+    arrow_bitmap_height = bm.bmHeight;
     } else
-	return FALSE;
+    return FALSE;
 
     if (! (hBitmap = CreateBitmap( 8, 8, 1, 1, shade_bits)))
-	return FALSE;
+    return FALSE;
 
     if(!(hShadeBrush = CreatePatternBrush( hBitmap )))
-	return FALSE;
+    return FALSE;
 
     DeleteObject( hBitmap );
     if (!(MENU_DefSysPopup = MENU_CopySysPopup()))
-	return FALSE;
+    return FALSE;
 
     ncm.cbSize = sizeof (NONCLIENTMETRICSA);
     if (!(SystemParametersInfoA(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICSA), &ncm, 0)))
-	return FALSE;
+    return FALSE;
 
     if (!(hMenuFont = CreateFontIndirectA( &ncm.lfMenuFont )))
-	return FALSE;
+    return FALSE;
 
     ncm.lfMenuFont.lfWeight += 300;
     if ( ncm.lfMenuFont.lfWeight > 1000)
-	ncm.lfMenuFont.lfWeight = 1000;
+    ncm.lfMenuFont.lfWeight = 1000;
 
     if (!(hMenuFontBold = CreateFontIndirectA( &ncm.lfMenuFont )))
-	return FALSE;
+    return FALSE;
 
     return TRUE;
@@ -500,5 +502,5 @@
     /* The menu item must keep its state if it's disabled */
     if(gray)
-	EnableMenuItem( hmenu, SC_CLOSE, MF_GRAYED);
+    EnableMenuItem( hmenu, SC_CLOSE, MF_GRAYED);
 }
 
@@ -518,13 +520,13 @@
 
     if(!menu)
-	return NO_SELECTED_ITEM;
+    return NO_SELECTED_ITEM;
 
     i = menu->FocusedItem + 1;
     if( i == NO_SELECTED_ITEM )
-	return i;
+    return i;
 
     for( ; i < menu->nItems; ++i ) {
-	if (menu->items[i].fType & MF_MENUBARBREAK)
-	    return i;
+    if (menu->items[i].fType & MF_MENUBARBREAK)
+        return i;
     }
 
@@ -547,21 +549,21 @@
 
     if( !menu )
-	return NO_SELECTED_ITEM;
+    return NO_SELECTED_ITEM;
 
     if( menu->FocusedItem == 0 || menu->FocusedItem == NO_SELECTED_ITEM )
-	return NO_SELECTED_ITEM;
+    return NO_SELECTED_ITEM;
 
     /* Find the start of the column */
 
     for(i = menu->FocusedItem; i != 0 &&
-	 !(menu->items[i].fType & MF_MENUBARBREAK);
-	--i); /* empty */
+     !(menu->items[i].fType & MF_MENUBARBREAK);
+    --i); /* empty */
 
     if(i == 0)
-	return NO_SELECTED_ITEM;
+    return NO_SELECTED_ITEM;
 
     for(--i; i != 0; --i) {
-	if (menu->items[i].fType & MF_MENUBARBREAK)
-	    break;
+    if (menu->items[i].fType & MF_MENUBARBREAK)
+        break;
     }
 
@@ -587,33 +589,33 @@
     if (wFlags & MF_BYPOSITION)
     {
-	if (*nPos >= menu->nItems) return NULL;
-	return &menu->items[*nPos];
+    if (*nPos >= menu->nItems) return NULL;
+    return &menu->items[*nPos];
     }
     else
     {
         MENUITEM *item = menu->items;
-	for (i = 0; i < menu->nItems; i++, item++)
-	{
-	    if (item->wID == *nPos)
-	    {
-		*nPos = i;
-		return item;
-	    }
-	    else if (item->fType & MF_POPUP)
-	    {
-		HMENU hsubmenu = item->hSubMenu;
-		MENUITEM *subitem = MENU_FindItem( &hsubmenu, nPos, wFlags );
+    for (i = 0; i < menu->nItems; i++, item++)
+    {
+        if (item->wID == *nPos)
+        {
+        *nPos = i;
+        return item;
+        }
+        else if (item->fType & MF_POPUP)
+        {
+        HMENU hsubmenu = item->hSubMenu;
+        MENUITEM *subitem = MENU_FindItem( &hsubmenu, nPos, wFlags );
 #ifdef __WIN32OS2__
                 //YD: 2000-12-01: extra check added for loops in menus
                 if (subitem && subitem!=item)
 #else
-		if (subitem)
+        if (subitem)
 #endif
-		{
-		    *hmenu = hsubmenu;
-		    return subitem;
-		}
-	    }
-	}
+        {
+            *hmenu = hsubmenu;
+            return subitem;
+        }
+        }
+    }
     }
     return NULL;
@@ -671,5 +673,5 @@
  */
 static MENUITEM *MENU_FindItemByCoords( POPUPMENU *menu,
-					POINT pt, UINT *pos )
+                    POINT pt, UINT *pos )
 {
     MENUITEM *item;
@@ -682,10 +684,10 @@
     for (i = 0; i < menu->nItems; i++, item++)
     {
-	if ((pt.x >= item->rect.left) && (pt.x < item->rect.right) &&
-	    (pt.y >= item->rect.top) && (pt.y < item->rect.bottom))
-	{
-	    if (pos) *pos = i;
-	    return item;
-	}
+    if ((pt.x >= item->rect.left) && (pt.x < item->rect.right) &&
+        (pt.y >= item->rect.top) && (pt.y < item->rect.bottom))
+    {
+        if (pos) *pos = i;
+        return item;
+    }
     }
     return NULL;
@@ -700,5 +702,5 @@
  */
 static UINT MENU_FindItemByKey( HWND hwndOwner, HMENU hmenu,
-				  UINT key, BOOL forceMenuChar )
+                  UINT key, BOOL forceMenuChar )
 {
     TRACE("\tlooking for '%c' in [%04x]\n", (char)key, (UINT16)hmenu );
@@ -708,31 +710,31 @@
     if (hmenu)
     {
-	POPUPMENU *menu = MENU_GetMenu( hmenu );
-	MENUITEM *item = menu->items;
-	LONG menuchar;
-
-	if( !forceMenuChar )
-	{
-	     UINT i;
-
-	     key = toupper(key);
-	     for (i = 0; i < menu->nItems; i++, item++)
-	     {
-		if (item->text && (IS_STRING_ITEM(item->fType)))
-		{
-		    WCHAR *p = item->text - 2;
-		    do
-		    {
-		    	p = strchrW (p + 2, '&');
-		    }
-		    while (p != NULL && p [1] == '&');
-		    if (p && (toupper(p[1]) == key)) return i;
-		}
-	     }
-	}
-	menuchar = SendMessageA( hwndOwner, WM_MENUCHAR,
+    POPUPMENU *menu = MENU_GetMenu( hmenu );
+    MENUITEM *item = menu->items;
+    LONG menuchar;
+
+    if( !forceMenuChar )
+    {
+         UINT i;
+
+         key = toupper(key);
+         for (i = 0; i < menu->nItems; i++, item++)
+         {
+        if (item->text && (IS_STRING_ITEM(item->fType)))
+        {
+            WCHAR *p = item->text - 2;
+            do
+            {
+                p = strchrW (p + 2, '&');
+            }
+            while (p != NULL && p [1] == '&');
+            if (p && (toupper(p[1]) == key)) return i;
+        }
+         }
+    }
+    menuchar = SendMessageA( hwndOwner, WM_MENUCHAR,
                                    MAKEWPARAM( key, menu->wFlags ), hmenu );
-	if (HIWORD(menuchar) == 2) return LOWORD(menuchar);
-	if (HIWORD(menuchar) == 1) return (UINT)(-2);
+    if (HIWORD(menuchar) == 2) return LOWORD(menuchar);
+    if (HIWORD(menuchar) == 1) return (UINT)(-2);
     }
     return (UINT)(-1);
@@ -888,5 +890,5 @@
  */
 static void MENU_CalcItemSize( HDC hdc, MENUITEM *lpitem, HWND hwndOwner,
-			       INT orgX, INT orgY, BOOL menuBar )
+                   INT orgX, INT orgY, BOOL menuBar )
 {
     WCHAR *p;
@@ -895,5 +897,5 @@
     TRACE("dc=0x%04x owner=0x%04x (%d,%d)\n", hdc, hwndOwner, orgX, orgY);
     debug_print_menuitem("MENU_CalcItemSize: menuitem:", lpitem,
-			 (menuBar ? " (MenuBar)" : ""));
+             (menuBar ? " (MenuBar)" : ""));
 
     SetRect( &lpitem->rect, orgX, orgY, orgX, orgY );
@@ -918,7 +920,7 @@
         lpitem->rect.right  += mis.itemWidth;
 
- 	if (menuBar)
-	{
-	     lpitem->rect.right += MENU_BAR_ITEMS_SPACE;
+    if (menuBar)
+    {
+         lpitem->rect.right += MENU_BAR_ITEMS_SPACE;
 
 
@@ -926,13 +928,13 @@
                 height for the menu and the height value is ignored */
 
-	     if (TWEAK_WineLook == WIN31_LOOK)
-	    	lpitem->rect.bottom += GetSystemMetrics(SM_CYMENU);
-	     else
-	    	lpitem->rect.bottom += GetSystemMetrics(SM_CYMENU)-1;
+         if (TWEAK_WineLook == WIN31_LOOK)
+            lpitem->rect.bottom += GetSystemMetrics(SM_CYMENU);
+         else
+            lpitem->rect.bottom += GetSystemMetrics(SM_CYMENU)-1;
         }
         else
             lpitem->rect.bottom += mis.itemHeight;
 
-	TRACE("id=%04x size=%dx%d\n",
+    TRACE("id=%04x size=%dx%d\n",
                      lpitem->wID, mis.itemWidth, mis.itemHeight);
         /* Fall through to get check/arrow width calculation. */
@@ -941,13 +943,13 @@
     if (lpitem->fType & MF_SEPARATOR)
     {
-	lpitem->rect.bottom += SEPARATOR_HEIGHT;
-	return;
+    lpitem->rect.bottom += SEPARATOR_HEIGHT;
+    return;
     }
 
     if (!menuBar)
     {
-	lpitem->rect.right += 2 * check_bitmap_width;
-	if (lpitem->fType & MF_POPUP)
-	    lpitem->rect.right += arrow_bitmap_width;
+    lpitem->rect.right += 2 * check_bitmap_width;
+    if (lpitem->fType & MF_POPUP)
+        lpitem->rect.right += arrow_bitmap_width;
     }
 
@@ -975,31 +977,31 @@
     {   SIZE size;
 
-	GetTextExtentPoint32W(hdc, lpitem->text,  strlenW(lpitem->text), &size);
-
-	lpitem->rect.right  += size.cx;
-	if (TWEAK_WineLook == WIN31_LOOK)
-	    lpitem->rect.bottom += max( size.cy, GetSystemMetrics(SM_CYMENU) );
-	else
-	    lpitem->rect.bottom += max(size.cy, GetSystemMetrics(SM_CYMENU)-1);
-	lpitem->xTab = 0;
-
-	if (menuBar)
-	{
-	     lpitem->rect.right += MENU_BAR_ITEMS_SPACE;
-	}
-	else if ((p = strchrW( lpitem->text, '\t' )) != NULL)
-	{
-	    /* Item contains a tab (only meaningful in popup menus) */
-	    GetTextExtentPoint32W(hdc, lpitem->text, (int)(p - lpitem->text) , &size);
-	    lpitem->xTab = check_bitmap_width + MENU_TAB_SPACE + size.cx;
-	    lpitem->rect.right += MENU_TAB_SPACE;
-	}
-	else
-	{
-	    if (strchrW( lpitem->text, '\b' ))
-	        lpitem->rect.right += MENU_TAB_SPACE;
-	    lpitem->xTab = lpitem->rect.right - check_bitmap_width
-	                   - arrow_bitmap_width;
-	}
+    GetTextExtentPoint32W(hdc, lpitem->text,  strlenW(lpitem->text), &size);
+
+    lpitem->rect.right  += size.cx;
+    if (TWEAK_WineLook == WIN31_LOOK)
+        lpitem->rect.bottom += max( size.cy, GetSystemMetrics(SM_CYMENU) );
+    else
+        lpitem->rect.bottom += max(size.cy, GetSystemMetrics(SM_CYMENU)-1);
+    lpitem->xTab = 0;
+
+    if (menuBar)
+    {
+         lpitem->rect.right += MENU_BAR_ITEMS_SPACE;
+    }
+    else if ((p = strchrW( lpitem->text, '\t' )) != NULL)
+    {
+        /* Item contains a tab (only meaningful in popup menus) */
+        GetTextExtentPoint32W(hdc, lpitem->text, (int)(p - lpitem->text) , &size);
+        lpitem->xTab = check_bitmap_width + MENU_TAB_SPACE + size.cx;
+        lpitem->rect.right += MENU_TAB_SPACE;
+    }
+    else
+    {
+        if (strchrW( lpitem->text, '\b' ))
+            lpitem->rect.right += MENU_TAB_SPACE;
+        lpitem->xTab = lpitem->rect.right - check_bitmap_width
+                       - arrow_bitmap_width;
+    }
     }
     TRACE("(%d,%d)-(%d,%d)\n", lpitem->rect.left, lpitem->rect.top, lpitem->rect.right, lpitem->rect.bottom);
@@ -1034,38 +1036,38 @@
     while (start < lppop->nItems)
     {
-	lpitem = &lppop->items[start];
-	orgX = maxX;
-	orgY = (TWEAK_WineLook == WIN31_LOOK) ? GetSystemMetrics(SM_CYBORDER) : 2;
-
-	maxTab = maxTabWidth = 0;
-
-	  /* Parse items until column break or end of menu */
-	for (i = start; i < lppop->nItems; i++, lpitem++)
-	{
-	    if ((i != start) &&
-		(lpitem->fType & (MF_MENUBREAK | MF_MENUBARBREAK))) break;
-
-	    MENU_CalcItemSize( hdc, lpitem, hwndOwner, orgX, orgY, FALSE );
-
-	    if (lpitem->fType & MF_MENUBARBREAK) orgX++;
-	    maxX = max( maxX, lpitem->rect.right );
-	    orgY = lpitem->rect.bottom;
-	    if (IS_STRING_ITEM(lpitem->fType) && lpitem->xTab)
-	    {
-		maxTab = max( maxTab, lpitem->xTab );
-		maxTabWidth = max(maxTabWidth,lpitem->rect.right-lpitem->xTab);
-	    }
-	}
-
-	  /* Finish the column (set all items to the largest width found) */
-	maxX = max( maxX, maxTab + maxTabWidth );
-	for (lpitem = &lppop->items[start]; start < i; start++, lpitem++)
-	{
-	    lpitem->rect.right = maxX;
-	    if (IS_STRING_ITEM(lpitem->fType) && lpitem->xTab)
-		lpitem->xTab = maxTab;
-
-	}
-	lppop->Height = max( lppop->Height, orgY );
+    lpitem = &lppop->items[start];
+    orgX = maxX;
+    orgY = (TWEAK_WineLook == WIN31_LOOK) ? GetSystemMetrics(SM_CYBORDER) : 2;
+
+    maxTab = maxTabWidth = 0;
+
+      /* Parse items until column break or end of menu */
+    for (i = start; i < lppop->nItems; i++, lpitem++)
+    {
+        if ((i != start) &&
+        (lpitem->fType & (MF_MENUBREAK | MF_MENUBARBREAK))) break;
+
+        MENU_CalcItemSize( hdc, lpitem, hwndOwner, orgX, orgY, FALSE );
+
+        if (lpitem->fType & MF_MENUBARBREAK) orgX++;
+        maxX = max( maxX, lpitem->rect.right );
+        orgY = lpitem->rect.bottom;
+        if (IS_STRING_ITEM(lpitem->fType) && lpitem->xTab)
+        {
+        maxTab = max( maxTab, lpitem->xTab );
+        maxTabWidth = max(maxTabWidth,lpitem->rect.right-lpitem->xTab);
+        }
+    }
+
+      /* Finish the column (set all items to the largest width found) */
+    maxX = max( maxX, maxTab + maxTabWidth );
+    for (lpitem = &lppop->items[start]; start < i; start++, lpitem++)
+    {
+        lpitem->rect.right = maxX;
+        if (IS_STRING_ITEM(lpitem->fType) && lpitem->xTab)
+        lpitem->xTab = maxTab;
+
+    }
+    lppop->Height = max( lppop->Height, orgY );
     }
 
@@ -1075,6 +1077,6 @@
     if(TWEAK_WineLook > WIN31_LOOK)
     {
-	lppop->Height += 2;
-	lppop->Width += 2;
+    lppop->Height += 2;
+    lppop->Width += 2;
     }
 
@@ -1113,31 +1115,31 @@
     while (start < lppop->nItems)
     {
-	lpitem = &lppop->items[start];
-	orgX = lprect->left;
-	orgY = maxY;
-
-	  /* Parse items until line break or end of menu */
-	for (i = start; i < lppop->nItems; i++, lpitem++)
-	{
-	    if ((helpPos == -1) && (lpitem->fType & MF_RIGHTJUSTIFY)) helpPos = i;
-	    if ((i != start) &&
-		(lpitem->fType & (MF_MENUBREAK | MF_MENUBARBREAK))) break;
-
-	    TRACE("calling MENU_CalcItemSize org=(%d, %d)\n",
-			 orgX, orgY );
-	    debug_print_menuitem ("  item: ", lpitem, "");
-	    MENU_CalcItemSize( hdc, lpitem, hwndOwner, orgX, orgY, TRUE );
-
-	    if (lpitem->rect.right > lprect->right)
-	    {
-		if (i != start) break;
-		else lpitem->rect.right = lprect->right;
-	    }
-	    maxY = max( maxY, lpitem->rect.bottom );
-	    orgX = lpitem->rect.right;
-	}
-
-	  /* Finish the line (set all items to the largest height found) */
-	while (start < i) lppop->items[start++].rect.bottom = maxY;
+    lpitem = &lppop->items[start];
+    orgX = lprect->left;
+    orgY = maxY;
+
+      /* Parse items until line break or end of menu */
+    for (i = start; i < lppop->nItems; i++, lpitem++)
+    {
+        if ((helpPos == -1) && (lpitem->fType & MF_RIGHTJUSTIFY)) helpPos = i;
+        if ((i != start) &&
+        (lpitem->fType & (MF_MENUBREAK | MF_MENUBARBREAK))) break;
+
+        TRACE("calling MENU_CalcItemSize org=(%d, %d)\n",
+             orgX, orgY );
+        debug_print_menuitem ("  item: ", lpitem, "");
+        MENU_CalcItemSize( hdc, lpitem, hwndOwner, orgX, orgY, TRUE );
+
+        if (lpitem->rect.right > lprect->right)
+        {
+        if (i != start) break;
+        else lpitem->rect.right = lprect->right;
+        }
+        maxY = max( maxY, lpitem->rect.bottom );
+        orgX = lpitem->rect.right;
+    }
+
+      /* Finish the line (set all items to the largest height found) */
+    while (start < i) lppop->items[start++].rect.bottom = maxY;
     }
 
@@ -1152,7 +1154,7 @@
     for (i = lppop->nItems - 1; i >= helpPos; i--, lpitem--) {
         if ( (helpPos==-1) || (helpPos>i) )
-            break;				/* done */
-        if (lpitem->rect.top != orgY) break;	/* Other line */
-        if (lpitem->rect.right >= orgX) break;	/* Too far right already */
+            break;              /* done */
+        if (lpitem->rect.top != orgY) break;    /* Other line */
+        if (lpitem->rect.right >= orgX) break;  /* Too far right already */
         lpitem->rect.left += orgX - lpitem->rect.right;
         lpitem->rect.right = orgX;
@@ -1167,5 +1169,5 @@
  */
 static void MENU_DrawMenuItem( HWND hwnd, HMENU hmenu, HWND hwndOwner, HDC hdc, MENUITEM *lpitem,
-			       UINT height, BOOL menuBar, UINT odaction )
+                   UINT height, BOOL menuBar, UINT odaction )
 {
     RECT rect;
@@ -1175,16 +1177,16 @@
     if (lpitem->fType & MF_SYSMENU)
     {
-	if( !IsIconic(hwnd) ) {
-	    if (TWEAK_WineLook > WIN31_LOOK)
-		NC_DrawSysButton95( hwnd, hdc,
-				    lpitem->fState &
-				    (MF_HILITE | MF_MOUSESELECT) );
-	    else
-		NC_DrawSysButton( hwnd, hdc,
-				  lpitem->fState &
-				  (MF_HILITE | MF_MOUSESELECT) );
-	}
-
-	return;
+    if( !IsIconic(hwnd) ) {
+        if (TWEAK_WineLook > WIN31_LOOK)
+        NC_DrawSysButton95( hwnd, hdc,
+                    lpitem->fState &
+                    (MF_HILITE | MF_MOUSESELECT) );
+        else
+        NC_DrawSysButton( hwnd, hdc,
+                  lpitem->fState &
+                  (MF_HILITE | MF_MOUSESELECT) );
+    }
+
+    return;
     }
 
@@ -1203,5 +1205,5 @@
 
         dis.CtlType   = ODT_MENU;
-	dis.CtlID     = 0;
+    dis.CtlID     = 0;
         dis.itemID    = lpitem->wID;
         dis.itemData  = (DWORD)lpitem->dwItemData;
@@ -1215,8 +1217,8 @@
         dis.rcItem     = lpitem->rect;
         TRACE("Ownerdraw: owner=%04x itemID=%d, itemState=%d, itemAction=%d, "
-	      "hwndItem=%04x, hdc=%04x, rcItem={%d,%d,%d,%d}\n", hwndOwner,
-	      dis.itemID, dis.itemState, dis.itemAction, dis.hwndItem,
-	      dis.hDC, dis.rcItem.left, dis.rcItem.top, dis.rcItem.right,
-	      dis.rcItem.bottom);
+          "hwndItem=%04x, hdc=%04x, rcItem={%d,%d,%d,%d}\n", hwndOwner,
+          dis.itemID, dis.itemState, dis.itemAction, dis.hwndItem,
+          dis.hDC, dis.rcItem.left, dis.rcItem.top, dis.rcItem.right,
+          dis.rcItem.bottom);
         SendMessageA( hwndOwner, WM_DRAWITEM, 0, (LPARAM)&dis );
         /* Fall through to draw popup-menu arrow */
@@ -1224,5 +1226,5 @@
 
     TRACE("rect={%d,%d,%d,%d}\n", lpitem->rect.left, lpitem->rect.top,
-					lpitem->rect.right,lpitem->rect.bottom);
+                    lpitem->rect.right,lpitem->rect.bottom);
 
     if (menuBar && (lpitem->fType & MF_SEPARATOR)) return;
@@ -1232,29 +1234,29 @@
     if (!(lpitem->fType & MF_OWNERDRAW))
     {
-	if (lpitem->fState & MF_HILITE)
-	{
+    if (lpitem->fState & MF_HILITE)
+    {
 #ifdef __WIN32OS2__
-            if(!fOS2Look) 
+            if(!fOS2Look)
 #else
-	    if(TWEAK_WineLook == WIN98_LOOK)
+        if(TWEAK_WineLook == WIN98_LOOK)
 #endif
-	    {
-		if(menuBar)
-		    DrawEdge(hdc, &rect, BDR_SUNKENOUTER, BF_RECT);
-		else
-		    FillRect(hdc, &rect, GetSysColorBrush(COLOR_HIGHLIGHT));
-	    }
-	    else /* Not Win98 Look */
-	    {
-		if(!IS_BITMAP_ITEM(lpitem->fType))
+        {
+        if(menuBar)
+            DrawEdge(hdc, &rect, BDR_SUNKENOUTER, BF_RECT);
+        else
+            FillRect(hdc, &rect, GetSysColorBrush(COLOR_HIGHLIGHT));
+        }
+        else /* Not Win98 Look */
+        {
+        if(!IS_BITMAP_ITEM(lpitem->fType))
 #ifdef __WIN32OS2__
-		    FillRect(hdc, &rect, GetOS2ColorBrush(PMSYSCLR_MENUHILITEBGND));
+            FillRect(hdc, &rect, GetOS2ColorBrush(PMSYSCLR_MENUHILITEBGND));
 #else
-		    FillRect(hdc, &rect, GetSysColorBrush(COLOR_HIGHLIGHT));
+            FillRect(hdc, &rect, GetSysColorBrush(COLOR_HIGHLIGHT));
 #endif
-	    }
-	}
+        }
+    }
         else
-	    FillRect( hdc, &rect, GetSysColorBrush(COLOR_MENU) );
+        FillRect( hdc, &rect, GetSysColorBrush(COLOR_MENU) );
     }
 
@@ -1266,17 +1268,17 @@
         if (!menuBar && (lpitem->fType & MF_MENUBARBREAK))
         {
-	    if (TWEAK_WineLook > WIN31_LOOK)
-	    {
-	        RECT rc = rect;
-	        rc.top = 3;
-	        rc.bottom = height - 3;
-	        DrawEdge (hdc, &rc, EDGE_ETCHED, BF_LEFT);
-	    }
-	    else
-	    {
-	        SelectObject( hdc, GetSysColorPen(COLOR_WINDOWFRAME) );
-	        MoveToEx( hdc, rect.left, 0, NULL );
-	        LineTo( hdc, rect.left, height );
-	    }
+        if (TWEAK_WineLook > WIN31_LOOK)
+        {
+            RECT rc = rect;
+            rc.top = 3;
+            rc.bottom = height - 3;
+            DrawEdge (hdc, &rc, EDGE_ETCHED, BF_LEFT);
+        }
+        else
+        {
+            SelectObject( hdc, GetSysColorPen(COLOR_WINDOWFRAME) );
+            MoveToEx( hdc, rect.left, 0, NULL );
+            LineTo( hdc, rect.left, height );
+        }
         }
 
@@ -1284,19 +1286,19 @@
         if (lpitem->fType & MF_SEPARATOR)
         {
-	    if (TWEAK_WineLook > WIN31_LOOK)
-	    {
-	        RECT rc = rect;
-	        rc.left++;
-	        rc.right--;
-	        rc.top += SEPARATOR_HEIGHT / 2;
-	        DrawEdge (hdc, &rc, EDGE_ETCHED, BF_TOP);
-	    }
-	    else
-	    {
-	        SelectObject( hdc, GetSysColorPen(COLOR_WINDOWFRAME) );
-	        MoveToEx( hdc, rect.left, rect.top + SEPARATOR_HEIGHT/2, NULL );
-	        LineTo( hdc, rect.right, rect.top + SEPARATOR_HEIGHT/2 );
-	    }
-	    return;
+        if (TWEAK_WineLook > WIN31_LOOK)
+        {
+            RECT rc = rect;
+            rc.left++;
+            rc.right--;
+            rc.top += SEPARATOR_HEIGHT / 2;
+            DrawEdge (hdc, &rc, EDGE_ETCHED, BF_TOP);
+        }
+        else
+        {
+            SelectObject( hdc, GetSysColorPen(COLOR_WINDOWFRAME) );
+            MoveToEx( hdc, rect.left, rect.top + SEPARATOR_HEIGHT/2, NULL );
+            LineTo( hdc, rect.right, rect.top + SEPARATOR_HEIGHT/2 );
+        }
+        return;
         }
     }
@@ -1307,50 +1309,50 @@
     {
 #ifdef __WIN32OS2__
-        if(!fOS2Look) 
+        if(!fOS2Look)
 #else
-	if(TWEAK_WineLook == WIN98_LOOK)
+    if(TWEAK_WineLook == WIN98_LOOK)
 #endif
-	{
+    {
             if(menuBar) {
-		SetTextColor(hdc, GetSysColor(COLOR_MENUTEXT));
+        SetTextColor(hdc, GetSysColor(COLOR_MENUTEXT));
                 SetBkColor(hdc, GetSysColor(COLOR_MENU));
-	    } else {
-		if(lpitem->fState & MF_GRAYED)
-		    SetTextColor(hdc, GetSysColor(COLOR_GRAYTEXT));
-		else
-		    SetTextColor(hdc, GetSysColor(COLOR_HIGHLIGHTTEXT));
+        } else {
+        if(lpitem->fState & MF_GRAYED)
+            SetTextColor(hdc, GetSysColor(COLOR_GRAYTEXT));
+        else
+            SetTextColor(hdc, GetSysColor(COLOR_HIGHLIGHTTEXT));
                 SetBkColor(hdc, GetSysColor(COLOR_HIGHLIGHT));
-	    }
-	}
-	else /* Not Win98 Look */
-	{
-	    SetTextColor(hdc, GetSysColor(COLOR_HIGHLIGHTTEXT));
-	    if(!IS_BITMAP_ITEM(lpitem->fType))
+        }
+    }
+    else /* Not Win98 Look */
+    {
+        SetTextColor(hdc, GetSysColor(COLOR_HIGHLIGHTTEXT));
+        if(!IS_BITMAP_ITEM(lpitem->fType))
 #ifdef __WIN32OS2__
-		SetBkColor(hdc, GetOS2Color(PMSYSCLR_MENUHILITEBGND));
+        SetBkColor(hdc, GetOS2Color(PMSYSCLR_MENUHILITEBGND));
 #else
-		SetBkColor(hdc, GetSysColor(COLOR_HIGHLIGHT));
+        SetBkColor(hdc, GetSysColor(COLOR_HIGHLIGHT));
 #endif
-	}
+    }
     }
     else
     {
-	if (lpitem->fState & MF_GRAYED)
-	    SetTextColor( hdc, GetSysColor( COLOR_GRAYTEXT ) );
-	else
-	    SetTextColor( hdc, GetSysColor( COLOR_MENUTEXT ) );
-	SetBkColor( hdc, GetSysColor( COLOR_MENU ) );
-    }
-
-	/* helper lines for debugging */
-/*	FrameRect(hdc, &rect, GetStockObject(BLACK_BRUSH));
-	SelectObject( hdc, GetSysColorPen(COLOR_WINDOWFRAME) );
-	MoveToEx( hdc, rect.left, (rect.top + rect.bottom)/2, NULL );
-	LineTo( hdc, rect.right, (rect.top + rect.bottom)/2 );
+    if (lpitem->fState & MF_GRAYED)
+        SetTextColor( hdc, GetSysColor( COLOR_GRAYTEXT ) );
+    else
+        SetTextColor( hdc, GetSysColor( COLOR_MENUTEXT ) );
+    SetBkColor( hdc, GetSysColor( COLOR_MENU ) );
+    }
+
+    /* helper lines for debugging */
+/*  FrameRect(hdc, &rect, GetStockObject(BLACK_BRUSH));
+    SelectObject( hdc, GetSysColorPen(COLOR_WINDOWFRAME) );
+    MoveToEx( hdc, rect.left, (rect.top + rect.bottom)/2, NULL );
+    LineTo( hdc, rect.right, (rect.top + rect.bottom)/2 );
 */
 
     if (!menuBar)
     {
-	INT	y = rect.top + rect.bottom;
+    INT y = rect.top + rect.bottom;
         UINT check_bitmap_width = GetSystemMetrics( SM_CXMENUCHECK );
         UINT check_bitmap_height = GetSystemMetrics( SM_CYMENUCHECK );
@@ -1358,9 +1360,9 @@
         if (!(lpitem->fType & MF_OWNERDRAW))
         {
-	      /* Draw the check mark
-	       *
-	       * FIXME:
-	       * Custom checkmark bitmaps are monochrome but not always 1bpp.
-	       */
+          /* Draw the check mark
+           *
+           * FIXME:
+           * Custom checkmark bitmaps are monochrome but not always 1bpp.
+           */
             HBITMAP bm = (lpitem->fState & MF_CHECKED) ? lpitem->hCheckBit : lpitem->hUnCheckBit;
             if (bm)  /* we have a custom bitmap */
@@ -1390,21 +1392,21 @@
         }
 
-	  /* Draw the popup-menu arrow */
-	if (lpitem->fType & MF_POPUP)
-	{
-	    HDC hdcMem = CreateCompatibleDC( hdc );
-	    HBITMAP hOrigBitmap;
-
-	    hOrigBitmap = SelectObject( hdcMem, hStdMnArrow );
-	    BitBlt( hdc, rect.right - arrow_bitmap_width - 1,
-		      (y - arrow_bitmap_height) / 2,
-		      arrow_bitmap_width, arrow_bitmap_height,
-		      hdcMem, 0, 0, SRCCOPY );
+      /* Draw the popup-menu arrow */
+    if (lpitem->fType & MF_POPUP)
+    {
+        HDC hdcMem = CreateCompatibleDC( hdc );
+        HBITMAP hOrigBitmap;
+
+        hOrigBitmap = SelectObject( hdcMem, hStdMnArrow );
+        BitBlt( hdc, rect.right - arrow_bitmap_width - 1,
+              (y - arrow_bitmap_height) / 2,
+              arrow_bitmap_width, arrow_bitmap_height,
+              hdcMem, 0, 0, SRCCOPY );
             SelectObject( hdcMem, hOrigBitmap );
-	    DeleteDC( hdcMem );
-	}
-
-	rect.left += check_bitmap_width;
-	rect.right -= arrow_bitmap_width;
+        DeleteDC( hdcMem );
+    }
+
+    rect.left += check_bitmap_width;
+    rect.right -= arrow_bitmap_width;
     }
 
@@ -1417,5 +1419,5 @@
     {
         MENU_DrawBitmapItem( hdc, lpitem, &rect, menuBar );
-	return;
+    return;
 
     }
@@ -1423,73 +1425,73 @@
     else if (IS_STRING_ITEM(lpitem->fType))
     {
-	register int i;
-	HFONT hfontOld = 0;
-
-	UINT uFormat = (menuBar) ?
-			DT_CENTER | DT_VCENTER | DT_SINGLELINE :
-			DT_LEFT | DT_VCENTER | DT_SINGLELINE;
+    register int i;
+    HFONT hfontOld = 0;
+
+    UINT uFormat = (menuBar) ?
+            DT_CENTER | DT_VCENTER | DT_SINGLELINE :
+            DT_LEFT | DT_VCENTER | DT_SINGLELINE;
 
 #ifdef __WIN32OS2__
-	if ( lpitem->fState & MFS_DEFAULT && !fOS2Look)
+    if ( lpitem->fState & MFS_DEFAULT && !fOS2Look)
 #else
-	if ( lpitem->fState & MFS_DEFAULT )
+    if ( lpitem->fState & MFS_DEFAULT )
 #endif
-	{
-	     hfontOld = SelectObject( hdc, hMenuFontBold);
-	}
-
-	if (menuBar)
-	{
-	    rect.left += MENU_BAR_ITEMS_SPACE / 2;
-	    rect.right -= MENU_BAR_ITEMS_SPACE / 2;
-	}
-
-	for (i = 0; lpitem->text[i]; i++)
-	    if ((lpitem->text[i] == '\t') || (lpitem->text[i] == '\b'))
-	        break;
-
-	if( (TWEAK_WineLook != WIN31_LOOK) && (lpitem->fState & MF_GRAYED))
-	{
-	    if (!(lpitem->fState & MF_HILITE) )
-	    {
-		++rect.left; ++rect.top; ++rect.right; ++rect.bottom;
-		SetTextColor(hdc, RGB(0xff, 0xff, 0xff));
-		DrawTextW( hdc, lpitem->text, i, &rect, uFormat );
-		--rect.left; --rect.top; --rect.right; --rect.bottom;
-	    }
-	    SetTextColor(hdc, RGB(0x80, 0x80, 0x80));
-	}
-
-	DrawTextW( hdc, lpitem->text, i, &rect, uFormat);
-
-	/* paint the shortcut text */
-	if (!menuBar && lpitem->text[i])  /* There's a tab or flush-right char */
-	{
-	    if (lpitem->text[i] == '\t')
-	    {
-		rect.left = lpitem->xTab;
-		uFormat = DT_LEFT | DT_VCENTER | DT_SINGLELINE;
-	    }
-	    else
-	    {
-		uFormat = DT_RIGHT | DT_VCENTER | DT_SINGLELINE;
-	    }
-
-	    if( !(TWEAK_WineLook == WIN31_LOOK) && (lpitem->fState & MF_GRAYED))
-	    {
-		if (!(lpitem->fState & MF_HILITE) )
-		{
-		    ++rect.left; ++rect.top; ++rect.right; ++rect.bottom;
-		    SetTextColor(hdc, RGB(0xff, 0xff, 0xff));
-		    DrawTextW( hdc, lpitem->text + i + 1, -1, &rect, uFormat );
-		    --rect.left; --rect.top; --rect.right; --rect.bottom;
-		}
-		SetTextColor(hdc, RGB(0x80, 0x80, 0x80));
-	    }
-	    DrawTextW( hdc, lpitem->text + i + 1, -1, &rect, uFormat );
-	}
-
-	if (hfontOld)
-	    SelectObject (hdc, hfontOld);
+    {
+         hfontOld = SelectObject( hdc, hMenuFontBold);
+    }
+
+    if (menuBar)
+    {
+        rect.left += MENU_BAR_ITEMS_SPACE / 2;
+        rect.right -= MENU_BAR_ITEMS_SPACE / 2;
+    }
+
+    for (i = 0; lpitem->text[i]; i++)
+        if ((lpitem->text[i] == '\t') || (lpitem->text[i] == '\b'))
+            break;
+
+    if( (TWEAK_WineLook != WIN31_LOOK) && (lpitem->fState & MF_GRAYED))
+    {
+        if (!(lpitem->fState & MF_HILITE) )
+        {
+        ++rect.left; ++rect.top; ++rect.right; ++rect.bottom;
+        SetTextColor(hdc, RGB(0xff, 0xff, 0xff));
+        DrawTextW( hdc, lpitem->text, i, &rect, uFormat );
+        --rect.left; --rect.top; --rect.right; --rect.bottom;
+        }
+        SetTextColor(hdc, RGB(0x80, 0x80, 0x80));
+    }
+
+    DrawTextW( hdc, lpitem->text, i, &rect, uFormat);
+
+    /* paint the shortcut text */
+    if (!menuBar && lpitem->text[i])  /* There's a tab or flush-right char */
+    {
+        if (lpitem->text[i] == '\t')
+        {
+        rect.left = lpitem->xTab;
+        uFormat = DT_LEFT | DT_VCENTER | DT_SINGLELINE;
+        }
+        else
+        {
+        uFormat = DT_RIGHT | DT_VCENTER | DT_SINGLELINE;
+        }
+
+        if( !(TWEAK_WineLook == WIN31_LOOK) && (lpitem->fState & MF_GRAYED))
+        {
+        if (!(lpitem->fState & MF_HILITE) )
+        {
+            ++rect.left; ++rect.top; ++rect.right; ++rect.bottom;
+            SetTextColor(hdc, RGB(0xff, 0xff, 0xff));
+            DrawTextW( hdc, lpitem->text + i + 1, -1, &rect, uFormat );
+            --rect.left; --rect.top; --rect.right; --rect.bottom;
+        }
+        SetTextColor(hdc, RGB(0x80, 0x80, 0x80));
+        }
+        DrawTextW( hdc, lpitem->text + i + 1, -1, &rect, uFormat );
+    }
+
+    if (hfontOld)
+        SelectObject (hdc, hfontOld);
     }
 }
@@ -1512,6 +1514,6 @@
     if(TWEAK_WineLook == WIN31_LOOK)
     {
-	rect.bottom -= POPUP_YSHADE * GetSystemMetrics(SM_CYBORDER);
-	rect.right -= POPUP_XSHADE * GetSystemMetrics(SM_CXBORDER);
+    rect.bottom -= POPUP_YSHADE * GetSystemMetrics(SM_CYBORDER);
+    rect.right -= POPUP_XSHADE * GetSystemMetrics(SM_CXBORDER);
     }
 
@@ -1519,53 +1521,53 @@
         && (SelectObject( hdc, hMenuFont)))
     {
-	HPEN hPrevPen;
-
-	Rectangle( hdc, rect.left, rect.top, rect.right, rect.bottom );
-
-	hPrevPen = SelectObject( hdc, GetStockObject( NULL_PEN ) );
-	if( hPrevPen )
-	{
-	    INT ropPrev, i;
-	    POPUPMENU *menu;
-
-	    /* draw 3-d shade */
-	    if(TWEAK_WineLook == WIN31_LOOK) {
-		SelectObject( hdc, hShadeBrush );
-		SetBkMode( hdc, TRANSPARENT );
-		ropPrev = SetROP2( hdc, R2_MASKPEN );
-
-		i = rect.right;		/* why SetBrushOrg() doesn't? */
-		PatBlt( hdc, i & 0xfffffffe,
-			  rect.top + POPUP_YSHADE*GetSystemMetrics(SM_CYBORDER),
-			  i%2 + POPUP_XSHADE*GetSystemMetrics(SM_CXBORDER),
-			  rect.bottom - rect.top, 0x00a000c9 );
-		i = rect.bottom;
-		PatBlt( hdc, rect.left + POPUP_XSHADE*GetSystemMetrics(SM_CXBORDER),
-			  i & 0xfffffffe,rect.right - rect.left,
-			  i%2 + POPUP_YSHADE*GetSystemMetrics(SM_CYBORDER), 0x00a000c9 );
-		SelectObject( hdc, hPrevPen );
-		SelectObject( hdc, hPrevBrush );
-		SetROP2( hdc, ropPrev );
-	    }
-	    else
-		DrawEdge (hdc, &rect, EDGE_RAISED, BF_RECT);
-
-	    /* draw menu items */
-
-	    menu = MENU_GetMenu( hmenu );
-	    if (menu && menu->nItems)
-	    {
-		MENUITEM *item;
-		UINT u;
-
-		for (u = menu->nItems, item = menu->items; u > 0; u--, item++)
-		    MENU_DrawMenuItem( hwnd, hmenu, menu->hwndOwner, hdc, item,
-				       menu->Height, FALSE, ODA_DRAWENTIRE );
-
-	    }
-	} else
-	{
-	    SelectObject( hdc, hPrevBrush );
-	}
+    HPEN hPrevPen;
+
+    Rectangle( hdc, rect.left, rect.top, rect.right, rect.bottom );
+
+    hPrevPen = SelectObject( hdc, GetStockObject( NULL_PEN ) );
+    if( hPrevPen )
+    {
+        INT ropPrev, i;
+        POPUPMENU *menu;
+
+        /* draw 3-d shade */
+        if(TWEAK_WineLook == WIN31_LOOK) {
+        SelectObject( hdc, hShadeBrush );
+        SetBkMode( hdc, TRANSPARENT );
+        ropPrev = SetROP2( hdc, R2_MASKPEN );
+
+        i = rect.right;     /* why SetBrushOrg() doesn't? */
+        PatBlt( hdc, i & 0xfffffffe,
+              rect.top + POPUP_YSHADE*GetSystemMetrics(SM_CYBORDER),
+              i%2 + POPUP_XSHADE*GetSystemMetrics(SM_CXBORDER),
+              rect.bottom - rect.top, 0x00a000c9 );
+        i = rect.bottom;
+        PatBlt( hdc, rect.left + POPUP_XSHADE*GetSystemMetrics(SM_CXBORDER),
+              i & 0xfffffffe,rect.right - rect.left,
+              i%2 + POPUP_YSHADE*GetSystemMetrics(SM_CYBORDER), 0x00a000c9 );
+        SelectObject( hdc, hPrevPen );
+        SelectObject( hdc, hPrevBrush );
+        SetROP2( hdc, ropPrev );
+        }
+        else
+        DrawEdge (hdc, &rect, EDGE_RAISED, BF_RECT);
+
+        /* draw menu items */
+
+        menu = MENU_GetMenu( hmenu );
+        if (menu && menu->nItems)
+        {
+        MENUITEM *item;
+        UINT u;
+
+        for (u = menu->nItems, item = menu->items; u > 0; u--, item++)
+            MENU_DrawMenuItem( hwnd, hmenu, menu->hwndOwner, hdc, item,
+                       menu->Height, FALSE, ODA_DRAWENTIRE );
+
+        }
+    } else
+    {
+        SelectObject( hdc, hPrevBrush );
+    }
     }
 }
@@ -1611,13 +1613,13 @@
     if (TWEAK_WineLook == WIN31_LOOK)
     {
-	SelectObject( hDC, GetSysColorPen(COLOR_WINDOWFRAME) );
-	MoveToEx( hDC, lprect->left, lprect->bottom, NULL );
-	LineTo( hDC, lprect->right, lprect->bottom );
+    SelectObject( hDC, GetSysColorPen(COLOR_WINDOWFRAME) );
+    MoveToEx( hDC, lprect->left, lprect->bottom, NULL );
+    LineTo( hDC, lprect->right, lprect->bottom );
     }
     else
     {
-	SelectObject( hDC, GetSysColorPen(COLOR_3DFACE));
-	MoveToEx( hDC, lprect->left, lprect->bottom, NULL );
-	LineTo( hDC, lprect->right, lprect->bottom );
+    SelectObject( hDC, GetSysColorPen(COLOR_3DFACE));
+    MoveToEx( hDC, lprect->left, lprect->bottom, NULL );
+    LineTo( hDC, lprect->right, lprect->bottom );
     }
 
@@ -1658,6 +1660,6 @@
     if (menu->FocusedItem != NO_SELECTED_ITEM)
     {
-	menu->items[menu->FocusedItem].fState &= ~(MF_HILITE|MF_MOUSESELECT);
-	menu->FocusedItem = NO_SELECTED_ITEM;
+    menu->items[menu->FocusedItem].fState &= ~(MF_HILITE|MF_MOUSESELECT);
+    menu->FocusedItem = NO_SELECTED_ITEM;
     }
 
@@ -1737,8 +1739,8 @@
     if (lppop->FocusedItem != NO_SELECTED_ITEM)
     {
-	lppop->items[lppop->FocusedItem].fState &= ~(MF_HILITE|MF_MOUSESELECT);
-	MENU_DrawMenuItem(lppop->hWnd, hmenu, hwndOwner, hdc,&lppop->items[lppop->FocusedItem],
+    lppop->items[lppop->FocusedItem].fState &= ~(MF_HILITE|MF_MOUSESELECT);
+    MENU_DrawMenuItem(lppop->hWnd, hmenu, hwndOwner, hdc,&lppop->items[lppop->FocusedItem],
                           lppop->Height, !(lppop->wFlags & MF_POPUP),
-			  ODA_SELECT );
+              ODA_SELECT );
     }
 
@@ -1756,5 +1758,5 @@
         {
             MENUITEM *ip = &lppop->items[lppop->FocusedItem];
-	    SendMessageA( hwndOwner, WM_MENUSELECT,
+        SendMessageA( hwndOwner, WM_MENUSELECT,
                      MAKELONG(ip->fType & MF_POPUP ? wIndex: ip->wID,
                      ip->fType | ip->fState | MF_MOUSESELECT |
@@ -1797,21 +1799,21 @@
     if ( menu->FocusedItem != NO_SELECTED_ITEM )
     {
-	if( menu->nItems == 1 ) return; else
-	for (i = menu->FocusedItem + offset ; i >= 0 && i < menu->nItems
-					    ; i += offset)
-	    if (!(menu->items[i].fType & MF_SEPARATOR))
-	    {
-		MENU_SelectItem( hwndOwner, hmenu, i, TRUE, 0 );
-		return;
-	    }
+    if( menu->nItems == 1 ) return; else
+    for (i = menu->FocusedItem + offset ; i >= 0 && i < menu->nItems
+                        ; i += offset)
+        if (!(menu->items[i].fType & MF_SEPARATOR))
+        {
+        MENU_SelectItem( hwndOwner, hmenu, i, TRUE, 0 );
+        return;
+        }
     }
 
     for ( i = (offset > 0) ? 0 : menu->nItems - 1;
-		  i >= 0 && i < menu->nItems ; i += offset)
-	if (!(menu->items[i].fType & MF_SEPARATOR))
-	{
-	    MENU_SelectItem( hwndOwner, hmenu, i, TRUE, 0 );
-	    return;
-	}
+          i >= 0 && i < menu->nItems ; i += offset)
+    if (!(menu->items[i].fType & MF_SEPARATOR))
+    {
+        MENU_SelectItem( hwndOwner, hmenu, i, TRUE, 0 );
+        return;
+    }
 }
 
@@ -1863,11 +1865,11 @@
 
     if ((item->fType & MF_POPUP) && (flags & MF_POPUP) && (item->hSubMenu != id) )
-	DestroyMenu( item->hSubMenu );   /* ModifyMenu() spec */
+    DestroyMenu( item->hSubMenu );   /* ModifyMenu() spec */
 
     if (flags & MF_POPUP)
     {
-	POPUPMENU *menu = MENU_GetMenu((UINT16)id);
+    POPUPMENU *menu = MENU_GetMenu((UINT16)id);
         if (menu) menu->wFlags |= MF_POPUP;
-	else
+    else
         {
             item->wID = 0;
@@ -1875,5 +1877,5 @@
             item->fType = 0;
             item->fState = 0;
-	    return FALSE;
+        return FALSE;
         }
     }
@@ -1929,5 +1931,4 @@
 
     /* Create new items array */
-
     newItems = HeapAlloc( GetProcessHeap(), 0, sizeof(MENUITEM) * (menu->nItems+1) );
     if (!newItems)
@@ -1938,8 +1939,8 @@
     if (menu->nItems > 0)
     {
-	  /* Copy the old array into the new one */
-	if (pos > 0) memcpy( newItems, menu->items, pos * sizeof(MENUITEM) );
-	if (pos < menu->nItems) memcpy( &newItems[pos+1], &menu->items[pos],
-					(menu->nItems-pos)*sizeof(MENUITEM) );
+      /* Copy the old array into the new one */
+    if (pos > 0) memcpy( newItems, menu->items, pos * sizeof(MENUITEM) );
+    if (pos < menu->nItems) memcpy( &newItems[pos+1], &menu->items[pos],
+                    (menu->nItems-pos)*sizeof(MENUITEM) );
         HeapFree( GetProcessHeap(), 0, menu->items );
     }
@@ -2005,46 +2006,46 @@
     WORD resinfo;
     do {
-	MENUITEMINFOW mii;
-
-	mii.cbSize = sizeof(mii);
-	mii.fMask = MIIM_STATE | MIIM_ID | MIIM_TYPE;
-	mii.fType = GET_DWORD(res);
+    MENUITEMINFOW mii;
+
+    mii.cbSize = sizeof(mii);
+    mii.fMask = MIIM_STATE | MIIM_ID | MIIM_TYPE;
+    mii.fType = GET_DWORD(res);
         res += sizeof(DWORD);
-	mii.fState = GET_DWORD(res);
+    mii.fState = GET_DWORD(res);
         res += sizeof(DWORD);
-	mii.wID = GET_DWORD(res);
+    mii.wID = GET_DWORD(res);
         res += sizeof(DWORD);
-	resinfo = GET_WORD(res); /* FIXME: for 16-bit apps this is a byte.  */
+    resinfo = GET_WORD(res); /* FIXME: for 16-bit apps this is a byte.  */
         res += sizeof(WORD);
-	/* Align the text on a word boundary.  */
-	res += (~((int)res - 1)) & 1;
-	mii.dwTypeData = (LPWSTR) res;
-	res += (1 + strlenW(mii.dwTypeData)) * sizeof(WCHAR);
-	/* Align the following fields on a dword boundary.  */
-	res += (~((int)res - 1)) & 3;
+    /* Align the text on a word boundary.  */
+    res += (~((int)res - 1)) & 1;
+    mii.dwTypeData = (LPWSTR) res;
+    res += (1 + strlenW(mii.dwTypeData)) * sizeof(WCHAR);
+    /* Align the following fields on a dword boundary.  */
+    res += (~((int)res - 1)) & 3;
 
         TRACE("Menu item: [%08x,%08x,%04x,%04x,%s]\n",
               mii.fType, mii.fState, mii.wID, resinfo, debugstr_w(mii.dwTypeData));
 
-	if (resinfo & 1) {	/* Pop-up? */
-	    /* DWORD helpid = GET_DWORD(res); FIXME: use this.  */
-	    res += sizeof(DWORD);
-	    mii.hSubMenu = CreatePopupMenu();
-	    if (!mii.hSubMenu)
-		return NULL;
-	    if (!(res = MENUEX_ParseResource(res, mii.hSubMenu))) {
-		DestroyMenu(mii.hSubMenu);
+    if (resinfo & 1) {  /* Pop-up? */
+        /* DWORD helpid = GET_DWORD(res); FIXME: use this.  */
+        res += sizeof(DWORD);
+        mii.hSubMenu = CreatePopupMenu();
+        if (!mii.hSubMenu)
+        return NULL;
+        if (!(res = MENUEX_ParseResource(res, mii.hSubMenu))) {
+        DestroyMenu(mii.hSubMenu);
                 return NULL;
             }
-	    mii.fMask |= MIIM_SUBMENU;
-	    mii.fType |= MF_POPUP;
-        }
-	else if(!*mii.dwTypeData && !(mii.fType & MF_SEPARATOR))
-	{
-	    WARN("Converting NULL menu item %04x, type %04x to SEPARATOR\n",
-		mii.wID, mii.fType);
-	    mii.fType |= MF_SEPARATOR;
-	}
-	InsertMenuItemW(hMenu, -1, MF_BYPOSITION, &mii);
+        mii.fMask |= MIIM_SUBMENU;
+        mii.fType |= MF_POPUP;
+        }
+    else if(!*mii.dwTypeData && !(mii.fType & MF_SEPARATOR))
+    {
+        WARN("Converting NULL menu item %04x, type %04x to SEPARATOR\n",
+        mii.wID, mii.fType);
+        mii.fType |= MF_SEPARATOR;
+    }
+    InsertMenuItemW(hMenu, -1, MF_BYPOSITION, &mii);
     } while (!(resinfo & MF_END));
     return res;
@@ -2087,20 +2088,20 @@
     if (menu && top_popup)
     {
-	HMENU hsubmenu;
-	POPUPMENU *submenu;
-	MENUITEM *item;
-
-	if (menu->FocusedItem != NO_SELECTED_ITEM)
-	{
-	    item = &menu->items[menu->FocusedItem];
-	    if (!(item->fType & MF_POPUP) ||
-		!(item->fState & MF_MOUSESELECT)) return;
-	    item->fState &= ~MF_MOUSESELECT;
-	    hsubmenu = item->hSubMenu;
-	} else return;
-
-	submenu = MENU_GetMenu( hsubmenu );
-	MENU_HideSubPopups( hwndOwner, hsubmenu, FALSE );
-	MENU_SelectItem( hwndOwner, hsubmenu, NO_SELECTED_ITEM, sendMenuSelect, 0 );
+    HMENU hsubmenu;
+    POPUPMENU *submenu;
+    MENUITEM *item;
+
+    if (menu->FocusedItem != NO_SELECTED_ITEM)
+    {
+        item = &menu->items[menu->FocusedItem];
+        if (!(item->fType & MF_POPUP) ||
+        !(item->fState & MF_MOUSESELECT)) return;
+        item->fState &= ~MF_MOUSESELECT;
+        hsubmenu = item->hSubMenu;
+    } else return;
+
+    submenu = MENU_GetMenu( hsubmenu );
+    MENU_HideSubPopups( hwndOwner, hsubmenu, FALSE );
+    MENU_SelectItem( hwndOwner, hsubmenu, NO_SELECTED_ITEM, sendMenuSelect, 0 );
         DestroyWindow( submenu->hWnd );
         submenu->hWnd = 0;
@@ -2139,5 +2140,5 @@
     if (!(wFlags & TPM_NONOTIFY))
        SendMessageA( hwndOwner, WM_INITMENUPOPUP, item->hSubMenu,
-		   MAKELONG( menu->FocusedItem, IS_SYSTEM_MENU(menu) ));
+           MAKELONG( menu->FocusedItem, IS_SYSTEM_MENU(menu) ));
 
     item = &menu->items[menu->FocusedItem];
@@ -2154,5 +2155,5 @@
         item->fState |= MF_HILITE;
         MENU_DrawMenuItem( menu->hWnd, hmenu, hwndOwner, hdc, item, menu->Height, !(menu->wFlags & MF_POPUP), ODA_DRAWENTIRE );
-	ReleaseDC( menu->hWnd, hdc );
+    ReleaseDC( menu->hWnd, hdc );
     }
     if (!item->rect.top && !item->rect.left && !item->rect.bottom && !item->rect.right)
@@ -2163,11 +2164,11 @@
     if (IS_SYSTEM_MENU(menu))
     {
-	MENU_InitSysMenuPopup(item->hSubMenu,
+    MENU_InitSysMenuPopup(item->hSubMenu,
                               GetWindowLongA( menu->hWnd, GWL_STYLE ),
                               GetClassLongA( menu->hWnd, GCL_STYLE));
 
-	NC_GetSysPopupPos( menu->hWnd, &rect );
-	rect.top = rect.bottom;
-	rect.right = GetSystemMetrics(SM_CXSIZE);
+    NC_GetSysPopupPos( menu->hWnd, &rect );
+    rect.top = rect.bottom;
+    rect.right = GetSystemMetrics(SM_CXSIZE);
         rect.bottom = GetSystemMetrics(SM_CYSIZE);
     }
@@ -2175,22 +2176,22 @@
     {
         GetWindowRect( menu->hWnd, &rect );
-	if (menu->wFlags & MF_POPUP)
-	{
-	    rect.left += item->rect.right - GetSystemMetrics(SM_CXBORDER);
-	    rect.top += item->rect.top;
-	    rect.right = item->rect.left - item->rect.right + GetSystemMetrics(SM_CXBORDER);
-	    rect.bottom = item->rect.top - item->rect.bottom;
-	}
-	else
-	{
-	    rect.left += item->rect.left;
-	    rect.top += item->rect.bottom;
-	    rect.right = item->rect.right - item->rect.left;
-	    rect.bottom = item->rect.bottom - item->rect.top;
-	}
+    if (menu->wFlags & MF_POPUP)
+    {
+        rect.left += item->rect.right - GetSystemMetrics(SM_CXBORDER);
+        rect.top += item->rect.top;
+        rect.right = item->rect.left - item->rect.right + GetSystemMetrics(SM_CXBORDER);
+        rect.bottom = item->rect.top - item->rect.bottom;
+    }
+    else
+    {
+        rect.left += item->rect.left;
+        rect.top += item->rect.bottom;
+        rect.right = item->rect.right - item->rect.left;
+        rect.bottom = item->rect.bottom - item->rect.top;
+    }
     }
 
     MENU_ShowPopup( hwndOwner, item->hSubMenu, menu->FocusedItem,
-		    rect.left, rect.top, rect.right, rect.bottom );
+            rect.left, rect.top, rect.right, rect.bottom );
     if (selectFirst)
         MENU_MoveSelection( hwndOwner, item->hSubMenu, ITEM_NEXT );
@@ -2258,5 +2259,5 @@
 
     if (!menu || !menu->nItems ||
-	(menu->FocusedItem == NO_SELECTED_ITEM)) return -1;
+    (menu->FocusedItem == NO_SELECTED_ITEM)) return -1;
 
     item = &menu->items[menu->FocusedItem];
@@ -2267,21 +2268,21 @@
     if (!(item->fType & MF_POPUP))
     {
-	if (!(item->fState & (MF_GRAYED | MF_DISABLED)) && !(item->fType & MF_SEPARATOR))
-	{
-	    /* If TPM_RETURNCMD is set you return the id, but
-	       do not send a message to the owner */
-	    if(!(wFlags & TPM_RETURNCMD))
-	    {
-		if( menu->wFlags & MF_SYSMENU )
-		    PostMessageA( pmt->hOwnerWnd, WM_SYSCOMMAND, item->wID,
-				  MAKELPARAM((INT16)pmt->pt.x, (INT16)pmt->pt.y) );
-		else
-		    PostMessageA( pmt->hOwnerWnd, WM_COMMAND, item->wID, 0 );
-	    }
-	    return item->wID;
-	}
+    if (!(item->fState & (MF_GRAYED | MF_DISABLED)) && !(item->fType & MF_SEPARATOR))
+    {
+        /* If TPM_RETURNCMD is set you return the id, but
+           do not send a message to the owner */
+        if(!(wFlags & TPM_RETURNCMD))
+        {
+        if( menu->wFlags & MF_SYSMENU )
+            PostMessageA( pmt->hOwnerWnd, WM_SYSCOMMAND, item->wID,
+                  MAKELPARAM((INT16)pmt->pt.x, (INT16)pmt->pt.y) );
+        else
+            PostMessageA( pmt->hOwnerWnd, WM_COMMAND, item->wID, 0 );
+        }
+        return item->wID;
+    }
     }
     else
-	pmt->hCurrentMenu = MENU_ShowSubPopup(pmt->hOwnerWnd, hMenu, TRUE, wFlags);
+    pmt->hCurrentMenu = MENU_ShowSubPopup(pmt->hOwnerWnd, hMenu, TRUE, wFlags);
 
     return -1;
@@ -2301,9 +2302,9 @@
 
     if( pmt->hTopMenu != hPtMenu &&
-	!((ptmenu->wFlags | topmenu->wFlags) & MF_POPUP) )
-    {
-	/* both are top level menus (system and menu-bar) */
-	MENU_HideSubPopups( pmt->hOwnerWnd, pmt->hTopMenu, FALSE );
-	MENU_SelectItem( pmt->hOwnerWnd, pmt->hTopMenu, NO_SELECTED_ITEM, FALSE, 0 );
+    !((ptmenu->wFlags | topmenu->wFlags) & MF_POPUP) )
+    {
+    /* both are top level menus (system and menu-bar) */
+    MENU_HideSubPopups( pmt->hOwnerWnd, pmt->hTopMenu, FALSE );
+    MENU_SelectItem( pmt->hOwnerWnd, pmt->hTopMenu, NO_SELECTED_ITEM, FALSE, 0 );
         pmt->hTopMenu = hPtMenu;
     }
@@ -2324,35 +2325,35 @@
     if (hPtMenu)
     {
-	UINT id = 0;
-	POPUPMENU *ptmenu = MENU_GetMenu( hPtMenu );
-	MENUITEM *item;
-
-	if( IS_SYSTEM_MENU(ptmenu) )
-	    item = ptmenu->items;
-	else
-	    item = MENU_FindItemByCoords( ptmenu, pmt->pt, &id );
-
-	if( item )
-	{
-	    if( ptmenu->FocusedItem != id )
-		MENU_SwitchTracking( pmt, hPtMenu, id );
-
-	    /* If the popup menu is not already "popped" */
-	    if(!(item->fState & MF_MOUSESELECT ))
-	    {
-		pmt->hCurrentMenu = MENU_ShowSubPopup( pmt->hOwnerWnd, hPtMenu, FALSE, wFlags );
-
-		/* In win31, a newly popped menu always remains opened for the next buttonup */
+    UINT id = 0;
+    POPUPMENU *ptmenu = MENU_GetMenu( hPtMenu );
+    MENUITEM *item;
+
+    if( IS_SYSTEM_MENU(ptmenu) )
+        item = ptmenu->items;
+    else
+        item = MENU_FindItemByCoords( ptmenu, pmt->pt, &id );
+
+    if( item )
+    {
+        if( ptmenu->FocusedItem != id )
+        MENU_SwitchTracking( pmt, hPtMenu, id );
+
+        /* If the popup menu is not already "popped" */
+        if(!(item->fState & MF_MOUSESELECT ))
+        {
+        pmt->hCurrentMenu = MENU_ShowSubPopup( pmt->hOwnerWnd, hPtMenu, FALSE, wFlags );
+
+        /* In win31, a newly popped menu always remains opened for the next buttonup */
 #ifdef __WIN32OS2__
-		if(fOS2Look)
-		    ptmenu->bTimeToHide = FALSE;		    
+        if(fOS2Look)
+            ptmenu->bTimeToHide = FALSE;
 #endif
-		if(TWEAK_WineLook == WIN31_LOOK)
-		    ptmenu->bTimeToHide = FALSE;
-	    }
-
-	    return TRUE;
-	}
-	/* Else the click was on the menu bar, finish the tracking */
+        if(TWEAK_WineLook == WIN31_LOOK)
+            ptmenu->bTimeToHide = FALSE;
+        }
+
+        return TRUE;
+    }
+    /* Else the click was on the menu bar, finish the tracking */
     }
     return FALSE;
@@ -2373,7 +2374,7 @@
     if (hPtMenu)
     {
-	UINT id = 0;
-	POPUPMENU *ptmenu = MENU_GetMenu( hPtMenu );
-	MENUITEM *item;
+    UINT id = 0;
+    POPUPMENU *ptmenu = MENU_GetMenu( hPtMenu );
+    MENUITEM *item;
 
         if( IS_SYSTEM_MENU(ptmenu) )
@@ -2382,16 +2383,16 @@
             item = MENU_FindItemByCoords( ptmenu, pmt->pt, &id );
 
-	if( item && (ptmenu->FocusedItem == id ))
-	{
-	    if( !(item->fType & MF_POPUP) )
-		return MENU_ExecFocusedItem( pmt, hPtMenu, wFlags);
-
-	    /* If we are dealing with the top-level menu            */
-	    /* and this is a click on an already "popped" item:     */
-	    /* Stop the menu tracking and close the opened submenus */
-	    if((pmt->hTopMenu == hPtMenu) && (ptmenu->bTimeToHide == TRUE))
-		return 0;
-	}
-	ptmenu->bTimeToHide = TRUE;
+    if( item && (ptmenu->FocusedItem == id ))
+    {
+        if( !(item->fType & MF_POPUP) )
+        return MENU_ExecFocusedItem( pmt, hPtMenu, wFlags);
+
+        /* If we are dealing with the top-level menu            */
+        /* and this is a click on an already "popped" item:     */
+        /* Stop the menu tracking and close the opened submenus */
+        if((pmt->hTopMenu == hPtMenu) && (ptmenu->bTimeToHide == TRUE))
+        return 0;
+    }
+    ptmenu->bTimeToHide = TRUE;
     }
     return -1;
@@ -2411,7 +2412,7 @@
     if( hPtMenu )
     {
-	ptmenu = MENU_GetMenu( hPtMenu );
+    ptmenu = MENU_GetMenu( hPtMenu );
         if( IS_SYSTEM_MENU(ptmenu) )
-	    id = 0;
+        id = 0;
         else
             MENU_FindItemByCoords( ptmenu, pmt->pt, &id );
@@ -2420,12 +2421,12 @@
     if( id == NO_SELECTED_ITEM )
     {
-	MENU_SelectItem( pmt->hOwnerWnd, pmt->hCurrentMenu,
-			 NO_SELECTED_ITEM, TRUE, pmt->hTopMenu);
+    MENU_SelectItem( pmt->hOwnerWnd, pmt->hCurrentMenu,
+             NO_SELECTED_ITEM, TRUE, pmt->hTopMenu);
 
     }
     else if( ptmenu->FocusedItem != id )
     {
-	    MENU_SwitchTracking( pmt, hPtMenu, id );
-	    pmt->hCurrentMenu = MENU_ShowSubPopup(pmt->hOwnerWnd, hPtMenu, FALSE, wFlags);
+        MENU_SwitchTracking( pmt, hPtMenu, id );
+        pmt->hCurrentMenu = MENU_ShowSubPopup(pmt->hOwnerWnd, hPtMenu, FALSE, wFlags);
     }
     return TRUE;
@@ -2446,7 +2447,7 @@
     {
         MDINEXTMENU next_menu;
-	HMENU hNewMenu;
-	HWND  hNewWnd;
-	UINT  id = 0;
+    HMENU hNewMenu;
+    HWND  hNewWnd;
+    UINT  id = 0;
 
         next_menu.hmenuIn = (IS_SYSTEM_MENU(menu)) ? GetSubMenu(pmt->hTopMenu,0) : pmt->hTopMenu;
@@ -2455,80 +2456,80 @@
         SendMessageW( pmt->hOwnerWnd, WM_NEXTMENU, vk, (LPARAM)&next_menu );
 
-	TRACE("%04x [%04x] -> %04x [%04x]\n",
+    TRACE("%04x [%04x] -> %04x [%04x]\n",
               pmt->hCurrentMenu, pmt->hOwnerWnd, next_menu.hmenuNext, next_menu.hwndNext );
 
-	if (!next_menu.hmenuNext || !next_menu.hwndNext)
-	{
+    if (!next_menu.hmenuNext || !next_menu.hwndNext)
+    {
             DWORD style = GetWindowLongA( pmt->hOwnerWnd, GWL_STYLE );
-	    hNewWnd = pmt->hOwnerWnd;
-	    if( IS_SYSTEM_MENU(menu) )
-	    {
-		/* switch to the menu bar */
+        hNewWnd = pmt->hOwnerWnd;
+        if( IS_SYSTEM_MENU(menu) )
+        {
+        /* switch to the menu bar */
 
                 if(style & WS_CHILD || !(hNewMenu = GetMenu(hNewWnd))) return FALSE;
 
-	        if( vk == VK_LEFT )
-	        {
-		    menu = MENU_GetMenu( hNewMenu );
-		    id = menu->nItems - 1;
-	        }
-	    }
-	    else if (style & WS_SYSMENU )
-	    {
-		/* switch to the system menu */
-	        hNewMenu = get_win_sys_menu( hNewWnd );
-	    }
+            if( vk == VK_LEFT )
+            {
+            menu = MENU_GetMenu( hNewMenu );
+            id = menu->nItems - 1;
+            }
+        }
+        else if (style & WS_SYSMENU )
+        {
+        /* switch to the system menu */
+            hNewMenu = get_win_sys_menu( hNewWnd );
+        }
             else return FALSE;
-	}
-	else    /* application returned a new menu to switch to */
-	{
+    }
+    else    /* application returned a new menu to switch to */
+    {
             hNewMenu = next_menu.hmenuNext;
             hNewWnd = WIN_GetFullHandle( next_menu.hwndNext );
 
-	    if( IsMenu(hNewMenu) && IsWindow(hNewWnd) )
-	    {
+        if( IsMenu(hNewMenu) && IsWindow(hNewWnd) )
+        {
                 DWORD style = GetWindowLongA( hNewWnd, GWL_STYLE );
 
-		if (style & WS_SYSMENU &&
-		    GetSubMenu(get_win_sys_menu(hNewWnd), 0) == hNewMenu )
-		{
-	            /* get the real system menu */
-		    hNewMenu =  get_win_sys_menu(hNewWnd);
-		}
-	        else if (style & WS_CHILD || GetMenu(hNewWnd) != hNewMenu )
-		{
-		    /* FIXME: Not sure what to do here;
-		     * perhaps try to track hNewMenu as a popup? */
-
-		    TRACE(" -- got confused.\n");
-		    return FALSE;
-		}
-	    }
-	    else return FALSE;
-	}
-
-	if( hNewMenu != pmt->hTopMenu )
-	{
-	    MENU_SelectItem( pmt->hOwnerWnd, pmt->hTopMenu, NO_SELECTED_ITEM,
+        if (style & WS_SYSMENU &&
+            GetSubMenu(get_win_sys_menu(hNewWnd), 0) == hNewMenu )
+        {
+                /* get the real system menu */
+            hNewMenu =  get_win_sys_menu(hNewWnd);
+        }
+            else if (style & WS_CHILD || GetMenu(hNewWnd) != hNewMenu )
+        {
+            /* FIXME: Not sure what to do here;
+             * perhaps try to track hNewMenu as a popup? */
+
+            TRACE(" -- got confused.\n");
+            return FALSE;
+        }
+        }
+        else return FALSE;
+    }
+
+    if( hNewMenu != pmt->hTopMenu )
+    {
+        MENU_SelectItem( pmt->hOwnerWnd, pmt->hTopMenu, NO_SELECTED_ITEM,
                     FALSE, 0 );
-	    if( pmt->hCurrentMenu != pmt->hTopMenu )
-		MENU_HideSubPopups( pmt->hOwnerWnd, pmt->hTopMenu, FALSE );
-	}
-
-	if( hNewWnd != pmt->hOwnerWnd )
-	{
-	    ReleaseCapture();
-	    pmt->hOwnerWnd = hNewWnd;
+        if( pmt->hCurrentMenu != pmt->hTopMenu )
+        MENU_HideSubPopups( pmt->hOwnerWnd, pmt->hTopMenu, FALSE );
+    }
+
+    if( hNewWnd != pmt->hOwnerWnd )
+    {
+        ReleaseCapture();
+        pmt->hOwnerWnd = hNewWnd;
 #ifdef __WIN32OS2__
             SetCapture(pmt->hOwnerWnd); //SvL: Don't know if this is good enough
 #else
-	    EVENT_Capture( pmt->hOwnerWnd, HTMENU );
+        EVENT_Capture( pmt->hOwnerWnd, HTMENU );
 #endif
-	}
-
-	pmt->hTopMenu = pmt->hCurrentMenu = hNewMenu; /* all subpopups are hidden */
-	MENU_SelectItem( pmt->hOwnerWnd, pmt->hTopMenu, id, TRUE, 0 );
-
-	return TRUE;
+    }
+
+    pmt->hTopMenu = pmt->hCurrentMenu = hNewMenu; /* all subpopups are hidden */
+    MENU_SelectItem( pmt->hOwnerWnd, pmt->hTopMenu, id, TRUE, 0 );
+
+    return TRUE;
     }
     return FALSE;
@@ -2552,18 +2553,18 @@
     switch( uMsg )
     {
-	case WM_KEYDOWN:
-	     PeekMessageA( &msg, 0, 0, 0, PM_NOYIELD | PM_NOREMOVE);
-	     if( msg.message == WM_KEYUP || msg.message == WM_PAINT )
-	     {
-		 PeekMessageA( &msg, 0, 0, 0, PM_NOYIELD | PM_REMOVE);
-	         PeekMessageA( &msg, 0, 0, 0, PM_NOYIELD | PM_NOREMOVE);
-	         if( msg.message == WM_KEYDOWN &&
-		    (msg.wParam == VK_LEFT || msg.wParam == VK_RIGHT))
-	         {
-		     pmt->trackFlags |= TF_SUSPENDPOPUP;
-		     return TRUE;
-	         }
-	     }
-	     break;
+    case WM_KEYDOWN:
+         PeekMessageA( &msg, 0, 0, 0, PM_NOYIELD | PM_NOREMOVE);
+         if( msg.message == WM_KEYUP || msg.message == WM_PAINT )
+         {
+         PeekMessageA( &msg, 0, 0, 0, PM_NOYIELD | PM_REMOVE);
+             PeekMessageA( &msg, 0, 0, 0, PM_NOYIELD | PM_NOREMOVE);
+             if( msg.message == WM_KEYDOWN &&
+            (msg.wParam == VK_LEFT || msg.wParam == VK_RIGHT))
+             {
+             pmt->trackFlags |= TF_SUSPENDPOPUP;
+             return TRUE;
+             }
+         }
+         break;
     }
 
@@ -2624,9 +2625,9 @@
     /* Try to move 1 column left (if possible) */
     if( (prevcol = MENU_GetStartOfPrevColumn( pmt->hCurrentMenu )) !=
-	NO_SELECTED_ITEM ) {
-
-	MENU_SelectItem( pmt->hOwnerWnd, pmt->hCurrentMenu,
-			 prevcol, TRUE, 0 );
-	return;
+    NO_SELECTED_ITEM ) {
+
+    MENU_SelectItem( pmt->hOwnerWnd, pmt->hCurrentMenu,
+             prevcol, TRUE, 0 );
+    return;
     }
 
@@ -2634,6 +2635,6 @@
     while (hmenutmp != pmt->hCurrentMenu)
     {
-	hmenuprev = hmenutmp;
-	hmenutmp = MENU_GetSubPopup( hmenuprev );
+    hmenuprev = hmenutmp;
+    hmenutmp = MENU_GetSubPopup( hmenuprev );
     }
 
@@ -2643,18 +2644,18 @@
     if ( (hmenuprev == pmt->hTopMenu) && !(menu->wFlags & MF_POPUP) )
     {
-	/* move menu bar selection if no more popups are left */
-
-	if( !MENU_DoNextMenu( pmt, VK_LEFT) )
-	     MENU_MoveSelection( pmt->hOwnerWnd, pmt->hTopMenu, ITEM_PREV );
-
-	if ( hmenuprev != hmenutmp || pmt->trackFlags & TF_SUSPENDPOPUP )
-	{
-	   /* A sublevel menu was displayed - display the next one
-	    * unless there is another displacement coming up */
-
-	    if( !MENU_SuspendPopup( pmt, WM_KEYDOWN ) )
-		pmt->hCurrentMenu = MENU_ShowSubPopup(pmt->hOwnerWnd,
-						pmt->hTopMenu, TRUE, wFlags);
-	}
+    /* move menu bar selection if no more popups are left */
+
+    if( !MENU_DoNextMenu( pmt, VK_LEFT) )
+         MENU_MoveSelection( pmt->hOwnerWnd, pmt->hTopMenu, ITEM_PREV );
+
+    if ( hmenuprev != hmenutmp || pmt->trackFlags & TF_SUSPENDPOPUP )
+    {
+       /* A sublevel menu was displayed - display the next one
+        * unless there is another displacement coming up */
+
+        if( !MENU_SuspendPopup( pmt, WM_KEYDOWN ) )
+        pmt->hCurrentMenu = MENU_ShowSubPopup(pmt->hOwnerWnd,
+                        pmt->hTopMenu, TRUE, wFlags);
+    }
     }
 }
@@ -2673,45 +2674,45 @@
 
     TRACE("MENU_KeyRight called, cur %x (%s), top %x (%s).\n",
-		  pmt->hCurrentMenu,
-		  debugstr_w((MENU_GetMenu(pmt->hCurrentMenu))->
-		     items[0].text),
-		  pmt->hTopMenu, debugstr_w(menu->items[0].text) );
+          pmt->hCurrentMenu,
+          debugstr_w((MENU_GetMenu(pmt->hCurrentMenu))->
+             items[0].text),
+          pmt->hTopMenu, debugstr_w(menu->items[0].text) );
 
     if ( (menu->wFlags & MF_POPUP) || (pmt->hCurrentMenu != pmt->hTopMenu))
     {
-	/* If already displaying a popup, try to display sub-popup */
-
-	hmenutmp = pmt->hCurrentMenu;
-	pmt->hCurrentMenu = MENU_ShowSubPopup(pmt->hOwnerWnd, hmenutmp, TRUE, wFlags);
-
-	/* if subpopup was displayed then we are done */
-	if (hmenutmp != pmt->hCurrentMenu) return;
+    /* If already displaying a popup, try to display sub-popup */
+
+    hmenutmp = pmt->hCurrentMenu;
+    pmt->hCurrentMenu = MENU_ShowSubPopup(pmt->hOwnerWnd, hmenutmp, TRUE, wFlags);
+
+    /* if subpopup was displayed then we are done */
+    if (hmenutmp != pmt->hCurrentMenu) return;
     }
 
     /* Check to see if there's another column */
     if( (nextcol = MENU_GetStartOfNextColumn( pmt->hCurrentMenu )) !=
-	NO_SELECTED_ITEM ) {
-	TRACE("Going to %d.\n", nextcol );
-	MENU_SelectItem( pmt->hOwnerWnd, pmt->hCurrentMenu,
-			 nextcol, TRUE, 0 );
-	return;
-    }
-
-    if (!(menu->wFlags & MF_POPUP))	/* menu bar tracking */
-    {
-	if( pmt->hCurrentMenu != pmt->hTopMenu )
-	{
-	    MENU_HideSubPopups( pmt->hOwnerWnd, pmt->hTopMenu, FALSE );
-	    hmenutmp = pmt->hCurrentMenu = pmt->hTopMenu;
-	} else hmenutmp = 0;
-
-	/* try to move to the next item */
-	if( !MENU_DoNextMenu( pmt, VK_RIGHT) )
-	     MENU_MoveSelection( pmt->hOwnerWnd, pmt->hTopMenu, ITEM_NEXT );
-
-	if( hmenutmp || pmt->trackFlags & TF_SUSPENDPOPUP )
-	    if( !MENU_SuspendPopup(pmt, WM_KEYDOWN) )
-		pmt->hCurrentMenu = MENU_ShowSubPopup(pmt->hOwnerWnd,
-						       pmt->hTopMenu, TRUE, wFlags);
+    NO_SELECTED_ITEM ) {
+    TRACE("Going to %d.\n", nextcol );
+    MENU_SelectItem( pmt->hOwnerWnd, pmt->hCurrentMenu,
+             nextcol, TRUE, 0 );
+    return;
+    }
+
+    if (!(menu->wFlags & MF_POPUP)) /* menu bar tracking */
+    {
+    if( pmt->hCurrentMenu != pmt->hTopMenu )
+    {
+        MENU_HideSubPopups( pmt->hOwnerWnd, pmt->hTopMenu, FALSE );
+        hmenutmp = pmt->hCurrentMenu = pmt->hTopMenu;
+    } else hmenutmp = 0;
+
+    /* try to move to the next item */
+    if( !MENU_DoNextMenu( pmt, VK_RIGHT) )
+         MENU_MoveSelection( pmt->hOwnerWnd, pmt->hTopMenu, ITEM_NEXT );
+
+    if( hmenutmp || pmt->trackFlags & TF_SUSPENDPOPUP )
+        if( !MENU_SuspendPopup(pmt, WM_KEYDOWN) )
+        pmt->hCurrentMenu = MENU_ShowSubPopup(pmt->hOwnerWnd,
+                               pmt->hTopMenu, TRUE, wFlags);
     }
 }
@@ -2743,6 +2744,6 @@
 
     TRACE("hmenu=0x%04x flags=0x%08x (%d,%d) hwnd=0x%04x (%d,%d)-(%d,%d)\n",
-	    hmenu, wFlags, x, y, hwnd, (lprect) ? lprect->left : 0, (lprect) ? lprect->top : 0,
-	    (lprect) ? lprect->right : 0,  (lprect) ? lprect->bottom : 0);
+        hmenu, wFlags, x, y, hwnd, (lprect) ? lprect->left : 0, (lprect) ? lprect->top : 0,
+        (lprect) ? lprect->right : 0,  (lprect) ? lprect->bottom : 0);
 
     fEndMenu = FALSE;
@@ -2751,7 +2752,7 @@
     if (wFlags & TPM_BUTTONDOWN)
     {
-	/* Get the result in order to start the tracking or not */
-	fRemove = MENU_ButtonDown( &mt, hmenu, wFlags );
-	fEndMenu = !fRemove;
+    /* Get the result in order to start the tracking or not */
+    fRemove = MENU_ButtonDown( &mt, hmenu, wFlags );
+    fEndMenu = !fRemove;
     }
 
@@ -2769,10 +2770,10 @@
     while (!fEndMenu)
     {
-	menu = MENU_GetMenu( mt.hCurrentMenu );
-	if (!menu) /* sometimes happens if I do a window manager close */
-	    break;
-
-	/* we have to keep the message in the queue until it's
-	 * clear that menu loop is not over yet. */
+    menu = MENU_GetMenu( mt.hCurrentMenu );
+    if (!menu) /* sometimes happens if I do a window manager close */
+        break;
+
+    /* we have to keep the message in the queue until it's
+     * clear that menu loop is not over yet. */
 
         for (;;)
@@ -2803,27 +2804,27 @@
         }
 
-	/* check if EndMenu() tried to cancel us, by posting this message */
+    /* check if EndMenu() tried to cancel us, by posting this message */
         if(msg.message == WM_CANCELMODE)
-	{
-	    /* we are now out of the loop */
-    	    fEndMenu = TRUE;
+    {
+        /* we are now out of the loop */
+            fEndMenu = TRUE;
 
 #ifdef __WIN32OS2__
-	    /* remove the message from the queue */
-	    PeekMessageA( &msg, 0, msg.message, msg.message, PM_REMOVE );
+        /* remove the message from the queue */
+        PeekMessageA( &msg, 0, msg.message, msg.message, PM_REMOVE );
 #endif
-	    /* break out of internal loop, ala ESCAPE */
-	    break;
-	}
+        /* break out of internal loop, ala ESCAPE */
+        break;
+    }
 
         TranslateMessage( &msg );
         mt.pt = msg.pt;
 
-	if ( (msg.hwnd==menu->hWnd) || (msg.message!=WM_TIMER) )
-	  enterIdleSent=FALSE;
+    if ( (msg.hwnd==menu->hWnd) || (msg.message!=WM_TIMER) )
+      enterIdleSent=FALSE;
 
         fRemove = FALSE;
-	if ((msg.message >= WM_MOUSEFIRST) && (msg.message <= WM_MOUSELAST))
-	{
+    if ((msg.message >= WM_MOUSEFIRST) && (msg.message <= WM_MOUSELAST))
+    {
             /*
              * use the mouse coordinates in lParam instead of those in the MSG
@@ -2839,25 +2840,25 @@
             ClientToScreen(msg.hwnd,&mt.pt);
 
-	    /* Find a menu for this mouse event */
-	    hmenu = MENU_PtMenu( mt.hTopMenu, mt.pt );
-
-	    switch(msg.message)
-	    {
-		/* no WM_NC... messages in captured state */
-
-		case WM_RBUTTONDBLCLK:
-		case WM_RBUTTONDOWN:
+        /* Find a menu for this mouse event */
+        hmenu = MENU_PtMenu( mt.hTopMenu, mt.pt );
+
+        switch(msg.message)
+        {
+        /* no WM_NC... messages in captured state */
+
+        case WM_RBUTTONDBLCLK:
+        case WM_RBUTTONDOWN:
 #ifdef __WIN32OS2__
-		    if (!(wFlags & TPM_RIGHTBUTTON)) {
+            if (!(wFlags & TPM_RIGHTBUTTON)) {
                       MENUITEM *item;
-   		      UINT id = 0;
-			
+              UINT id = 0;
+
                        if( IS_SYSTEM_MENU(menu) )
                           item = menu->items;
                        else
                           item = MENU_FindItemByCoords( menu, mt.pt, &id );
-		       //@@PF If our pointer is over the menu - do nothing
-                       if (item) break; 
-		       //@@PF Time to close menu - win2k&98 checked
+               //@@PF If our pointer is over the menu - do nothing
+                       if (item) break;
+               //@@PF Time to close menu - win2k&98 checked
                        fEndMenu = 1;
                        break;
@@ -2865,8 +2866,8 @@
                     goto buttondown;
 #else
-		    if (!(wFlags & TPM_RIGHTBUTTON)) break;
+            if (!(wFlags & TPM_RIGHTBUTTON)) break;
 #endif
-		    /* fall through */
-		case WM_LBUTTONDBLCLK:
+            /* fall through */
+        case WM_LBUTTONDBLCLK:
 #ifdef __WIN32OS2__
                     if (bSysMenu && (hmenu == mt.hTopMenu))
@@ -2889,24 +2890,24 @@
 
 #endif
-		case WM_LBUTTONDOWN:
-		    /* If the message belongs to the menu, removes it from the queue */
-		    /* Else, end menu tracking */
-		    fRemove = MENU_ButtonDown( &mt, hmenu, wFlags );
-		    fEndMenu = !fRemove;
-		    break;
-
-		case WM_RBUTTONUP:
-		    if (!(wFlags & TPM_RIGHTBUTTON)) break;
-		    /* fall through */
-		case WM_LBUTTONUP:
-		    /* Check if a menu was selected by the mouse */
-		    if (hmenu)
-		    {
+        case WM_LBUTTONDOWN:
+            /* If the message belongs to the menu, removes it from the queue */
+            /* Else, end menu tracking */
+            fRemove = MENU_ButtonDown( &mt, hmenu, wFlags );
+            fEndMenu = !fRemove;
+            break;
+
+        case WM_RBUTTONUP:
+            if (!(wFlags & TPM_RIGHTBUTTON)) break;
+            /* fall through */
+        case WM_LBUTTONUP:
+            /* Check if a menu was selected by the mouse */
+            if (hmenu)
+            {
                         executedMenuId = MENU_ButtonUp( &mt, hmenu, wFlags);
 
-			/* End the loop if executedMenuId is an item ID */
-			/* or if the job was done (executedMenuId = 0). */
+            /* End the loop if executedMenuId is an item ID */
+            /* or if the job was done (executedMenuId = 0). */
                         fEndMenu = fRemove = (executedMenuId != -1);
-		    }
+            }
                     /* No menu was selected by the mouse */
                     /* if the function was called by TrackPopupMenu, continue
@@ -2915,7 +2916,7 @@
                         fEndMenu = ((wFlags & TPM_POPUPMENU) ? FALSE : TRUE);
 
-		    break;
-
-		case WM_MOUSEMOVE:
+            break;
+
+        case WM_MOUSEMOVE:
                     /* In win95 winelook, the selected menu item must be changed every time the
                        mouse moves. In Win31 winelook, the mouse button has to be held down */
@@ -2924,7 +2925,7 @@
                     //PF Win32 eats first mousemove to prevent auto-select of item
                     //on TrackMenuPopup pressed button - verified in Win2k
-                    if (bFirstMouseMove) 
-                    { 
-                        bFirstMouseMove = FALSE; 
+                    if (bFirstMouseMove)
+                    {
+                        bFirstMouseMove = FALSE;
                         break;
                     }
@@ -2937,125 +2938,125 @@
                            ((wFlags & TPM_RIGHTBUTTON) && (msg.wParam & MK_RBUTTON))) )
 
-			fEndMenu |= !MENU_MouseMove( &mt, hmenu, wFlags );
-
-	    } /* switch(msg.message) - mouse */
-	}
-	else if ((msg.message >= WM_KEYFIRST) && (msg.message <= WM_KEYLAST))
-	{
+            fEndMenu |= !MENU_MouseMove( &mt, hmenu, wFlags );
+
+        } /* switch(msg.message) - mouse */
+    }
+    else if ((msg.message >= WM_KEYFIRST) && (msg.message <= WM_KEYLAST))
+    {
             fRemove = TRUE;  /* Keyboard messages are always removed */
-	    switch(msg.message)
-	    {
-	    case WM_KEYDOWN:
-		switch(msg.wParam)
-		{
-		case VK_HOME:
-		case VK_END:
-		    MENU_SelectItem( mt.hOwnerWnd, mt.hCurrentMenu,
-				     NO_SELECTED_ITEM, FALSE, 0 );
-		/* fall through */
-		case VK_UP:
-		    MENU_MoveSelection( mt.hOwnerWnd, mt.hCurrentMenu,
-				       (msg.wParam == VK_HOME)? ITEM_NEXT : ITEM_PREV );
-		    break;
-
-		case VK_DOWN: /* If on menu bar, pull-down the menu */
-
-		    menu = MENU_GetMenu( mt.hCurrentMenu );
-		    if (!(menu->wFlags & MF_POPUP))
-			mt.hCurrentMenu = MENU_ShowSubPopup(mt.hOwnerWnd, mt.hTopMenu, TRUE, wFlags);
-		    else      /* otherwise try to move selection */
-			MENU_MoveSelection( mt.hOwnerWnd, mt.hCurrentMenu, ITEM_NEXT );
-		    break;
-
-		case VK_LEFT:
-		    MENU_KeyLeft( &mt, wFlags );
-		    break;
-
-		case VK_RIGHT:
-		    MENU_KeyRight( &mt, wFlags );
-		    break;
-
-		case VK_ESCAPE:
+        switch(msg.message)
+        {
+        case WM_KEYDOWN:
+        switch(msg.wParam)
+        {
+        case VK_HOME:
+        case VK_END:
+            MENU_SelectItem( mt.hOwnerWnd, mt.hCurrentMenu,
+                     NO_SELECTED_ITEM, FALSE, 0 );
+        /* fall through */
+        case VK_UP:
+            MENU_MoveSelection( mt.hOwnerWnd, mt.hCurrentMenu,
+                       (msg.wParam == VK_HOME)? ITEM_NEXT : ITEM_PREV );
+            break;
+
+        case VK_DOWN: /* If on menu bar, pull-down the menu */
+
+            menu = MENU_GetMenu( mt.hCurrentMenu );
+            if (!(menu->wFlags & MF_POPUP))
+            mt.hCurrentMenu = MENU_ShowSubPopup(mt.hOwnerWnd, mt.hTopMenu, TRUE, wFlags);
+            else      /* otherwise try to move selection */
+            MENU_MoveSelection( mt.hOwnerWnd, mt.hCurrentMenu, ITEM_NEXT );
+            break;
+
+        case VK_LEFT:
+            MENU_KeyLeft( &mt, wFlags );
+            break;
+
+        case VK_RIGHT:
+            MENU_KeyRight( &mt, wFlags );
+            break;
+
+        case VK_ESCAPE:
                     fEndMenu = MENU_KeyEscape(&mt, wFlags);
-		    break;
-
-		case VK_F1:
-		    {
-			HELPINFO hi;
-			hi.cbSize = sizeof(HELPINFO);
-			hi.iContextType = HELPINFO_MENUITEM;
-			if (menu->FocusedItem == NO_SELECTED_ITEM)
-			    hi.iCtrlId = 0;
-		        else
-			    hi.iCtrlId = menu->items[menu->FocusedItem].wID;
-			hi.hItemHandle = hmenu;
-			hi.dwContextId = menu->dwContextHelpID;
-			hi.MousePos = msg.pt;
-			SendMessageA(hwnd, WM_HELP, 0, (LPARAM)&hi);
-			break;
-		    }
-
-		default:
-		    break;
-		}
-		break;  /* WM_KEYDOWN */
-
-	    case WM_SYSKEYDOWN:
-		switch(msg.wParam)
-		{
-		case VK_MENU:
-		    fEndMenu = TRUE;
-		    break;
-
-		}
-		break;  /* WM_SYSKEYDOWN */
-
-	    case WM_CHAR:
-		{
-		    UINT	pos;
-
-		    if (msg.wParam == '\r' || msg.wParam == ' ')
-		    {
+            break;
+
+        case VK_F1:
+            {
+            HELPINFO hi;
+            hi.cbSize = sizeof(HELPINFO);
+            hi.iContextType = HELPINFO_MENUITEM;
+            if (menu->FocusedItem == NO_SELECTED_ITEM)
+                hi.iCtrlId = 0;
+                else
+                hi.iCtrlId = menu->items[menu->FocusedItem].wID;
+            hi.hItemHandle = hmenu;
+            hi.dwContextId = menu->dwContextHelpID;
+            hi.MousePos = msg.pt;
+            SendMessageA(hwnd, WM_HELP, 0, (LPARAM)&hi);
+            break;
+            }
+
+        default:
+            break;
+        }
+        break;  /* WM_KEYDOWN */
+
+        case WM_SYSKEYDOWN:
+        switch(msg.wParam)
+        {
+        case VK_MENU:
+            fEndMenu = TRUE;
+            break;
+
+        }
+        break;  /* WM_SYSKEYDOWN */
+
+        case WM_CHAR:
+        {
+            UINT    pos;
+
+            if (msg.wParam == '\r' || msg.wParam == ' ')
+            {
                         executedMenuId = MENU_ExecFocusedItem(&mt,mt.hCurrentMenu, wFlags);
                         fEndMenu = (executedMenuId != -1);
 
-			break;
-		    }
-
-		      /* Hack to avoid control chars. */
-		      /* We will find a better way real soon... */
-		    if ((msg.wParam <= 32) || (msg.wParam >= 127)) break;
-
-		    pos = MENU_FindItemByKey( mt.hOwnerWnd, mt.hCurrentMenu,
+            break;
+            }
+
+              /* Hack to avoid control chars. */
+              /* We will find a better way real soon... */
+            if ((msg.wParam <= 32) || (msg.wParam >= 127)) break;
+
+            pos = MENU_FindItemByKey( mt.hOwnerWnd, mt.hCurrentMenu,
                                               LOWORD(msg.wParam), FALSE );
-		    if (pos == (UINT)-2) fEndMenu = TRUE;
-		    else if (pos == (UINT)-1) MessageBeep(0);
-		    else
-		    {
-			MENU_SelectItem( mt.hOwnerWnd, mt.hCurrentMenu, pos,
+            if (pos == (UINT)-2) fEndMenu = TRUE;
+            else if (pos == (UINT)-1) MessageBeep(0);
+            else
+            {
+            MENU_SelectItem( mt.hOwnerWnd, mt.hCurrentMenu, pos,
                                 TRUE, 0 );
                         executedMenuId = MENU_ExecFocusedItem(&mt,mt.hCurrentMenu, wFlags);
                         fEndMenu = (executedMenuId != -1);
-		    }
-		}
-		break;
-	    }  /* switch(msg.message) - kbd */
-	}
-	else
-	{
-	    DispatchMessageA( &msg );
-	}
-
-	if (!fEndMenu) fRemove = TRUE;
-
-	/* finally remove message from the queue */
+            }
+        }
+        break;
+        }  /* switch(msg.message) - kbd */
+    }
+    else
+    {
+        DispatchMessageA( &msg );
+    }
+
+    if (!fEndMenu) fRemove = TRUE;
+
+    /* finally remove message from the queue */
 
         if (fRemove && !(mt.trackFlags & TF_SKIPREMOVE) )
-#ifdef __WIN32OS2__ 
+#ifdef __WIN32OS2__
             ;
 #else
-	    PeekMessageA( &msg, 0, msg.message, msg.message, PM_REMOVE );
+        PeekMessageA( &msg, 0, msg.message, msg.message, PM_REMOVE );
 #endif
-	else mt.trackFlags &= ~TF_SKIPREMOVE;
+    else mt.trackFlags &= ~TF_SKIPREMOVE;
     }
 
@@ -3071,17 +3072,17 @@
     if( IsMenu( mt.hTopMenu ) )
     {
-	menu = MENU_GetMenu( mt.hTopMenu );
+    menu = MENU_GetMenu( mt.hTopMenu );
 
         if( IsWindow( mt.hOwnerWnd ) )
         {
-	    MENU_HideSubPopups( mt.hOwnerWnd, mt.hTopMenu, FALSE );
-
-	    if (menu && menu->wFlags & MF_POPUP)
-	    {
+        MENU_HideSubPopups( mt.hOwnerWnd, mt.hTopMenu, FALSE );
+
+        if (menu && menu->wFlags & MF_POPUP)
+        {
                 DestroyWindow( menu->hWnd );
                 menu->hWnd = 0;
-	    }
-	    MENU_SelectItem( mt.hOwnerWnd, mt.hTopMenu, NO_SELECTED_ITEM, FALSE, 0 );
-	    SendMessageA( mt.hOwnerWnd, WM_MENUSELECT, MAKELONG(0,0xffff), 0 );
+        }
+        MENU_SelectItem( mt.hOwnerWnd, mt.hTopMenu, NO_SELECTED_ITEM, FALSE, 0 );
+        SendMessageA( mt.hOwnerWnd, WM_MENUSELECT, MAKELONG(0,0xffff), 0 );
         }
 
@@ -3153,7 +3154,7 @@
         if (parent != GetDesktopWindow()) ScreenToClient( parent, &pt );
 
-	MENU_InitTracking( hWnd, hMenu, FALSE, wFlags );
-	MENU_TrackMenu( hMenu, wFlags, pt.x, pt.y, hWnd, NULL );
-	MENU_ExitTracking(hWnd);
+    MENU_InitTracking( hWnd, hMenu, FALSE, wFlags );
+    MENU_TrackMenu( hMenu, wFlags, pt.x, pt.y, hWnd, NULL );
+    MENU_ExitTracking(hWnd);
     }
 }
@@ -3241,9 +3242,9 @@
 
     if (MENU_ShowPopup( hWnd, hMenu, 0, x, y, 0, 0 ))
-	ret = MENU_TrackMenu( hMenu, wFlags | TPM_POPUPMENU, 0, 0, hWnd, lpRect );
+    ret = MENU_TrackMenu( hMenu, wFlags | TPM_POPUPMENU, 0, 0, hWnd, lpRect );
     MENU_ExitTracking(hWnd);
 
     if( (!(wFlags & TPM_RETURNCMD)) && (ret != FALSE) )
-	ret = 1;
+    ret = 1;
 
     return ret;
@@ -3274,9 +3275,9 @@
     {
     case WM_CREATE:
-	{
-	    CREATESTRUCTW *cs = (CREATESTRUCTW*)lParam;
-	    SetWindowLongW( hwnd, 0, (LONG)cs->lpCreateParams );
+    {
+        CREATESTRUCTW *cs = (CREATESTRUCTW*)lParam;
+        SetWindowLongW( hwnd, 0, (LONG)cs->lpCreateParams );
             return 0;
-	}
+    }
 
     case WM_MOUSEACTIVATE:  /* We don't want to be activated */
@@ -3284,12 +3285,12 @@
 
     case WM_PAINT:
-	{
-	    PAINTSTRUCT ps;
-	    BeginPaint( hwnd, &ps );
-	    MENU_DrawPopupMenu( hwnd, ps.hdc,
+    {
+        PAINTSTRUCT ps;
+        BeginPaint( hwnd, &ps );
+        MENU_DrawPopupMenu( hwnd, ps.hdc,
                                 (HMENU)GetWindowLongA( hwnd, 0 ) );
-	    EndPaint( hwnd, &ps );
+        EndPaint( hwnd, &ps );
             return 0;
-	}
+    }
     case WM_ERASEBKGND:
         return 1;
@@ -3302,11 +3303,11 @@
     case WM_SHOWWINDOW:
 
-	if( wParam )
-	{
+    if( wParam )
+    {
             if (!GetWindowLongW( hwnd, 0 )) ERR("no menu to display\n");
-	}
-	else
+    }
+    else
             SetWindowLongW( hwnd, 0, 0 );
-	break;
+    break;
 
     case MM_SETMENUHANDLE:
@@ -3419,12 +3420,12 @@
 
     TRACE("(%04x, %04X, %04X) !\n",
-		 hMenu, wItemID, wFlags);
+         hMenu, wItemID, wFlags);
 
     /* Get the Popupmenu to access the owner menu */
     if (!(menu = MENU_GetMenu(hMenu)))
-	return (UINT)-1;
+    return (UINT)-1;
 
     if (!(item = MENU_FindItem( &hMenu, &wItemID, wFlags )))
-	return (UINT)-1;
+    return (UINT)-1;
 
     oldflags = item->fState & (MF_GRAYED | MF_DISABLED);
@@ -3433,19 +3434,19 @@
     /* In win95 if the close item in the system menu change update the close button */
     if (TWEAK_WineLook == WIN95_LOOK)
-	if((item->wID == SC_CLOSE) && (oldflags != wFlags))
-	{
-	    if (menu->hSysMenuOwner != 0)
-	    {
-		POPUPMENU* parentMenu;
-
-		/* Get the parent menu to access*/
-		if (!(parentMenu = MENU_GetMenu(menu->hSysMenuOwner)))
-		    return (UINT)-1;
-
-		/* Refresh the frame to reflect the change*/
-		SetWindowPos(parentMenu->hWnd, 0, 0, 0, 0, 0,
-			     SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER);
-	    }
-	}
+    if((item->wID == SC_CLOSE) && (oldflags != wFlags))
+    {
+        if (menu->hSysMenuOwner != 0)
+        {
+        POPUPMENU* parentMenu;
+
+        /* Get the parent menu to access*/
+        if (!(parentMenu = MENU_GetMenu(menu->hSysMenuOwner)))
+            return (UINT)-1;
+
+        /* Refresh the frame to reflect the change*/
+        SetWindowPos(parentMenu->hWnd, 0, 0, 0, 0, 0,
+                 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER);
+        }
+    }
 
     return oldflags;
@@ -3457,9 +3458,9 @@
  */
 INT WINAPI GetMenuStringA(
-	HMENU hMenu,	/* [in] menuhandle */
-	UINT wItemID,	/* [in] menu item (dep. on wFlags) */
-	LPSTR str,	/* [out] outbuffer. If NULL, func returns entry length*/
-	INT nMaxSiz,	/* [in] length of buffer. if 0, func returns entry len*/
-	UINT wFlags	/* [in] MF_ flags */
+    HMENU hMenu,    /* [in] menuhandle */
+    UINT wItemID,   /* [in] menu item (dep. on wFlags) */
+    LPSTR str,  /* [out] outbuffer. If NULL, func returns entry length*/
+    INT nMaxSiz,    /* [in] length of buffer. if 0, func returns entry len*/
+    UINT wFlags /* [in] MF_ flags */
 ) {
     MENUITEM *item;
@@ -3472,5 +3473,9 @@
     str[0] = '\0';
     if (!WideCharToMultiByte( CP_ACP, 0, item->text, -1, str, nMaxSiz, NULL, NULL ))
+#ifdef __WIN32OS2__
+        lstrtrunc( str, nMaxSiz );
+#else
         str[nMaxSiz-1] = 0;
+#endif
     TRACE("returning '%s'\n", str );
     return strlen(str);
@@ -3522,19 +3527,19 @@
     MENUITEM *item;
     TRACE("(menu=%04x, id=%04x, flags=%04x);\n",
-		 hMenu, wItemID, wFlags);
+         hMenu, wItemID, wFlags);
     if (!(item = MENU_FindItem( &hMenu, &wItemID, wFlags ))) return -1;
     debug_print_menuitem ("  item: ", item, "");
     if (item->fType & MF_POPUP)
     {
-	POPUPMENU *menu = MENU_GetMenu( item->hSubMenu );
-	if (!menu) return -1;
-	else return (menu->nItems << 8) | ((item->fState|item->fType) & 0xff);
+    POPUPMENU *menu = MENU_GetMenu( item->hSubMenu );
+    if (!menu) return -1;
+    else return (menu->nItems << 8) | ((item->fState|item->fType) & 0xff);
     }
     else
     {
-	/* We used to (from way back then) mask the result to 0xff.  */
-	/* I don't know why and it seems wrong as the documented */
-	/* return flag MF_SEPARATOR is outside that mask.  */
-	return (item->fType | item->fState);
+    /* We used to (from way back then) mask the result to 0xff.  */
+    /* I don't know why and it seems wrong as the documented */
+    /* return flag MF_SEPARATOR is outside that mask.  */
+    return (item->fType | item->fState);
     }
 }
@@ -3546,5 +3551,5 @@
 INT WINAPI GetMenuItemCount( HMENU hMenu )
 {
-    LPPOPUPMENU	menu = MENU_GetMenu(hMenu);
+    LPPOPUPMENU menu = MENU_GetMenu(hMenu);
     if (!menu) return -1;
     TRACE("(%04x) returning %d\n",
@@ -3585,8 +3590,8 @@
     if (IS_STRING_ITEM(flags) && str)
         TRACE("hMenu %04x, pos %d, flags %08x, "
-		      "id %04x, str %s\n",
+              "id %04x, str %s\n",
                       hMenu, pos, flags, id, debugstr_w(str) );
     else TRACE("hMenu %04x, pos %d, flags %08x, "
-		       "id %04x, str %08lx (not a string)\n",
+               "id %04x, str %08lx (not a string)\n",
                        hMenu, pos, flags, id, (DWORD)str );
 
@@ -3600,5 +3605,5 @@
 
     if (flags & MF_POPUP)  /* Set the MF_POPUP flag on the popup-menu */
-	(MENU_GetMenu((HMENU16)id))->wFlags |= MF_POPUP;
+    (MENU_GetMenu((HMENU16)id))->wFlags |= MF_POPUP;
 
     item->hCheckBit = item->hUnCheckBit = 0;
@@ -3656,5 +3661,5 @@
 BOOL WINAPI RemoveMenu( HMENU hMenu, UINT nPos, UINT wFlags )
 {
-    LPPOPUPMENU	menu;
+    LPPOPUPMENU menu;
     MENUITEM *item;
 
@@ -3674,10 +3679,10 @@
     else
     {
-	while(nPos < menu->nItems)
-	{
-	    *item = *(item+1);
-	    item++;
-	    nPos++;
-	}
+    while(nPos < menu->nItems)
+    {
+        *item = *(item+1);
+        item++;
+        nPos++;
+    }
         menu->items = HeapReAlloc( GetProcessHeap(), 0, menu->items,
                                    menu->nItems * sizeof(MENUITEM) );
@@ -3711,5 +3716,5 @@
     if (IS_STRING_ITEM(flags))
     {
-	TRACE("%04x %d %04x %04x %s\n",
+    TRACE("%04x %d %04x %04x %s\n",
                       hMenu, pos, flags, id, debugstr_w(str) );
         if (!str) return FALSE;
@@ -3717,5 +3722,5 @@
     else
     {
-	TRACE("%04x %d %04x %04x %08lx\n",
+    TRACE("%04x %d %04x %04x %08lx\n",
                       hMenu, pos, flags, id, (DWORD)str );
     }
@@ -3789,11 +3794,11 @@
     if (!hNewCheck && !hNewUnCheck)
     {
-	item->fState &= ~MF_USECHECKBITMAPS;
+    item->fState &= ~MF_USECHECKBITMAPS;
     }
     else  /* Install new bitmaps */
     {
-	item->hCheckBit = hNewCheck;
-	item->hUnCheckBit = hNewUnCheck;
-	item->fState |= MF_USECHECKBITMAPS;
+    item->hCheckBit = hNewCheck;
+    item->hUnCheckBit = hNewUnCheck;
+    item->fState |= MF_USECHECKBITMAPS;
     }
     return TRUE;
@@ -3880,5 +3885,5 @@
     HMENU retvalue = 0;
 
-    if(IsWindow(hWnd)) 
+    if(IsWindow(hWnd))
     {
         HMENU hSysMenu = getSysMenu(hWnd);
@@ -3934,41 +3939,41 @@
     if (wndPtr)
     {
-	if( wndPtr->hSysMenu )
-	{
-	    if( bRevert )
-	    {
-		DestroyMenu(wndPtr->hSysMenu);
-		wndPtr->hSysMenu = 0;
-	    }
-	    else
-	    {
-		POPUPMENU *menu = MENU_GetMenu( wndPtr->hSysMenu );
-		if( menu )
+    if( wndPtr->hSysMenu )
+    {
+        if( bRevert )
+        {
+        DestroyMenu(wndPtr->hSysMenu);
+        wndPtr->hSysMenu = 0;
+        }
+        else
+        {
+        POPUPMENU *menu = MENU_GetMenu( wndPtr->hSysMenu );
+        if( menu )
                 {
-		   if( menu->nItems > 0 && menu->items[0].hSubMenu == MENU_DefSysPopup )
-		      menu->items[0].hSubMenu = MENU_CopySysPopup();
-		}
-		else
-		{
-		   WARN("Current sys-menu (%04x) of wnd %04x is broken\n",
-			wndPtr->hSysMenu, hWnd);
-		   wndPtr->hSysMenu = 0;
-		}
-	    }
-	}
-
-	if(!wndPtr->hSysMenu && (wndPtr->dwStyle & WS_SYSMENU) )
-	    wndPtr->hSysMenu = MENU_GetSysMenu( hWnd, (HMENU)(-1) );
-
-	if( wndPtr->hSysMenu )
-        {
-	    POPUPMENU *menu;
-	    retvalue = GetSubMenu(wndPtr->hSysMenu, 0);
-
-	    /* Store the dummy sysmenu handle to facilitate the refresh */
-	    /* of the close button if the SC_CLOSE item change */
-	    menu = MENU_GetMenu(retvalue);
-	    if ( menu )
-	       menu->hSysMenuOwner = wndPtr->hSysMenu;
+           if( menu->nItems > 0 && menu->items[0].hSubMenu == MENU_DefSysPopup )
+              menu->items[0].hSubMenu = MENU_CopySysPopup();
+        }
+        else
+        {
+           WARN("Current sys-menu (%04x) of wnd %04x is broken\n",
+            wndPtr->hSysMenu, hWnd);
+           wndPtr->hSysMenu = 0;
+        }
+        }
+    }
+
+    if(!wndPtr->hSysMenu && (wndPtr->dwStyle & WS_SYSMENU) )
+        wndPtr->hSysMenu = MENU_GetSysMenu( hWnd, (HMENU)(-1) );
+
+    if( wndPtr->hSysMenu )
+        {
+        POPUPMENU *menu;
+        retvalue = GetSubMenu(wndPtr->hSysMenu, 0);
+
+        /* Store the dummy sysmenu handle to facilitate the refresh */
+        /* of the close button if the SC_CLOSE item change */
+        menu = MENU_GetMenu(retvalue);
+        if ( menu )
+           menu->hSysMenuOwner = wndPtr->hSysMenu;
         }
         WIN_ReleaseWndPtr(wndPtr);
@@ -3999,8 +4004,8 @@
     if (wndPtr)
     {
-	if (wndPtr->hSysMenu) DestroyMenu( wndPtr->hSysMenu );
-	wndPtr->hSysMenu = MENU_GetSysMenu( hwnd, hMenu );
+    if (wndPtr->hSysMenu) DestroyMenu( wndPtr->hSysMenu );
+    wndPtr->hSysMenu = MENU_GetSysMenu( hwnd, hMenu );
         WIN_ReleaseWndPtr(wndPtr);
-	return TRUE;
+    return TRUE;
     }
     return FALSE;
@@ -4126,11 +4131,11 @@
     if (!fEndMenu && top_popup)
     {
-	/* terminate the menu handling code */
+    /* terminate the menu handling code */
         fEndMenu = TRUE;
 
-	/* needs to be posted to wakeup the internal menu handler */
-	/* which will now terminate the menu, in the event that */
-	/* the main window was minimized, or lost focus, so we */
-	/* don't end up with an orphaned menu */
+    /* needs to be posted to wakeup the internal menu handler */
+    /* which will now terminate the menu, in the event that */
+    /* the main window was minimized, or lost focus, so we */
+    /* don't end up with an orphaned menu */
         PostMessageA( top_popup, WM_CANCELMODE, 0, 0);
     }
@@ -4152,5 +4157,5 @@
 #ifndef __WIN32OS2__
 /**********************************************************************
- *	    LoadMenu    (USER.150)
+ *      LoadMenu    (USER.150)
  */
 HMENU16 WINAPI LoadMenu16( HINSTANCE16 instance, LPCSTR name )
@@ -4204,5 +4209,5 @@
 
 /**********************************************************************
- *	    LoadMenuIndirect    (USER.220)
+ *      LoadMenuIndirect    (USER.220)
  */
 HMENU16 WINAPI LoadMenuIndirect16( LPCVOID template )
@@ -4233,5 +4238,5 @@
 
 /**********************************************************************
- *	    LoadMenuIndirectA    (USER32.@)
+ *      LoadMenuIndirectA    (USER32.@)
  */
 HMENU WINAPI LoadMenuIndirectA( LPCVOID template )
@@ -4247,23 +4252,23 @@
       {
       case 0:
-	offset = GET_WORD(p);
-	p += sizeof(WORD) + offset;
-	if (!(hMenu = CreateMenu())) return 0;
-	if (!MENU_ParseResource( p, hMenu, TRUE ))
-	  {
-	    DestroyMenu( hMenu );
-	    return 0;
-	  }
-	return hMenu;
+    offset = GET_WORD(p);
+    p += sizeof(WORD) + offset;
+    if (!(hMenu = CreateMenu())) return 0;
+    if (!MENU_ParseResource( p, hMenu, TRUE ))
+      {
+        DestroyMenu( hMenu );
+        return 0;
+      }
+    return hMenu;
       case 1:
-	offset = GET_WORD(p);
-	p += sizeof(WORD) + offset;
-	if (!(hMenu = CreateMenu())) return 0;
-	if (!MENUEX_ParseResource( p, hMenu))
-	  {
-	    DestroyMenu( hMenu );
-	    return 0;
-	  }
-	return hMenu;
+    offset = GET_WORD(p);
+    p += sizeof(WORD) + offset;
+    if (!(hMenu = CreateMenu())) return 0;
+    if (!MENUEX_ParseResource( p, hMenu))
+      {
+        DestroyMenu( hMenu );
+        return 0;
+      }
+    return hMenu;
       default:
         ERR("version %d not supported.\n", version);
@@ -4274,5 +4279,5 @@
 
 /**********************************************************************
- *	    LoadMenuIndirectW    (USER32.@)
+ *      LoadMenuIndirectW    (USER32.@)
  */
 HMENU WINAPI LoadMenuIndirectW( LPCVOID template )
@@ -4284,5 +4289,5 @@
 
 /**********************************************************************
- *		IsMenu    (USER32.@)
+ *      IsMenu    (USER32.@)
  */
 BOOL WINAPI IsMenu(HMENU hmenu)
@@ -4293,9 +4298,9 @@
 
 /**********************************************************************
- *		GetMenuItemInfo_common
+ *      GetMenuItemInfo_common
  */
 
 static BOOL GetMenuItemInfo_common ( HMENU hmenu, UINT item, BOOL bypos,
-					LPMENUITEMINFOW lpmii, BOOL unicode)
+                    LPMENUITEMINFOW lpmii, BOOL unicode)
 {
     MENUITEM *menu = MENU_FindItem (&hmenu, &item, bypos? MF_BYPOSITION : 0);
@@ -4304,18 +4309,18 @@
 
     if (!menu)
-	return FALSE;
+    return FALSE;
 
     if (lpmii->fMask & MIIM_TYPE) {
-	lpmii->fType = menu->fType;
-	switch (MENU_ITEM_TYPE(menu->fType)) {
-	case MF_STRING:
+    lpmii->fType = menu->fType;
+    switch (MENU_ITEM_TYPE(menu->fType)) {
+    case MF_STRING:
             break;  /* will be done below */
-	case MF_OWNERDRAW:
-	case MF_BITMAP:
-	    lpmii->dwTypeData = menu->text;
-	    /* fall through */
-	default:
-	    lpmii->cch = 0;
-	}
+    case MF_OWNERDRAW:
+    case MF_BITMAP:
+        lpmii->dwTypeData = menu->text;
+        /* fall through */
+    default:
+        lpmii->cch = 0;
+    }
     }
 
@@ -4337,5 +4342,9 @@
                 if (!WideCharToMultiByte( CP_ACP, 0, menu->text, -1,
                                           (LPSTR)lpmii->dwTypeData, lpmii->cch, NULL, NULL ))
+#ifdef __WIN32OS2__
+                    lstrtrunc((LPSTR)lpmii->dwTypeData, lpmii->cch );
+#else
                     ((LPSTR)lpmii->dwTypeData)[lpmii->cch-1] = 0;
+#endif
         }
         /* if we've copied a substring we return its length */
@@ -4349,24 +4358,24 @@
 
     if (lpmii->fMask & MIIM_FTYPE)
-	lpmii->fType = menu->fType;
+    lpmii->fType = menu->fType;
 
     if (lpmii->fMask & MIIM_BITMAP)
-	lpmii->hbmpItem = menu->hbmpItem;
+    lpmii->hbmpItem = menu->hbmpItem;
 
     if (lpmii->fMask & MIIM_STATE)
-	lpmii->fState = menu->fState;
+    lpmii->fState = menu->fState;
 
     if (lpmii->fMask & MIIM_ID)
-	lpmii->wID = menu->wID;
+    lpmii->wID = menu->wID;
 
     if (lpmii->fMask & MIIM_SUBMENU)
-	lpmii->hSubMenu = menu->hSubMenu;
+    lpmii->hSubMenu = menu->hSubMenu;
 
     if (lpmii->fMask & MIIM_CHECKMARKS) {
-	lpmii->hbmpChecked = menu->hCheckBit;
-	lpmii->hbmpUnchecked = menu->hUnCheckBit;
+    lpmii->hbmpChecked = menu->hCheckBit;
+    lpmii->hbmpUnchecked = menu->hUnCheckBit;
     }
     if (lpmii->fMask & MIIM_DATA)
-	lpmii->dwItemData = menu->dwItemData;
+    lpmii->dwItemData = menu->dwItemData;
 
   return TRUE;
@@ -4374,5 +4383,5 @@
 
 /**********************************************************************
- *		GetMenuItemInfoA    (USER32.@)
+ *      GetMenuItemInfoA    (USER32.@)
  */
 BOOL WINAPI GetMenuItemInfoA( HMENU hmenu, UINT item, BOOL bypos,
@@ -4384,5 +4393,5 @@
 
 /**********************************************************************
- *		GetMenuItemInfoW    (USER32.@)
+ *      GetMenuItemInfoW    (USER32.@)
  */
 BOOL WINAPI GetMenuItemInfoW( HMENU hmenu, UINT item, BOOL bypos,
@@ -4418,10 +4427,10 @@
 
 /**********************************************************************
- *		SetMenuItemInfo_common
+ *      SetMenuItemInfo_common
  */
 
 static BOOL SetMenuItemInfo_common(MENUITEM * menu,
-				       const MENUITEMINFOW *lpmii,
-				       BOOL unicode)
+                       const MENUITEMINFOW *lpmii,
+                       BOOL unicode)
 {
     if (!menu) return FALSE;
@@ -4430,15 +4439,15 @@
 
     if (lpmii->fMask & MIIM_TYPE ) {
-	/* Get rid of old string.  */
-	if ( IS_STRING_ITEM(menu->fType) && menu->text) {
-	    HeapFree(GetProcessHeap(), 0, menu->text);
-	    menu->text = NULL;
-	}
-
-	/* make only MENU_ITEM_TYPE bits in menu->fType equal lpmii->fType */
-	menu->fType &= ~MENU_ITEM_TYPE(menu->fType);
-	menu->fType |= MENU_ITEM_TYPE(lpmii->fType);
-
-	menu->text = lpmii->dwTypeData;
+    /* Get rid of old string.  */
+    if ( IS_STRING_ITEM(menu->fType) && menu->text) {
+        HeapFree(GetProcessHeap(), 0, menu->text);
+        menu->text = NULL;
+    }
+
+    /* make only MENU_ITEM_TYPE bits in menu->fType equal lpmii->fType */
+    menu->fType &= ~MENU_ITEM_TYPE(menu->fType);
+    menu->fType |= MENU_ITEM_TYPE(lpmii->fType);
+
+    menu->text = lpmii->dwTypeData;
 
        if (IS_STRING_ITEM(menu->fType))
@@ -4447,11 +4456,11 @@
 
     if (lpmii->fMask & MIIM_FTYPE ) {
-	/* free the string when the type is changing */
-	if ( (!IS_STRING_ITEM(lpmii->fType)) && IS_STRING_ITEM(menu->fType) && menu->text) {
-	    HeapFree(GetProcessHeap(), 0, menu->text);
-	    menu->text = NULL;
-	}
-	menu->fType &= ~MENU_ITEM_TYPE(menu->fType);
-	menu->fType |= MENU_ITEM_TYPE(lpmii->fType);
+    /* free the string when the type is changing */
+    if ( (!IS_STRING_ITEM(lpmii->fType)) && IS_STRING_ITEM(menu->fType) && menu->text) {
+        HeapFree(GetProcessHeap(), 0, menu->text);
+        menu->text = NULL;
+    }
+    menu->fType &= ~MENU_ITEM_TYPE(menu->fType);
+    menu->fType |= MENU_ITEM_TYPE(lpmii->fType);
         if ( IS_STRING_ITEM(menu->fType) && !menu->text )
             menu->fType |= MF_SEPARATOR;
@@ -4459,34 +4468,34 @@
 
     if (lpmii->fMask & MIIM_STRING ) {
-	/* free the string when used */
-	if ( IS_STRING_ITEM(menu->fType) && menu->text) {
-	    HeapFree(GetProcessHeap(), 0, menu->text);
+    /* free the string when used */
+    if ( IS_STRING_ITEM(menu->fType) && menu->text) {
+        HeapFree(GetProcessHeap(), 0, menu->text);
             set_menu_item_text( menu, lpmii->dwTypeData, unicode );
-	}
+    }
     }
 
     if (lpmii->fMask & MIIM_STATE)
     {
-	/* FIXME: MFS_DEFAULT do we have to reset the other menu items? */
-	menu->fState = lpmii->fState;
+    /* FIXME: MFS_DEFAULT do we have to reset the other menu items? */
+    menu->fState = lpmii->fState;
     }
 
     if (lpmii->fMask & MIIM_ID)
-	menu->wID = lpmii->wID;
+    menu->wID = lpmii->wID;
 
     if (lpmii->fMask & MIIM_SUBMENU) {
-	menu->hSubMenu = lpmii->hSubMenu;
-	if (menu->hSubMenu) {
-	    POPUPMENU *subMenu = MENU_GetMenu((UINT16)menu->hSubMenu);
-	    if (subMenu) {
-		subMenu->wFlags |= MF_POPUP;
-		menu->fType |= MF_POPUP;
-	    }
-	    else
-		/* FIXME: Return an error ? */
-		menu->fType &= ~MF_POPUP;
-	}
-	else
-	    menu->fType &= ~MF_POPUP;
+    menu->hSubMenu = lpmii->hSubMenu;
+    if (menu->hSubMenu) {
+        POPUPMENU *subMenu = MENU_GetMenu((UINT16)menu->hSubMenu);
+        if (subMenu) {
+        subMenu->wFlags |= MF_POPUP;
+        menu->fType |= MF_POPUP;
+        }
+        else
+        /* FIXME: Return an error ? */
+        menu->fType &= ~MF_POPUP;
+    }
+    else
+        menu->fType &= ~MF_POPUP;
     }
 
@@ -4496,9 +4505,9 @@
             menu->fType |= MFT_RADIOCHECK;
 
-	menu->hCheckBit = lpmii->hbmpChecked;
-	menu->hUnCheckBit = lpmii->hbmpUnchecked;
+    menu->hCheckBit = lpmii->hbmpChecked;
+    menu->hUnCheckBit = lpmii->hbmpUnchecked;
     }
     if (lpmii->fMask & MIIM_DATA)
-	menu->dwItemData = lpmii->dwItemData;
+    menu->dwItemData = lpmii->dwItemData;
 
     debug_print_menuitem("SetMenuItemInfo_common to : ", menu, "");
@@ -4507,5 +4516,5 @@
 
 /**********************************************************************
- *		SetMenuItemInfoA    (USER32.@)
+ *      SetMenuItemInfoA    (USER32.@)
  */
 BOOL WINAPI SetMenuItemInfoA(HMENU hmenu, UINT item, BOOL bypos,
@@ -4513,18 +4522,18 @@
 {
     if ((lpmii->fType & (MF_HILITE|MF_POPUP)) || (lpmii->fState)) {
-	/* QuickTime does pass invalid data into SetMenuItemInfo.
-	 * do some of the checks Windows does.
-	 */
+    /* QuickTime does pass invalid data into SetMenuItemInfo.
+     * do some of the checks Windows does.
+     */
         WARN("Bad masks for type (0x%08x) or state (0x%08x)\n",
              lpmii->fType,lpmii->fState );
-	return FALSE;
+    return FALSE;
     }
 
     return SetMenuItemInfo_common(MENU_FindItem(&hmenu, &item, bypos? MF_BYPOSITION : 0),
-				    (const MENUITEMINFOW *)lpmii, FALSE);
+                    (const MENUITEMINFOW *)lpmii, FALSE);
 }
 
 /**********************************************************************
- *		SetMenuItemInfoW    (USER32.@)
+ *      SetMenuItemInfoW    (USER32.@)
  */
 BOOL WINAPI SetMenuItemInfoW(HMENU hmenu, UINT item, BOOL bypos,
@@ -4532,94 +4541,94 @@
 {
     return SetMenuItemInfo_common(MENU_FindItem(&hmenu, &item, bypos? MF_BYPOSITION : 0),
-				    lpmii, TRUE);
+                    lpmii, TRUE);
 }
 
 /**********************************************************************
- *		SetMenuDefaultItem    (USER32.@)
+ *      SetMenuDefaultItem    (USER32.@)
  *
  */
 BOOL WINAPI SetMenuDefaultItem(HMENU hmenu, UINT uItem, UINT bypos)
 {
-	UINT i;
-	POPUPMENU *menu;
-	MENUITEM *item;
-
-	TRACE("(0x%x,%d,%d)\n", hmenu, uItem, bypos);
-
-	if (!(menu = MENU_GetMenu(hmenu))) return FALSE;
-
-	/* reset all default-item flags */
-	item = menu->items;
-	for (i = 0; i < menu->nItems; i++, item++)
-	{
-	    item->fState &= ~MFS_DEFAULT;
-	}
-
-	/* no default item */
-	if ( -1 == uItem)
-	{
-	    return TRUE;
-	}
-
-	item = menu->items;
-	if ( bypos )
-	{
-	    if ( uItem >= menu->nItems ) return FALSE;
-	    item[uItem].fState |= MFS_DEFAULT;
-	    return TRUE;
-	}
-	else
-	{
-	    for (i = 0; i < menu->nItems; i++, item++)
-	    {
-		if (item->wID == uItem)
-		{
-		     item->fState |= MFS_DEFAULT;
-		     return TRUE;
-		}
-	    }
-
-	}
-	return FALSE;
+    UINT i;
+    POPUPMENU *menu;
+    MENUITEM *item;
+
+    TRACE("(0x%x,%d,%d)\n", hmenu, uItem, bypos);
+
+    if (!(menu = MENU_GetMenu(hmenu))) return FALSE;
+
+    /* reset all default-item flags */
+    item = menu->items;
+    for (i = 0; i < menu->nItems; i++, item++)
+    {
+        item->fState &= ~MFS_DEFAULT;
+    }
+
+    /* no default item */
+    if ( -1 == uItem)
+    {
+        return TRUE;
+    }
+
+    item = menu->items;
+    if ( bypos )
+    {
+        if ( uItem >= menu->nItems ) return FALSE;
+        item[uItem].fState |= MFS_DEFAULT;
+        return TRUE;
+    }
+    else
+    {
+        for (i = 0; i < menu->nItems; i++, item++)
+        {
+        if (item->wID == uItem)
+        {
+             item->fState |= MFS_DEFAULT;
+             return TRUE;
+        }
+        }
+
+    }
+    return FALSE;
 }
 
 /**********************************************************************
- *		GetMenuDefaultItem    (USER32.@)
+ *      GetMenuDefaultItem    (USER32.@)
  */
 UINT WINAPI GetMenuDefaultItem(HMENU hmenu, UINT bypos, UINT flags)
 {
-	POPUPMENU *menu;
-	MENUITEM * item;
-	UINT i = 0;
-
-	TRACE("(0x%x,%d,%d)\n", hmenu, bypos, flags);
-
-	if (!(menu = MENU_GetMenu(hmenu))) return -1;
-
-	/* find default item */
-	item = menu->items;
-
-	/* empty menu */
-	if (! item) return -1;
-
-	while ( !( item->fState & MFS_DEFAULT ) )
-	{
-	    i++; item++;
-	    if  (i >= menu->nItems ) return -1;
-	}
-
-	/* default: don't return disabled items */
-	if ( (!(GMDI_USEDISABLED & flags)) && (item->fState & MFS_DISABLED )) return -1;
-
-	/* search rekursiv when needed */
-	if ( (item->fType & MF_POPUP) &&  (flags & GMDI_GOINTOPOPUPS) )
-	{
-	    UINT ret;
-	    ret = GetMenuDefaultItem( item->hSubMenu, bypos, flags );
-	    if ( -1 != ret ) return ret;
-
-	    /* when item not found in submenu, return the popup item */
-	}
-	return ( bypos ) ? i : item->wID;
+    POPUPMENU *menu;
+    MENUITEM * item;
+    UINT i = 0;
+
+    TRACE("(0x%x,%d,%d)\n", hmenu, bypos, flags);
+
+    if (!(menu = MENU_GetMenu(hmenu))) return -1;
+
+    /* find default item */
+    item = menu->items;
+
+    /* empty menu */
+    if (! item) return -1;
+
+    while ( !( item->fState & MFS_DEFAULT ) )
+    {
+        i++; item++;
+        if  (i >= menu->nItems ) return -1;
+    }
+
+    /* default: don't return disabled items */
+    if ( (!(GMDI_USEDISABLED & flags)) && (item->fState & MFS_DISABLED )) return -1;
+
+    /* search rekursiv when needed */
+    if ( (item->fType & MF_POPUP) &&  (flags & GMDI_GOINTOPOPUPS) )
+    {
+        UINT ret;
+        ret = GetMenuDefaultItem( item->hSubMenu, bypos, flags );
+        if ( -1 != ret ) return ret;
+
+        /* when item not found in submenu, return the popup item */
+    }
+    return ( bypos ) ? i : item->wID;
 
 }
@@ -4627,5 +4636,5 @@
 
 /**********************************************************************
- *		InsertMenuItemA    (USER32.@)
+ *      InsertMenuItemA    (USER32.@)
  */
 BOOL WINAPI InsertMenuItemA(HMENU hMenu, UINT uItem, BOOL bypos,
@@ -4638,5 +4647,5 @@
 
 /**********************************************************************
- *		InsertMenuItemW    (USER32.@)
+ *      InsertMenuItemW    (USER32.@)
  */
 BOOL WINAPI InsertMenuItemW(HMENU hMenu, UINT uItem, BOOL bypos,
@@ -4648,10 +4657,10 @@
 
 /**********************************************************************
- *		CheckMenuRadioItem    (USER32.@)
+ *      CheckMenuRadioItem    (USER32.@)
  */
 
 BOOL WINAPI CheckMenuRadioItem(HMENU hMenu,
-				   UINT first, UINT last, UINT check,
-				   UINT bypos)
+                   UINT first, UINT last, UINT check,
+                   UINT bypos)
 {
      MENUITEM *mifirst, *milast, *micheck;
@@ -4659,5 +4668,5 @@
 
      TRACE("ox%x: %d-%d, check %d, bypos=%d\n",
-		  hMenu, first, last, check, bypos);
+          hMenu, first, last, check, bypos);
 
      mifirst = MENU_FindItem (&mfirst, &first, bypos);
@@ -4666,19 +4675,19 @@
 
      if (mifirst == NULL || milast == NULL || micheck == NULL ||
-	 mifirst > milast || mfirst != mlast || mfirst != mcheck ||
-	 micheck > milast || micheck < mifirst)
-	  return FALSE;
+     mifirst > milast || mfirst != mlast || mfirst != mcheck ||
+     micheck > milast || micheck < mifirst)
+      return FALSE;
 
      while (mifirst <= milast)
      {
-	  if (mifirst == micheck)
-	  {
-	       mifirst->fType |= MFT_RADIOCHECK;
-	       mifirst->fState |= MFS_CHECKED;
-	  } else {
-	       mifirst->fType &= ~MFT_RADIOCHECK;
-	       mifirst->fState &= ~MFS_CHECKED;
-	  }
-	  mifirst++;
+      if (mifirst == micheck)
+      {
+           mifirst->fType |= MFT_RADIOCHECK;
+           mifirst->fState |= MFS_CHECKED;
+      } else {
+           mifirst->fType &= ~MFT_RADIOCHECK;
+           mifirst->fState &= ~MFS_CHECKED;
+      }
+      mifirst++;
      }
 
@@ -4687,5 +4696,5 @@
 
 /**********************************************************************
- *		GetMenuItemRect    (USER32.@)
+ *      GetMenuItemRect    (USER32.@)
  *
  *      ATTENTION: Here, the returned values in rect are the screen
@@ -4695,5 +4704,5 @@
  */
 BOOL WINAPI GetMenuItemRect (HWND hwnd, HMENU hMenu, UINT uItem,
-				 LPRECT rect)
+                 LPRECT rect)
 {
      POPUPMENU *itemMenu;
@@ -4708,15 +4717,15 @@
      if(!hwnd)
      {
-	 itemMenu = MENU_GetMenu(hMenu);
-	 if (itemMenu == NULL)
-	     return FALSE;
-
-	 if(itemMenu->hWnd == 0)
-	     return FALSE;
-	 referenceHwnd = itemMenu->hWnd;
+     itemMenu = MENU_GetMenu(hMenu);
+     if (itemMenu == NULL)
+         return FALSE;
+
+     if(itemMenu->hWnd == 0)
+         return FALSE;
+     referenceHwnd = itemMenu->hWnd;
      }
 
      if ((rect == NULL) || (item == NULL))
-	 return FALSE;
+     return FALSE;
 
      *rect = item->rect;
@@ -4729,9 +4738,9 @@
 
 /**********************************************************************
- *		SetMenuInfo    (USER32.@)
+ *      SetMenuInfo    (USER32.@)
  *
  * FIXME
- *	MIM_APPLYTOSUBMENUS
- *	actually use the items to draw the menu
+ *  MIM_APPLYTOSUBMENUS
+ *  actually use the items to draw the menu
  */
 BOOL WINAPI SetMenuInfo (HMENU hMenu, LPCMENUINFO lpmi)
@@ -4744,20 +4753,20 @@
     {
 
-	if (lpmi->fMask & MIM_BACKGROUND)
-	    menu->hbrBack = lpmi->hbrBack;
-
-	if (lpmi->fMask & MIM_HELPID)
-	    menu->dwContextHelpID = lpmi->dwContextHelpID;
-
-	if (lpmi->fMask & MIM_MAXHEIGHT)
-	    menu->cyMax = lpmi->cyMax;
-
-	if (lpmi->fMask & MIM_MENUDATA)
-	    menu->dwMenuData = lpmi->dwMenuData;
-
-	if (lpmi->fMask & MIM_STYLE)
-	    menu->dwStyle = lpmi->dwStyle;
-
-	return TRUE;
+    if (lpmi->fMask & MIM_BACKGROUND)
+        menu->hbrBack = lpmi->hbrBack;
+
+    if (lpmi->fMask & MIM_HELPID)
+        menu->dwContextHelpID = lpmi->dwContextHelpID;
+
+    if (lpmi->fMask & MIM_MAXHEIGHT)
+        menu->cyMax = lpmi->cyMax;
+
+    if (lpmi->fMask & MIM_MENUDATA)
+        menu->dwMenuData = lpmi->dwMenuData;
+
+    if (lpmi->fMask & MIM_STYLE)
+        menu->dwStyle = lpmi->dwStyle;
+
+    return TRUE;
     }
     return FALSE;
@@ -4765,8 +4774,8 @@
 
 /**********************************************************************
- *		GetMenuInfo    (USER32.@)
+ *      GetMenuInfo    (USER32.@)
  *
  *  NOTES
- *	win98/NT5.0
+ *  win98/NT5.0
  *
  */
@@ -4779,20 +4788,20 @@
     {
 
-	if (lpmi->fMask & MIM_BACKGROUND)
-	    lpmi->hbrBack = menu->hbrBack;
-
-	if (lpmi->fMask & MIM_HELPID)
-	    lpmi->dwContextHelpID = menu->dwContextHelpID;
-
-	if (lpmi->fMask & MIM_MAXHEIGHT)
-	    lpmi->cyMax = menu->cyMax;
-
-	if (lpmi->fMask & MIM_MENUDATA)
-	    lpmi->dwMenuData = menu->dwMenuData;
-
-	if (lpmi->fMask & MIM_STYLE)
-	    lpmi->dwStyle = menu->dwStyle;
-
-	return TRUE;
+    if (lpmi->fMask & MIM_BACKGROUND)
+        lpmi->hbrBack = menu->hbrBack;
+
+    if (lpmi->fMask & MIM_HELPID)
+        lpmi->dwContextHelpID = menu->dwContextHelpID;
+
+    if (lpmi->fMask & MIM_MAXHEIGHT)
+        lpmi->cyMax = menu->cyMax;
+
+    if (lpmi->fMask & MIM_MENUDATA)
+        lpmi->dwMenuData = menu->dwMenuData;
+
+    if (lpmi->fMask & MIM_STYLE)
+        lpmi->dwStyle = menu->dwStyle;
+
+    return TRUE;
     }
     return FALSE;
@@ -4810,6 +4819,6 @@
     if ((menu = MENU_GetMenu(hMenu)))
     {
-	menu->dwContextHelpID = dwContextHelpID;
-	return TRUE;
+    menu->dwContextHelpID = dwContextHelpID;
+    return TRUE;
     }
     return FALSE;
@@ -4827,5 +4836,5 @@
     if ((menu = MENU_GetMenu(hMenu)))
     {
-	return menu->dwContextHelpID;
+    return menu->dwContextHelpID;
     }
     return 0;
@@ -4847,5 +4856,5 @@
 }
 
-#ifdef __WIN32OS2__ 
+#ifdef __WIN32OS2__
 //******************************************************************************
 //******************************************************************************
@@ -4853,4 +4862,237 @@
 {
     fDisableOdinSysMenuItems = TRUE;
+}
+/**********************************************************************
+ *           KBD_translate_accelerator
+ *
+ * FIXME: should send some WM_INITMENU or/and WM_INITMENUPOPUP  -messages
+ */
+static BOOL KBD_translate_accelerator(HWND hWnd,LPMSG msg,
+                                      BYTE fVirt,WORD key,WORD cmd)
+{
+    BOOL sendmsg = FALSE;
+
+    if(msg->wParam == key)
+    {
+        if (msg->message == WM_CHAR) {
+            if ( !(fVirt & FALT) && !(fVirt & FVIRTKEY) )
+            {
+                dprintf(("TranslateAccelerator: found accel for WM_CHAR: ('%c')\n", msg->wParam&0xff));
+                sendmsg=TRUE;
+            }
+        }
+        else
+        {
+            if(fVirt & FVIRTKEY) {
+                INT mask = 0;
+                if(GetKeyState(VK_SHIFT) & 0x8000) mask |= FSHIFT;
+                if(GetKeyState(VK_CONTROL) & 0x8000) mask |= FCONTROL;
+                if(GetKeyState(VK_MENU) & 0x8000) mask |= FALT;
+
+                if(mask == (fVirt & (FSHIFT | FCONTROL | FALT)))
+                        sendmsg=TRUE;
+                else    dprintf(("TranslateAccelerator: but incorrect SHIFT/CTRL/ALT-state %x != %x", mask, fVirt));
+            }
+            else
+            {
+                if (!(msg->lParam & 0x01000000))  /* no special_key */
+                {
+                    if ((fVirt & FALT) && (msg->lParam & 0x20000000))
+                    {                                                   /* ^^ ALT pressed */
+                        dprintf(("TranslateAccelerator: found accel for Alt-%c\n", msg->wParam&0xff));
+                        sendmsg=TRUE;
+                    }
+                }
+            }
+        }
+
+            dprintf(("TranslateAccelerator: not match for %x %x %x", fVirt, key, cmd));
+    }
+
+    else if( key >= 1 && key <= 26 && !( fVirt & FVIRTKEY )) // Ctrl-A to Ctrl-Z
+    {
+        int ctrlCh;
+
+        if( msg->message == WM_CHAR )
+            ctrlCh = toupper( msg->wParam ) - 'A' + 1;
+        else
+            ctrlCh = msg->wParam - VK_A + 1;
+
+        if( ctrlCh == key )
+        {
+            INT mask = 0;
+            if(GetKeyState(VK_SHIFT) & 0x8000) mask |= FSHIFT;
+            if(GetKeyState(VK_CONTROL) & 0x8000) mask |= FCONTROL;
+            if(GetKeyState(VK_MENU) & 0x8000) mask |= FALT;
+
+            if(mask == FCONTROL)
+            {
+                sendmsg=TRUE;
+            }
+        }
+    }
+
+        if (sendmsg)      /* found an accelerator, but send a message... ? */
+        {
+            INT     iSysStat = -1,iStat = -1,mesg=0;
+            HMENU   hSysMenu, hMenu, hSubMenu;
+            UINT    nPos;
+
+            if (msg->message == WM_KEYUP || msg->message == WM_SYSKEYUP) {
+                mesg=1;
+            }
+            else
+                if (GetCapture())
+                    mesg=2;
+                else
+                if (!IsWindowEnabled(hWnd))
+                    mesg=3;
+                else
+                {
+                    hMenu = (GetWindowLongA(hWnd, GWL_STYLE) & WS_CHILD) ? NULL : GetMenu(hWnd);
+                    hSysMenu = getSysMenu(hWnd);
+
+                    hSubMenu = hSysMenu;
+                    nPos = cmd;
+                    if(MENU_FindItem(&hSubMenu, &nPos, MF_BYCOMMAND))
+                    {
+                        SendMessageA(hWnd, WM_INITMENU, (WPARAM)hSysMenu, 0L);
+                        if(hSubMenu != hSysMenu)
+                        {
+                            nPos = MENU_FindSubMenu(&hSysMenu, hSubMenu);
+                            dprintf(("hSysMenu = %04x, hSubMenu = %04x, nPos = %d\n", hSysMenu, hSubMenu, nPos));
+                            SendMessageA(hWnd, WM_INITMENUPOPUP, (WPARAM)hSubMenu, MAKELPARAM(nPos, TRUE));
+                        }
+                        iSysStat = GetMenuState(GetSubMenu(hSysMenu, 0), cmd, MF_BYCOMMAND);
+                    }
+                    else
+                    {
+                        hSubMenu = hMenu;
+                        nPos = cmd;
+                        if(MENU_FindItem(&hSubMenu, &nPos, MF_BYCOMMAND))
+                        {
+                            SendMessageA(hWnd, WM_INITMENU, (WPARAM)hMenu, 0L);
+                            if(hSubMenu != hMenu)
+                            {
+                                nPos = MENU_FindSubMenu(&hMenu, hSubMenu);
+                                dprintf(("hMenu = %04x, hSubMenu = %04x, nPos = %d\n", hMenu, hSubMenu, nPos));
+                                SendMessageA(hWnd, WM_INITMENUPOPUP, (WPARAM)hSubMenu, MAKELPARAM(nPos, FALSE));
+                            }
+                            iStat = GetMenuState(hMenu, cmd, MF_BYCOMMAND);
+                        }
+                    }
+
+                    if (iSysStat!=-1)
+                    {
+                        if (iSysStat & (MF_DISABLED|MF_GRAYED))
+                            mesg=4;
+                        else
+                            mesg=WM_SYSCOMMAND;
+                    }
+                    else
+                    {
+                        if (iStat!=-1)
+                        {
+                            if (IsIconic(hWnd)) {
+                                mesg=5;
+                            }
+                            else
+                            {
+                                if (iStat & (MF_DISABLED|MF_GRAYED))
+                                    mesg=6;
+                                else
+                                    mesg=WM_COMMAND;
+                            }
+                        }
+                        else
+                            mesg=WM_COMMAND;
+                    }
+                }
+                if ( mesg==WM_COMMAND )
+                    SendMessageA(hWnd, mesg, MAKEWPARAM( cmd, 1 ), NULL);
+                else if( mesg==WM_SYSCOMMAND )
+                    SendMessageA( hWnd, mesg, cmd, MAKELPARAM( 0, 1 ));
+                else
+                {
+                    /*  some reasons for NOT sending the WM_{SYS}COMMAND message:
+                     *   #0: unknown (please report!)
+                     *   #1: for WM_KEYUP,WM_SYSKEYUP
+                     *   #2: mouse is captured
+                     *   #3: window is disabled
+                     *   #4: it's a disabled system menu option
+                     *   #5: it's a menu option, but window is iconic
+                     *   #6: it's a menu option, but disabled
+                     */
+                    if(mesg==0)
+                            dprintf(("ERROR: unknown reason - please report!"));
+                    else    dprintf(("but won't send WM_{SYS}COMMAND, reason is #%d\n",mesg));
+
+                }
+                return TRUE;
+            }
+
+    return FALSE;
+}
+/*****************************************************************************
+ * Name      : int WIN32API TranslateAcceleratorA
+ * Purpose   : Translate WM_*KEYDOWN messages to WM_COMMAND messages
+ *             according to Accelerator table
+ * Parameters: HWND hwnd, HACCEL haccel, LPMSG lpmsg
+ * Variables :
+ * Result    : int FALSE (no accelerator found) TRUE (accelerator found)
+ * Remark    : if a accelerator is found it is not neccesarely executed
+ *             depends on window stat
+ *
+ *****************************************************************************/
+INT WINAPI TranslateAcceleratorA(HWND hWnd, HACCEL hAccel, LPMSG msg)
+{
+    /* YES, Accel16! */
+    LPACCEL lpAccelTbl;
+    int i;
+
+    SetLastError(ERROR_SUCCESS);
+    if (msg == NULL)
+    {
+          dprintf(("TranslateAcceleratorAmsg null; should hang here to be win compatible"));
+          SetLastError(ERROR_INVALID_PARAMETER);
+          return 0;
+    }
+    if (!hAccel || !(lpAccelTbl = (LPACCEL)GlobalLock(hAccel)))
+    {
+          dprintf(("TranslateAcceleratorA: invalid accel handle=%x", hAccel));
+          SetLastError(ERROR_INVALID_PARAMETER);
+          return 0;
+    }
+    if(!IsWindow(hWnd)) {
+          dprintf(("TranslateAccelerator, window %x not found", hWnd));
+          SetLastError(ERROR_INVALID_WINDOW_HANDLE);
+          return 0;
+    }
+    if ((msg->message != WM_KEYDOWN &&
+         msg->message != WM_KEYUP &&
+         msg->message != WM_SYSKEYDOWN &&
+         msg->message != WM_SYSKEYUP &&
+         msg->message != WM_CHAR))
+    {
+          return 0;
+    }
+
+/*    TRACE_(accel)("TranslateAccelerators hAccel=%04x, hWnd=%04x,"
+      "msg->hwnd=%04x, msg->message=%04x, wParam=%08x, lParam=%lx\n",
+      hAccel,hWnd,msg->hwnd,msg->message,msg->wParam,msg->lParam); */
+
+    i = 0;
+    do
+    {
+        if (KBD_translate_accelerator(hWnd,msg,lpAccelTbl[i].fVirt,
+                                      lpAccelTbl[i].key,lpAccelTbl[i].cmd))
+        {
+            return 1;
+        }
+    }
+    while ((lpAccelTbl[i++].fVirt & 0x80) == 0);
+
+//    WARN_(accel)("couldn't translate accelerator key\n");
+    return 0;
 }
 //******************************************************************************
@@ -5046,2 +5288,4 @@
 }
 #endif
+
+
Index: trunk/src/user32/msgbox.c
===================================================================
--- trunk/src/user32/msgbox.c	(revision 10189)
+++ trunk/src/user32/msgbox.c	(revision 10190)
@@ -1,3 +1,3 @@
-/* $Id: msgbox.c,v 1.7 2003-05-06 13:50:36 sandervl Exp $ */
+/* $Id: msgbox.c,v 1.8 2003-07-31 15:56:43 sandervl Exp $ */
 /*
  * Message boxes (based on Wine code)
@@ -360,6 +360,28 @@
 {
     MSGBOXPARAMSA       msgboxa;
+#ifdef __WIN32OS2__
+    int ret;
+#endif
 
     memcpy(&msgboxa,msgbox,sizeof(msgboxa));
+#ifdef __WIN32OS2__
+    if (msgbox->lpszCaption)
+        msgboxa.lpszCaption = HEAP_strdupWtoA( GetProcessHeap(), 0, msgbox->lpszCaption );
+    if (msgbox->lpszText)
+        msgboxa.lpszText = HEAP_strdupWtoA( GetProcessHeap(), 0, msgbox->lpszText );
+    if( msgbox->lpszIcon && HIWORD( msgbox->lpszIcon ))
+        msgboxa.lpszIcon = HEAP_strdupWtoA( GetProcessHeap(), 0, msgbox->lpszIcon );
+
+    ret = MessageBoxIndirectA(&msgboxa);
+
+    if (msgbox->lpszCaption)
+        HeapFree( GetProcessHeap(), 0, ( LPVOID )msgboxa.lpszCaption );
+    if (msgbox->lpszText)
+        HeapFree( GetProcessHeap(), 0, ( LPVOID )msgboxa.lpszText );
+    if( msgbox->lpszIcon && HIWORD( msgbox->lpszIcon ))
+        HeapFree( GetProcessHeap(), 0, ( LPVOID )msgboxa.lpszIcon );
+
+    return ret;
+#else
     if (msgbox->lpszCaption)
       lstrcpyWtoA((LPSTR)msgboxa.lpszCaption,msgbox->lpszCaption);
@@ -368,4 +390,6 @@
 
     return MessageBoxIndirectA(&msgboxa);
+#endif
+
 }
 
Index: trunk/src/user32/oslibmsg.cpp
===================================================================
--- trunk/src/user32/oslibmsg.cpp	(revision 10189)
+++ trunk/src/user32/oslibmsg.cpp	(revision 10190)
@@ -1,3 +1,3 @@
-/* $Id: oslibmsg.cpp,v 1.71 2003-07-28 11:27:45 sandervl Exp $ */
+/* $Id: oslibmsg.cpp,v 1.72 2003-07-31 15:56:43 sandervl Exp $ */
 /*
  * Window message translation functions for OS/2
@@ -226,5 +226,6 @@
   else {//is this allowed?
 //        dprintf(("WARNING: OSLibWinDispatchMsg: called with own message!"));
-        return SendMessageA(msg->hwnd, msg->message, msg->wParam, msg->lParam);
+        return isUnicode ? SendMessageW(msg->hwnd, msg->message, msg->wParam, msg->lParam) :
+                           SendMessageA(msg->hwnd, msg->message, msg->wParam, msg->lParam);
   }
 }
Index: trunk/src/user32/oslibmsgtranslate.cpp
===================================================================
--- trunk/src/user32/oslibmsgtranslate.cpp	(revision 10189)
+++ trunk/src/user32/oslibmsgtranslate.cpp	(revision 10190)
@@ -1,3 +1,3 @@
-/* $Id: oslibmsgtranslate.cpp,v 1.112 2003-07-31 12:25:57 sandervl Exp $ */
+/* $Id: oslibmsgtranslate.cpp,v 1.113 2003-07-31 15:56:44 sandervl Exp $ */
 /*
  * Window message translation functions for OS/2
@@ -38,4 +38,5 @@
 #include <winkeyboard.h>
 #include <winnls.h>
+#include <heapstring.h>
 #include "hook.h"
 #include "user32api.h"
@@ -732,12 +733,54 @@
         WORD  wWinScan;
 
-        if (scanCode==0) goto dummymessage;
-
-        KeyTranslatePMScanToWinVKey(usPMScanCode,
-                                    FALSE,
-                                    &bWinVKey,
-                                    &wWinScan,
-                                    &fWinExtended);
-        winMsg->wParam = bWinVKey;
+        if ( (!IsDBCSEnv() && scanCode == 0) || 
+             (scanCode==0 ) && !( flags & KC_CHAR ) ) 
+        {
+            goto dummymessage;
+        }
+
+        if( scanCode != 0 )
+        {
+            KeyTranslatePMScanToWinVKey(usPMScanCode,
+                                        FALSE,
+                                        &bWinVKey,
+                                        &wWinScan,
+                                        &fWinExtended);
+            winMsg->wParam = bWinVKey;
+        }
+        else
+        {
+            dprintf(("PM: WM_CHAR: DBCS processing "));
+
+            winMsg->wParam = CHAR1FROMMP( os2Msg->mp2 );
+
+            wWinScan = 0;
+            fWinExtended = 0;
+
+            if( CHAR2FROMMP( os2Msg->mp2 ))     // DBCS character
+            {
+                if( isUnicode )
+                {
+                    char  dbcsCh[] = { CHAR1FROMMP( os2Msg->mp2 ), CHAR2FROMMP( os2Msg->mp2 ), 0 };
+                    WCHAR uniChar[ 2 ];
+
+                    lstrcpynAtoW(( LPWSTR )&uniChar, ( LPCSTR )&dbcsCh, 2 );
+                    winMsg->wParam = ( WPARAM )uniChar[ 0 ];
+                }
+                // insert DBCS trail byte for Non-Unicode window
+                else if(fMsgRemoved && !(teb->o.odin.fTranslated))
+                {
+                    MSG extramsg;
+                    memcpy(&extramsg, winMsg, sizeof(MSG));
+
+                    //After SetFocus(0), all keystrokes are converted in WM_SYS*
+                    extramsg.message = (fIgnoreKeystrokes) ? WINWM_SYSCHAR : WINWM_CHAR;
+
+                    extramsg.wParam = CHAR2FROMMP( os2Msg->mp2 );
+                    extramsg.lParam = 0;
+
+                    setThreadQueueExtraCharMessage(teb, &extramsg);
+                }
+            }
+        }
         winMsg->lParam  = repeatCount & 0x0FFFF;                 // bit 0-15, repeatcount
         winMsg->lParam |= (wWinScan & 0x1FF) << 16;  // bit 16-23, scancode + bit 15 extended
@@ -797,4 +840,9 @@
             winMsg->lParam |= WIN_KEY_PREVSTATE;                    // bit 30, previous state, always 1 for a WM_KEYUP message
             winMsg->lParam |= 1 << 31;                              // bit 31, transition state, always 1 for WM_KEYUP
+          }
+          else if( scanCode == 0 )
+          {
+            //After SetFocus(0), all keystrokes are converted in WM_SYS*
+            winMsg->message = (fIgnoreKeystrokes) ? WINWM_SYSCHAR :  WINWM_CHAR;
           }
           else
Index: trunk/src/user32/pmwindow.cpp
===================================================================
--- trunk/src/user32/pmwindow.cpp	(revision 10189)
+++ trunk/src/user32/pmwindow.cpp	(revision 10190)
@@ -1,3 +1,3 @@
-/* $Id: pmwindow.cpp,v 1.217 2003-07-28 11:27:47 sandervl Exp $ */
+/* $Id: pmwindow.cpp,v 1.218 2003-07-31 15:56:44 sandervl Exp $ */
 /*
  * Win32 Window Managment Code for OS/2
@@ -514,5 +514,5 @@
     // - thread must not be suspended in WaitMessage
     if(!teb || (msg != WM_CREATE && win32wnd == NULL) || teb->o.odin.fWaitMessageSuspend) {
-        if(teb->o.odin.fWaitMessageSuspend) 
+        if(teb && teb->o.odin.fWaitMessageSuspend) 
              dprintf(("OS2: fWaitMessageSuspend window %x msg %x -> run default frame proc", hwnd, msg));
         else dprintf(("OS2: Invalid win32wnd pointer for window %x msg %x", hwnd, msg));
@@ -1182,5 +1182,5 @@
     // - thread must not be suspended in WaitMessage
     if(!teb || (msg != WM_CREATE && win32wnd == NULL) || teb->o.odin.fWaitMessageSuspend) {
-        if(teb->o.odin.fWaitMessageSuspend) 
+        if(teb && teb->o.odin.fWaitMessageSuspend) 
              dprintf(("PMFRAME: fWaitMessageSuspend window %x msg %x -> run default frame proc", hwnd, msg));
         else dprintf(("PMFRAME: Invalid win32wnd pointer for window %x msg %x", hwnd, msg));
Index: trunk/src/user32/resources/user32_Ko.orc
===================================================================
--- trunk/src/user32/resources/user32_Ko.orc	(revision 10189)
+++ trunk/src/user32/resources/user32_Ko.orc	(revision 10190)
@@ -7,5 +7,5 @@
  MENUITEM "Å©±â º¯°æ(&S)", 61440
  MENUITEM "ŸÆÀÌÄÜ Ç¥œÃ(&N)", 61472
- MENUITEM "ÀüÃŒ È­žé Ç¥œÃ(&M)", 61488
+ MENUITEM "ÀüÃŒ È­žé Ç¥œÃ(&F)", 61488
  MENUITEM SEPARATOR
  MENUITEM "ŽÝ±â(&C)\tAlt-F4", 61536
@@ -16,13 +16,13 @@
 SYSMENUWARP MENU LOADONCALL MOVEABLE DISCARDABLE
 {
- MENUITEM "º¹Í(&R)\tAlt-F5", 61728
- MENUITEM "ÀÌ¿(&M)\tAlt-F7", 61456
- MENUITEM "Åâ º¯°æ(&S)\tAlt-F8", 61440
- MENUITEM "ÆÀÌÄÜ ÇÃ(&N)\tAlt-F9", 61472
- MENUITEM "ÀüÃ Èžé ÇÃ(&M)\tAlt-F10", 61488
+ MENUITEM "º¹±Í(&R)\tAlt-F5", 61728
+ MENUITEM "ÀÌµ¿(&M)\tAlt-F7", 61456
+ MENUITEM "Å©±â º¯°æ(&S)\tAlt-F8", 61440
+ MENUITEM "ŸÆÀÌÄÜ Ç¥œÃ(&N)\tAlt-F9", 61472
+ MENUITEM "ÀüÃŒ È­žé Ç¥œÃ(&F)\tAlt-F10", 61488
  MENUITEM SEPARATOR
- MENUITEM "Ýâ(&C)\tAlt-F4", 61536
+ MENUITEM "ŽÝ±â(&C)\tAlt-F4", 61536
  MENUITEM SEPARATOR
- MENUITEM "ÀÛ÷ ÀüÈ¯(&W) ...\tCtrl-Esc", 61744
+ MENUITEM "ÀÛŸ÷ ÀüÈ¯(&W) ...\tCtrl-Esc", 61744
 }
 
Index: trunk/src/user32/win32wbase.cpp
===================================================================
--- trunk/src/user32/win32wbase.cpp	(revision 10189)
+++ trunk/src/user32/win32wbase.cpp	(revision 10190)
@@ -1,3 +1,3 @@
-/* $Id: win32wbase.cpp,v 1.375 2003-06-03 09:51:05 sandervl Exp $ */
+/* $Id: win32wbase.cpp,v 1.376 2003-07-31 15:56:45 sandervl Exp $ */
 /*
  * Win32 Window Base Class for OS/2
@@ -86,5 +86,5 @@
 //******************************************************************************
 //******************************************************************************
-Win32BaseWindow::Win32BaseWindow() 
+Win32BaseWindow::Win32BaseWindow()
                      : GenericObject(&windows, &critsect), ChildWindow(&critsect)
 {
@@ -126,6 +126,7 @@
   windowNameA      = NULL;
   windowNameW      = NULL;
-  windowNameLength = 0;
-  
+  windowNameLengthA = 0;
+  windowNameLengthW = 0;
+
   userWindowBytes  = NULL;;
   nrUserWindowBytes= 0;
@@ -228,5 +229,5 @@
     {
         //if we're the last child that's being destroyed and our
-        //parent window was also destroyed, then we 
+        //parent window was also destroyed, then we
         if(getParent()->IsWindowDestroyed())
         {
@@ -236,5 +237,5 @@
         }
     }
-    else 
+    else
     {
         Win32BaseWindow *wndparent = (Win32BaseWindow *)ChildWindow::getParentOfChild();
@@ -340,5 +341,5 @@
             }
             if (window->getExStyle() & WS_EX_TOPMOST)
-                 cs->dwExStyle |= WS_EX_TOPMOST;          
+                 cs->dwExStyle |= WS_EX_TOPMOST;
 
             RELEASE_WNDOBJ(window);
@@ -389,5 +390,4 @@
         cs->lpszClass = buffer;
     }
-
     /* Fix the coordinates */
     fXDefault = FALSE;
@@ -446,5 +446,5 @@
                  RELEASE_WNDOBJ(wndparent);
             }
-            else owner = NULL;        
+            else owner = NULL;
 
             if(owner == NULL)
@@ -582,5 +582,5 @@
         vertScrollInfo->flags  = ESB_ENABLE_BOTH;
     }
-  
+
     // initially allocate the window name fields
     if(HIWORD(cs->lpszName))
@@ -588,34 +588,31 @@
         if (!isUnicode)
         {
-            windowNameLength = strlen(cs->lpszName);
-            windowNameA = (LPSTR)_smalloc(windowNameLength+1);
-            memcpy(windowNameA,cs->lpszName,windowNameLength+1);
-            windowNameW = (LPWSTR)_smalloc((windowNameLength+1)*sizeof(WCHAR));
-            lstrcpynAtoW(windowNameW,windowNameA,windowNameLength+1);
-            windowNameA[windowNameLength] = 0;
-            windowNameW[windowNameLength] = 0;
+            windowNameLengthA = strlen(cs->lpszName);
+            windowNameA = (LPSTR)_smalloc(windowNameLengthA+1);
+            strcpy(windowNameA,cs->lpszName);
+
+            windowNameLengthW = lstrlenAtoW( windowNameA, -1 );
+            windowNameW = (LPWSTR)_smalloc(( windowNameLengthW + 1 ) * sizeof( WCHAR ) );
+            lstrcpyAtoW( windowNameW, windowNameA );
         }
         else
         {
             // Wide
-            windowNameLength = lstrlenW((LPWSTR)cs->lpszName);
-            windowNameW = (LPWSTR)_smalloc( (windowNameLength+1)*sizeof(WCHAR) );
-            memcpy(windowNameW,(LPWSTR)cs->lpszName, (windowNameLength+1)*sizeof(WCHAR) );
-          
+            windowNameLengthW = lstrlenW((LPWSTR)cs->lpszName);
+            windowNameW = (LPWSTR)_smalloc((windowNameLengthW+1)*sizeof(WCHAR));
+            strcpyW(windowNameW,(LPWSTR)cs->lpszName);
+
             // windowNameW[lstrlenW((LPWSTR)cs->lpszName)] = 0; // need ?
-          
+
             // Ascii
-            windowNameA = (LPSTR)_smalloc(windowNameLength+1);
-            WideCharToMultiByte(CP_ACP,
-                                0,
-                                windowNameW,
-                                windowNameLength,
-                                windowNameA,
-                                windowNameLength + 1,
-                                0,
-                                NULL);
-            windowNameA[windowNameLength] = 0;
-        }
-      
+            windowNameLengthA = lstrlenWtoA( windowNameW, -1 );
+            windowNameA = (LPSTR)_smalloc( windowNameLengthA + 1 );
+            lstrcpyWtoA( windowNameA, windowNameW );
+        }
+
+        dprintf(("windowNameA 0x%lx to 0x%lx windowNameW : 0x%lx to 0x%lx",
+                windowNameA, windowNameA + windowNameLengthA,
+                windowNameW, windowNameW + windowNameLengthW ));
+
         if(fOS2Look) {
             OSLibWinSetTitleBarText(OS2HwndFrame, windowNameA);
@@ -752,5 +749,5 @@
         //@@PF Popup children of inactive windows can thus bring inactive window
         //on top, this is not correct, popup windows can be on top only if their owner
-        //is in foreground, otherwise they are linked after owner. 
+        //is in foreground, otherwise they are linked after owner.
         if (((dwStyle & (WS_CHILD|WS_POPUP)) == WS_POPUP) && getOwner() && (getOwner()->getWindowHandle() != GetForegroundWindow()))
         {
@@ -1066,5 +1063,5 @@
 
     dprintf(("MsgButton %d at (%d,%d)", msg->message, msg->pt.x, msg->pt.y));
-    switch(msg->message) 
+    switch(msg->message)
     {
         case WM_LBUTTONDBLCLK:
@@ -1132,5 +1129,5 @@
     SendMessageA(getWindowHandle(),WM_SETCURSOR, getWindowHandle(), MAKELONG(lastHitTestVal, msg->message));
 
-    switch(msg->message) 
+    switch(msg->message)
     {
         case WM_LBUTTONDOWN:
@@ -1155,8 +1152,8 @@
 }
 //******************************************************************************
-// 
+//
 // Win32BaseWindow::saveAndValidateUpdateRegion
 //
-//   If an application doesn't validate the update region while processing 
+//   If an application doesn't validate the update region while processing
 //   WM_PAINT, then we must remember it for the next time. Also validates
 //   the current update region.
@@ -1192,8 +1189,8 @@
 }
 //******************************************************************************
-// 
+//
 // Win32BaseWindow::checkForDirtyUpdateRegion
 //
-//   If an application doesn't validate the update region while processing 
+//   If an application doesn't validate the update region while processing
 //   WM_PAINT, then we must remember it for the next time. If the window has
 //   a dirty update region, then invalidate that region.
@@ -1250,5 +1247,5 @@
 ULONG Win32BaseWindow::MsgChar(MSG *msg)
 {
-    return DispatchMsgA(msg);
+    return IsWindowUnicode() ? DispatchMsgW( msg ) : DispatchMsgA( msg );
 }
 //******************************************************************************
@@ -1276,5 +1273,5 @@
     //Send WM_PAINTICON here if minimized, because client window will
     //not receive a (valid) WM_PAINT message
-    if (getStyle() & WS_MINIMIZE) 
+    if (getStyle() & WS_MINIMIZE)
     {
         rc = SendMessageA(getWindowHandle(),WM_PAINTICON, 1, 0);
@@ -1347,5 +1344,5 @@
 #endif
   //WS_EX_TOOLWINDOW is incompatible with the OS2Look (titlebar thinner + smaller font)
-  if(fOS2Look && ((dwStyle & WS_CAPTION) == WS_CAPTION) && !(dwExStyle & WS_EX_TOOLWINDOW)) 
+  if(fOS2Look && ((dwStyle & WS_CAPTION) == WS_CAPTION) && !(dwExStyle & WS_EX_TOOLWINDOW))
   {
       RECT rect = {0};
@@ -1362,5 +1359,5 @@
       rect.top    = rect.bottom - rect.top;
       rect.right  = rectWindow.right - rectWindow.left - rect.right;
- 
+
       rectOS2.xLeft   = rect.left;
       rectOS2.xRight  = rect.right;
@@ -1368,9 +1365,9 @@
       rectOS2.yTop    = height - rect.bottom;
 
-      //@@PF Disable close button as well when needed by application 
+      //@@PF Disable close button as well when needed by application
       OSLibChangeCloseButtonState(getOS2FrameWindowHandle(), fCloseButton);
       OSLibWinPositionFrameControls(getOS2FrameWindowHandle(), &rectOS2,
                                     dwStyle, dwExStyle, IconForWindow(ICON_SMALL),
-				    fCloseButton, windowClass->getIcon() != NULL);
+                    fCloseButton, windowClass->getIcon() != NULL);
   }
   return rc;
@@ -1562,19 +1559,19 @@
 
     case WM_GETTEXTLENGTH:
-        return windowNameLength;
+        return windowNameLengthA;
 
     case WM_GETTEXT:
-        if (!lParam || !wParam) 
+        if (!lParam || !wParam)
           return 0;
-        if (!windowNameA) 
+        if (!windowNameA)
           ((LPSTR)lParam)[0] = 0;
-        else 
-          memcpy((LPSTR)lParam, windowNameA, min(windowNameLength+1, wParam) );
-        return min(windowNameLength, wParam);
+        else
+          lstrcpynA(( LPSTR )lParam, windowNameA, wParam );
+        return strlen(( LPSTR )lParam );
 
     case WM_SETTEXT:
     {
         LPCSTR lpsz = (LPCSTR)lParam;
-      
+
         // reallocate if new buffer is larger
         if (!lParam)
@@ -1582,5 +1579,6 @@
           free(windowNameA);
           free(windowNameW);
-          windowNameLength = 0;
+          windowNameLengthA = 0;
+          windowNameLengthW = 0;
           windowNameA      = NULL;
           windowNameW      = NULL;
@@ -1590,6 +1588,6 @@
           // determine length of new text
           int iTextLength = strlen(lpsz);
-          
-          if (windowNameLength < iTextLength)
+
+          if (windowNameLengthA < iTextLength)
           {
             if (windowNameA)
@@ -1598,5 +1596,5 @@
               windowNameA = NULL;
             }
-          
+
             if (windowNameW)
             {
@@ -1605,14 +1603,15 @@
             }
           }
-      
-          windowNameLength = iTextLength;
+
+          windowNameLengthA = iTextLength;
           if(!windowNameA)
-            windowNameA = (LPSTR)_smalloc(windowNameLength+1);
-          memcpy(windowNameA, lpsz, windowNameLength+1);
+            windowNameA = (LPSTR)_smalloc(windowNameLengthA+1);
+          strcpy(windowNameA, lpsz);
+          windowNameLengthW = lstrlenAtoW( windowNameA, -1 );
           if(!windowNameW)
-            windowNameW = (LPWSTR)_smalloc((windowNameLength+1)*sizeof(WCHAR));
-          lstrcpynAtoW(windowNameW, windowNameA, windowNameLength+1);
-        }
-      
+            windowNameW = (LPWSTR)_smalloc(( windowNameLengthW + 1 )*sizeof(WCHAR));
+          lstrcpyAtoW( windowNameW, windowNameA );
+        }
+
         dprintf(("WM_SETTEXT of %x to %s\n", Win32Hwnd, lParam));
         if ((dwStyle & WS_CAPTION) == WS_CAPTION)
@@ -1675,10 +1674,10 @@
         dprintf(("DefWndProc: WM_MOUSEACTIVATE for %x Msg %s", Win32Hwnd, GetMsgText(HIWORD(lParam))));
         if (::GetWindowLongW( hwnd, GWL_STYLE ) & WS_CHILD)
-	{
-	    LONG ret = ::SendMessageW( ::GetParent(hwnd), WM_MOUSEACTIVATE, wParam, lParam );
-	    if (ret) return ret;
-	}
-
-	/* Caption clicks are handled by the NC_HandleNCLButtonDown() */
+    {
+        LONG ret = ::SendMessageW( ::GetParent(hwnd), WM_MOUSEACTIVATE, wParam, lParam );
+        if (ret) return ret;
+    }
+
+    /* Caption clicks are handled by the NC_HandleNCLButtonDown() */
         return (LOWORD(lParam) >= HTCLIENT) ? MA_ACTIVATE : MA_NOACTIVATE;
     }
@@ -1754,5 +1753,5 @@
         if (::GetWindowLongA( getWindowHandle(), GWL_STYLE ) & WS_CHILD)
             return ::SendMessageA( ::GetParent(getWindowHandle()), WM_MOUSEWHEEL, wParam, lParam );
-	break;
+    break;
 
     case WM_WINDOWPOSCHANGED:
@@ -1789,6 +1788,6 @@
       RECT   rect;
       int    rc;
-     
-        if (!windowClass || (!windowClass->getBackgroundBrush() 
+
+        if (!windowClass || (!windowClass->getBackgroundBrush()
                               && !(getStyle() & WS_MINIMIZE))) return 0;
 
@@ -1804,5 +1803,5 @@
                 hBrush = GetSysColorBrush(hBrush-1);
         }
-             
+
 
         rc = GetClipBox( (HDC)wParam, &rect );
@@ -1905,69 +1904,69 @@
 
     case WM_KEYDOWN:
-	if(wParam == VK_F10) iF10Key = VK_F10;
-	break;
+    if(wParam == VK_F10) iF10Key = VK_F10;
+    break;
 
     case WM_SYSKEYDOWN:
     {
-	if( HIWORD(lParam) & KEYDATA_ALT )
-	{
-	    /* if( HIWORD(lParam) & ~KEYDATA_PREVSTATE ) */
-	      if( wParam == VK_MENU && !iMenuSysKey )
-		iMenuSysKey = 1;
-	      else
-		iMenuSysKey = 0;
-	    
-	    iF10Key = 0;
-
-	    if( wParam == VK_F4 )	/* try to close the window */
-	    {
+    if( HIWORD(lParam) & KEYDATA_ALT )
+    {
+        /* if( HIWORD(lParam) & ~KEYDATA_PREVSTATE ) */
+          if( wParam == VK_MENU && !iMenuSysKey )
+        iMenuSysKey = 1;
+          else
+        iMenuSysKey = 0;
+
+        iF10Key = 0;
+
+        if( wParam == VK_F4 )   /* try to close the window */
+        {
                 HWND top = GetTopParent();
                 if (!(GetClassLongW( top, GCL_STYLE ) & CS_NOCLOSE))
                     PostMessageW( top, WM_SYSCOMMAND, SC_CLOSE, 0 );
-	    }
+        }
 
             //Default OS/2 app behaviour for system keys
             if(fOS2Look)
             {
-		    if( wParam == VK_F5 )	/* try to restore the window */
-		    {
-	                HWND top = GetTopParent();
+            if( wParam == VK_F5 )   /* try to restore the window */
+            {
+                    HWND top = GetTopParent();
                         /* No checks needed SC_RESTORE handler does them */
-	                PostMessageW( top, WM_SYSCOMMAND, SC_RESTORE, 0 );
-		    }
-
-		    if( wParam == VK_F7 )	/* size the window */
-		    {
-	                HWND top = GetTopParent();
-	                PostMessageW( top, WM_SYSCOMMAND, SC_MOVE, 0 );
-		    }
-
-		    if( wParam == VK_F8 )	/* move the window */
-		    {
-	                HWND top = GetTopParent();
-	                if ( GetWindowLongA(top, GWL_STYLE) & WS_SIZEBOX)
-	                PostMessageW( top, WM_SYSCOMMAND, SC_SIZE, 0 );
-		    }
-
-		    if( wParam == VK_F9 )	/* try to minimize the window */
-		    {
-	                HWND top = GetTopParent();
-	                if ( GetWindowLongA(top, GWL_STYLE) & WS_MINIMIZEBOX)
-	                    PostMessageW( top, WM_SYSCOMMAND, SC_MINIMIZE, 0 );
-		    }
-
-		    if( wParam == VK_F10 )	/* try to maximize the window */
-		    {
-	                HWND top = GetTopParent();
-	                if ( GetWindowLongA(top, GWL_STYLE) & WS_MAXIMIZEBOX)
-	                    PostMessageW( top, WM_SYSCOMMAND, SC_MAXIMIZE, 0 );
-		    }
-            }
-
-	} 
-	else if( wParam == VK_F10 )
-	        iF10Key = 1;
-	     else
-	        if( wParam == VK_ESCAPE && (GetKeyState(VK_SHIFT) & 0x8000))
+                    PostMessageW( top, WM_SYSCOMMAND, SC_RESTORE, 0 );
+            }
+
+            if( wParam == VK_F7 )   /* size the window */
+            {
+                    HWND top = GetTopParent();
+                    PostMessageW( top, WM_SYSCOMMAND, SC_MOVE, 0 );
+            }
+
+            if( wParam == VK_F8 )   /* move the window */
+            {
+                    HWND top = GetTopParent();
+                    if ( GetWindowLongA(top, GWL_STYLE) & WS_SIZEBOX)
+                    PostMessageW( top, WM_SYSCOMMAND, SC_SIZE, 0 );
+            }
+
+            if( wParam == VK_F9 )   /* try to minimize the window */
+            {
+                    HWND top = GetTopParent();
+                    if ( GetWindowLongA(top, GWL_STYLE) & WS_MINIMIZEBOX)
+                        PostMessageW( top, WM_SYSCOMMAND, SC_MINIMIZE, 0 );
+            }
+
+            if( wParam == VK_F10 )  /* try to maximize the window */
+            {
+                    HWND top = GetTopParent();
+                    if ( GetWindowLongA(top, GWL_STYLE) & WS_MAXIMIZEBOX)
+                        PostMessageW( top, WM_SYSCOMMAND, SC_MAXIMIZE, 0 );
+            }
+            }
+
+    }
+    else if( wParam == VK_F10 )
+            iF10Key = 1;
+         else
+            if( wParam == VK_ESCAPE && (GetKeyState(VK_SHIFT) & 0x8000))
                     SendMessageW(getWindowHandle(), WM_SYSCOMMAND, SC_KEYMENU, VK_SPACE );
         return 0;
@@ -1979,9 +1978,9 @@
         // no break;
     case WM_SYSKEYUP:
-	/* Press and release F10 or ALT */
-	if (((wParam == VK_MENU) && iMenuSysKey) ||
+    /* Press and release F10 or ALT */
+    if (((wParam == VK_MENU) && iMenuSysKey) ||
             ((wParam == VK_F10) && iF10Key))
               ::SendMessageW( GetTopParent(), WM_SYSCOMMAND, SC_KEYMENU, 0L );
-	iMenuSysKey = iF10Key = 0;
+    iMenuSysKey = iF10Key = 0;
         break;
 
@@ -2020,8 +2019,8 @@
     case WM_RBUTTONUP:
         {
-	    POINT pt;
-	    pt.x = SLOWORD(lParam);
-	    pt.y = SHIWORD(lParam);
-	    ClientToScreen(getWindowHandle(), &pt);
+        POINT pt;
+        pt.x = SLOWORD(lParam);
+        pt.y = SHIWORD(lParam);
+        ClientToScreen(getWindowHandle(), &pt);
             SendMessageA( getWindowHandle(), WM_CONTEXTMENU, getWindowHandle(),MAKELPARAM(pt.x, pt.y) );
         }
@@ -2136,19 +2135,20 @@
     {
     case WM_GETTEXTLENGTH:
-        return windowNameLength;
+        return windowNameLengthW;
 
     case WM_GETTEXT:
-        if (!lParam || !wParam) 
+        if (!lParam || !wParam)
           return 0;
         if (!windowNameW)
           ((LPWSTR)lParam)[0] = 0;
-        else 
-          memcpy((LPSTR)lParam, windowNameW, min( sizeof(WCHAR) * (windowNameLength+1), wParam) );
-        return min(windowNameLength, wParam);
+        else
+          lstrcpynW(( LPWSTR )lParam, windowNameW, wParam );
+
+        return strlenW(( LPWSTR )lParam );
 
     case WM_SETTEXT:
     {
         LPWSTR lpsz = (LPWSTR)lParam;
-      
+
         // reallocate if new buffer is larger
         if (!lParam)
@@ -2156,5 +2156,6 @@
           free(windowNameA);
           free(windowNameW);
-          windowNameLength = 0;
+          windowNameLengthA = 0;
+          windowNameLengthW = 0;
           windowNameA      = NULL;
           windowNameW      = NULL;
@@ -2164,6 +2165,6 @@
           // determine length of new text
           int iTextLength = lstrlenW(lpsz);
-          
-          if (windowNameLength < iTextLength)
+
+          if (windowNameLengthW < iTextLength)
           {
             if (windowNameA)
@@ -2172,5 +2173,5 @@
               windowNameA = NULL;
             }
-          
+
             if (windowNameW)
             {
@@ -2179,15 +2180,16 @@
             }
           }
-      
-          windowNameLength = iTextLength;
+
+          windowNameLengthW = iTextLength;
           if(!windowNameW)
-            windowNameW = (LPWSTR)_smalloc((windowNameLength+1)*sizeof(WCHAR));
-          memcpy(windowNameW, lpsz, (windowNameLength+1) * sizeof(WCHAR));
+            windowNameW = (LPWSTR)_smalloc((windowNameLengthW+1)*sizeof(WCHAR));
+          strcpyW(windowNameW, lpsz);
+          windowNameLengthA = lstrlenWtoA( windowNameW, -1 );
           if(!windowNameA)
-            windowNameA = (LPSTR)_smalloc(windowNameLength+1);
-          lstrcpynWtoA(windowNameA, windowNameW, windowNameLength+1);
-        }
-
-        dprintf(("WM_SETTEXT of %x\n",Win32Hwnd));
+            windowNameA = (LPSTR)_smalloc( windowNameLengthA + 1 );
+          lstrcpyWtoA( windowNameA, windowNameW );
+        }
+
+        dprintf(("WM_SETTEXT of %x to %s\n", Win32Hwnd, windowNameA));
         if ((dwStyle & WS_CAPTION) == WS_CAPTION)
         {
@@ -2259,5 +2261,5 @@
         hWndIcon = windowClass->getIcon();
     else
-    if (!(dwStyle & DS_MODALFRAME)) 
+    if (!(dwStyle & DS_MODALFRAME))
     {//SvL: load it as shared or else we'll leak icons
          hWndIcon = LoadImageA(0,MAKEINTRESOURCEA(OIC_ODINICON),IMAGE_ICON,0,0,LR_DEFAULTCOLOR|LR_SHARED);
@@ -2279,5 +2281,5 @@
         hWndIcon = windowClass->getIcon();
     else
-    if (!(dwStyle & DS_MODALFRAME)) 
+    if (!(dwStyle & DS_MODALFRAME))
     {//SvL: load it as shared or else we'll leak icons
          hWndIcon = LoadImageA(0,MAKEINTRESOURCEA(OIC_ODINICON),IMAGE_ICON,0,0,LR_DEFAULTCOLOR|LR_SHARED);
@@ -2310,5 +2312,5 @@
         dprintf(("ShowWindow: GetProcessDword(0, GPD_STARTF_SHOWWINDOW) -> %x", nCmdShow));
     }
- 
+
 
     switch(nCmdShow)
@@ -2433,5 +2435,5 @@
 //******************************************************************************
 //******************************************************************************
-BOOL Win32BaseWindow::SetWindowPos(HWND hwndInsertAfter, int x, int y, int cx, 
+BOOL Win32BaseWindow::SetWindowPos(HWND hwndInsertAfter, int x, int y, int cx,
                                    int cy, UINT fuFlags, BOOL fShowWindow)
 {
@@ -2538,5 +2540,5 @@
         OSLibWinQueryWindowPos(OS2HwndFrame, &swpOld);
     }
-    if((dwOldStyle & WS_MINIMIZE) && (getStyle() & WS_MINIMIZE)) 
+    if((dwOldStyle & WS_MINIMIZE) && (getStyle() & WS_MINIMIZE))
     {//don't allow size changes if the window is minimized
      //we will update the restore position at the end of this method
@@ -2589,5 +2591,5 @@
     //SvL: Must also deactivate the window when hiding it or else focus won't
     //     change. (NOTE: make sure this doesn't cause regressions (01-02-2003)
-    if((swp.fl & (SWPOS_HIDE|SWPOS_DEACTIVATE)) == (SWPOS_HIDE|SWPOS_DEACTIVATE)) 
+    if((swp.fl & (SWPOS_HIDE|SWPOS_DEACTIVATE)) == (SWPOS_HIDE|SWPOS_DEACTIVATE))
     {
         //we must make sure the owner is not disabled or else the focus will
@@ -2687,5 +2689,5 @@
          wpos->y      = rectWindow.top;
     }
-   
+
     WINDOWPOS wpOld = *wpos;
     if(!(wpos->flags & SWP_NOSENDCHANGING))
@@ -2823,5 +2825,5 @@
         return FALSE;
     }
-  
+
     if(!(getStyle() & WS_CHILD) && getOwner() == NULL)
     {
@@ -2854,5 +2856,5 @@
     }
     dprintf(("DestroyWindow %x -> HIDDEN", hwnd));
-  
+
     // check the handle for the last active popup window
     Win32BaseWindow* owner = getOwner();
@@ -2870,9 +2872,9 @@
         //     (MFC created modeless dialog)
         //TODO: This might be the wrong place to do it. EndDialog is called,
-        //      so perhaps it should be done there. (although Wine only 
+        //      so perhaps it should be done there. (although Wine only
         //      enables the owner if the dialog is modal)
         ::EnableWindow(owner->getWindowHandle(), 1);
     }
-  
+
     fDestroyWindowCalled = TRUE;
 
@@ -2929,5 +2931,5 @@
   Win32BaseWindow *wndparent = (Win32BaseWindow *)ChildWindow::getParentOfChild();
 
-    if(getStyle() & WS_CHILD) 
+    if(getStyle() & WS_CHILD)
     {
         if(wndparent) {
@@ -2938,5 +2940,5 @@
         return 0;
     }
-    else 
+    else
     if(getStyle() & WS_POPUP)
          return (getOwner()) ? getOwner()->getWindowHandle() : 0;
@@ -3027,13 +3029,13 @@
     // in release build.
     Win32BaseWindow *_parent = getParent();
-    
-    if(_parent) 
+
+    if(_parent)
     {
         if(_parent->getWindowHandle() == hwndParent)
             return TRUE;
-    
+
         return _parent->IsChild(hwndParent);
     }
-    else 
+    else
         return 0;
 }
@@ -3208,5 +3210,5 @@
     dprintf(("EnumWindows %x %x", lpfn, lParam));
 
-    for(int i=0;i<MAX_WINDOW_HANDLES;i++) 
+    for(int i=0;i<MAX_WINDOW_HANDLES;i++)
     {
         window = Win32BaseWindow::GetWindowFromHandle(hwnd);
@@ -3440,9 +3442,9 @@
              if(window->state >= STATE_POST_WMNCCREATE) {
                  hwndRelated = window->getWindowHandle();
-                 RELEASE_WNDOBJ(window); 
+                 RELEASE_WNDOBJ(window);
              }
              else {
                  hwndRelated = window->GetWindow(GW_HWNDNEXT);
-                 RELEASE_WNDOBJ(window); 
+                 RELEASE_WNDOBJ(window);
              }
         }
@@ -3497,6 +3499,6 @@
 //******************************************************************************
 PRECT Win32BaseWindow::getWindowRect()
-{ 
-    return &rectWindow; 
+{
+    return &rectWindow;
 }
 //******************************************************************************
@@ -3668,5 +3670,5 @@
 {
     //if the destination window is created by this process, send message
-    if(dwProcessId == currentProcessId) 
+    if(dwProcessId == currentProcessId)
     {
         if(fUnicode) {
@@ -3677,5 +3679,5 @@
     //else get data directory from window structure
     //TODO: must lock window structure.... (TODO)
-    return windowNameLength;
+    return fUnicode ? windowNameLengthW : windowNameLengthA;
 }
 //******************************************************************************
@@ -3689,10 +3691,10 @@
         return SendMessageA(getWindowHandle(),WM_GETTEXT,(WPARAM)cch,(LPARAM)lpsz);
     }
-  
+
     //else get data directory from window structure
     if (!lpsz || !cch) return 0;
     if (!windowNameA) lpsz[0] = 0;
-    else memcpy(lpsz, windowNameA, min(windowNameLength + 1, cch) );
-    return min(windowNameLength, cch);
+    else lstrcpynA( lpsz, windowNameA, cch );
+    return strlen( lpsz );
 }
 //******************************************************************************
@@ -3707,12 +3709,12 @@
     }
     //else get data directory from window structure
-    if (!lpsz || !cch) 
+    if (!lpsz || !cch)
         return 0;
-    if (!windowNameW) 
+    if (!windowNameW)
         lpsz[0] = 0;
-    else 
-        memcpy(lpsz, windowNameW, min( sizeof(WCHAR) * (windowNameLength+1), cch));
-           
-    return min(windowNameLength, cch);
+    else
+        lstrcpynW( lpsz, windowNameW, cch );
+
+    return strlenW( lpsz );
 }
 //******************************************************************************
@@ -3751,5 +3753,5 @@
                 SendMessageA(getWindowHandle(),WM_STYLECHANGED,GWL_EXSTYLE,(LPARAM)&ss);
 
-                OSLibSetWindowStyle(getOS2FrameWindowHandle(), getOS2WindowHandle(), 
+                OSLibSetWindowStyle(getOS2FrameWindowHandle(), getOS2WindowHandle(),
                                     getStyle(), getExStyle(),ss.styleOld);
 
@@ -3760,5 +3762,5 @@
         {
                 STYLESTRUCT ss;
- 
+
                 //SvL: TODO: Can you change minimize or maximize status here too?
 
@@ -3768,5 +3770,5 @@
                 }
                 dprintf(("SetWindowLong GWL_STYLE %x old %x new style %x (%x)", getWindowHandle(), dwStyle, value));
-                
+
                 //Changing WS_CHILD style is allowed
                 ss.styleOld = getStyle();
@@ -3776,5 +3778,5 @@
                 SendMessageA(getWindowHandle(),WM_STYLECHANGED,GWL_STYLE,(LPARAM)&ss);
 
-                 OSLibSetWindowStyle(getOS2FrameWindowHandle(), getOS2WindowHandle(), 
+                 OSLibSetWindowStyle(getOS2FrameWindowHandle(), getOS2WindowHandle(),
                                     getStyle(), getExStyle(),ss.styleOld);
 
@@ -3941,15 +3943,15 @@
     switch(index)
     {
-    case GWW_ID:         
-    	if(HIWORD(getWindowId()))
+    case GWW_ID:
+        if(HIWORD(getWindowId()))
             dprintf(("WARNING: GWW_ID: discards high bits of 0x%08x!\n", getWindowId()));
         return (WORD)getWindowId();
 
-    case GWW_HWNDPARENT: 
+    case GWW_HWNDPARENT:
         dprintf(("WARNING: GWW_HWNDPARENT: discards high bits of 0x%08x!\n", GetParent()));
-    	return (WORD) GetParent();
-
-    case GWW_HINSTANCE:  
-    	if (HIWORD(hInstance))
+        return (WORD) GetParent();
+
+    case GWW_HINSTANCE:
+        if (HIWORD(hInstance))
             dprintf(("WARNING: GWW_HINSTANCE: discards high bits of 0x%08x!\n", hInstance));
         return (WORD)hInstance;
@@ -3969,5 +3971,5 @@
 //    VISRGN_NOTIFY_PROC lpNotifyProc    - notification handler
 //    DWORD              dwUserData      - caller supplied parameter for handler invocations
-// 
+//
 // Returns:
 //    TRUE              - Success
@@ -3989,5 +3991,5 @@
 // Parameters:
 //    BOOL   fDrawingAllowed    - drawing is allowed or not
-// 
+//
 // Returns:
 //    TRUE              - Success
@@ -3995,5 +3997,5 @@
 //
 //******************************************************************************
-void Win32BaseWindow::callVisibleRgnNotifyProc(BOOL fDrawingAllowed) 
+void Win32BaseWindow::callVisibleRgnNotifyProc(BOOL fDrawingAllowed)
 {
     if(fDrawingAllowed) {
@@ -4016,5 +4018,5 @@
 //    int  chdcWindow   - size of HDC array       (IN)
 //    int *pnrdcs       - number of HDCs returned (OUT)
-// 
+//
 // Returns:
 //    TRUE              - Success
@@ -4050,5 +4052,5 @@
 // Parameters:
 //    HDC hdc            - HDC to be added to our list of open DCs
-// 
+//
 // Returns:
 //
@@ -4083,5 +4085,5 @@
 // Parameters:
 //    HDC hdc            - HDC to be removed from our list of open DCs
-// 
+//
 // Returns:
 //
@@ -4141,5 +4143,5 @@
 {
  DWORD            magic;
- HWND             hwnd; 
+ HWND             hwnd;
 
     if(hwndOS2 == OSLIB_HWND_DESKTOP)
@@ -4157,5 +4159,5 @@
 //  dprintf2(("Win32BaseWindow::GetWindowFromOS2Handle: not an Odin os2 window %x", hwndOS2));
 
-    //Now check if it's a fake window 
+    //Now check if it's a fake window
     Win32FakeWindow *window = Win32FakeWindow::GetWindowFromOS2Handle(hwndOS2);
     if(window) {
Index: trunk/src/user32/win32wbase.h
===================================================================
--- trunk/src/user32/win32wbase.h	(revision 10189)
+++ trunk/src/user32/win32wbase.h	(revision 10190)
@@ -1,3 +1,3 @@
-/* $Id: win32wbase.h,v 1.154 2003-05-15 12:40:20 sandervl Exp $ */
+/* $Id: win32wbase.h,v 1.155 2003-07-31 15:56:47 sandervl Exp $ */
 /*
  * Win32 Window Base Class for OS/2
@@ -31,5 +31,5 @@
 #define NROF_WIN32WNDBYTES        16
 
-#define WINDOWFLAG_ACTIVE	  1
+#define WINDOWFLAG_ACTIVE     1
 
 #define WIN32PM_MAGIC             0x12345678
@@ -38,6 +38,6 @@
 #define MAX_OPENDCS               8
 
-#define TYPE_ASCII		  0
-#define TYPE_UNICODE		  1
+#define TYPE_ASCII        0
+#define TYPE_UNICODE          1
 
 #define GW_HWNDNEXTCHILD          (0x10000 | GW_HWNDNEXT)
@@ -101,5 +101,5 @@
 #define HAS_MENU() (!(getStyle() & WS_CHILD) && (getWindowId() != 0))
 
-#define STATE_INIT	         0   //initial state
+#define STATE_INIT           0   //initial state
 #define STATE_PRE_WMNCCREATE     1   //before WM_NCCREATE
 #define STATE_POST_WMNCCREATE    2   //after WM_NCCREATE
@@ -234,5 +234,5 @@
 
          void   saveAndValidateUpdateRegion();
-         void   checkForDirtyUpdateRegion();   
+         void   checkForDirtyUpdateRegion();
          BOOL   hasDirtUpdateRegion()             { return fDirtyUpdateRegion; };
 
@@ -276,6 +276,6 @@
 //hack alert (see DestroyWindow)
          BOOL   IsChildDestructionInProgress() { return fChildDestructionInProgress; };
-         void   SetChildDestructionInProgress(BOOL fDestuctionInProgress) 
-         { 
+         void   SetChildDestructionInProgress(BOOL fDestuctionInProgress)
+         {
              fChildDestructionInProgress = fDestuctionInProgress;
          };
@@ -310,5 +310,6 @@
          CHAR  *getWindowNameA()              { return windowNameA; }; //only for MDI windows!
          WCHAR *getWindowNameW()              { return windowNameW; }; //only for MDI windows!
-         int    getWindowNameLength()         { return windowNameLength; };
+         int    getWindowNameLengthA()        { return windowNameLengthA; };
+         int    getWindowNameLengthW()        { return windowNameLengthW; };
          Win32WndClass  *getClass()  { return windowClass; };
          Win32BaseWindow *getOwner() { return owner; };
@@ -338,14 +339,14 @@
 
 
-	 BOOL   isComingToTop()			{ return fComingToTop; };
-	 void   setComingToTop(BOOL fTop) 	{ fComingToTop = fTop; };
+     BOOL   isComingToTop()         { return fComingToTop; };
+     void   setComingToTop(BOOL fTop)   { fComingToTop = fTop; };
          BOOL   isInTasklist()                  { return fTaskList; };
 
          //window property methods
          HANDLE getProp(LPCSTR str);
-	 BOOL   setProp(LPCSTR str, HANDLE handle);
-	 HANDLE removeProp(LPCSTR str);
-	 INT    enumPropsExA(PROPENUMPROCEXA func, LPARAM lParam);
-	 INT    enumPropsExW(PROPENUMPROCEXW func, LPARAM lParam);
+     BOOL   setProp(LPCSTR str, HANDLE handle);
+     HANDLE removeProp(LPCSTR str);
+     INT    enumPropsExA(PROPENUMPROCEXA func, LPARAM lParam);
+     INT    enumPropsExW(PROPENUMPROCEXW func, LPARAM lParam);
 
 #ifdef DEBUG
@@ -391,5 +392,5 @@
         ULONG   userData;               //GWL_USERDATA
         HWND    hwndLastActive;         // last active popup handle
-  
+
         ULONG   cbExtra;
         PVOID   pExtra;
@@ -414,5 +415,5 @@
                  fCXDefault:1,
                  fParentDC:1,
-	         fComingToTop:1,
+             fComingToTop:1,
                  isUnicode:1,
                  fMinMaxChange:1,        //set when switching between min/max/restored state
@@ -440,6 +441,7 @@
         char   *windowNameA;
         WCHAR  *windowNameW;
-        int     windowNameLength;
-  
+        int     windowNameLengthA;
+        int     windowNameLengthW;
+
         char   *userWindowBytes;
         ULONG   nrUserWindowBytes;
@@ -455,5 +457,5 @@
 VISRGN_NOTIFY_PROC lpVisRgnNotifyProc;
         DWORD   dwVisRgnNotifyParam;
-       
+
         HANDLE  hTaskList; //PM specific (switchentry handle)
 
Index: trunk/src/user32/winaccel.cpp
===================================================================
--- trunk/src/user32/winaccel.cpp	(revision 10189)
+++ trunk/src/user32/winaccel.cpp	(revision 10190)
@@ -1,3 +1,3 @@
-/* $Id: winaccel.cpp,v 1.11 2003-04-02 12:58:02 sandervl Exp $ */
+/* $Id: winaccel.cpp,v 1.12 2003-07-31 15:56:47 sandervl Exp $ */
 /*
  * Win32 accelerator key functions for OS/2
@@ -18,5 +18,4 @@
 #include <misc.h>
 #include <heapstring.h>
-#include "win32wbase.h"
 #include <win\winnls.h>
 
@@ -24,192 +23,4 @@
 #include "dbglocal.h"
 
-/**********************************************************************
- *           KBD_translate_accelerator
- *
- * FIXME: should send some WM_INITMENU or/and WM_INITMENUPOPUP  -messages
- */
-static BOOL KBD_translate_accelerator(HWND hWnd,LPMSG msg,
-                                      BYTE fVirt,WORD key,WORD cmd)
-{
-    BOOL sendmsg = FALSE;
-
-    if(msg->wParam == key)
-    {
-        if (msg->message == WM_CHAR) {
-            if ( !(fVirt & FALT) && !(fVirt & FVIRTKEY) )
-            {
-                dprintf(("TranslateAccelerator: found accel for WM_CHAR: ('%c')\n", msg->wParam&0xff));
-                sendmsg=TRUE;
-            }
-        }
-        else
-        {
-            if(fVirt & FVIRTKEY) {
-                INT mask = 0;
-                if(GetKeyState(VK_SHIFT) & 0x8000) mask |= FSHIFT;
-                if(GetKeyState(VK_CONTROL) & 0x8000) mask |= FCONTROL;
-                if(GetKeyState(VK_MENU) & 0x8000) mask |= FALT;
-
-                if(mask == (fVirt & (FSHIFT | FCONTROL | FALT)))
-                        sendmsg=TRUE;
-                else    dprintf(("TranslateAccelerator: but incorrect SHIFT/CTRL/ALT-state %x != %x", mask, fVirt));
-            }
-            else
-            {
-                if (!(msg->lParam & 0x01000000))  /* no special_key */
-                {
-                    if ((fVirt & FALT) && (msg->lParam & 0x20000000))
-                    {                                                   /* ^^ ALT pressed */
-                        dprintf(("TranslateAccelerator: found accel for Alt-%c\n", msg->wParam&0xff));
-                        sendmsg=TRUE;
-                    }
-                }
-            }
-        }
-
-        if (sendmsg)      /* found an accelerator, but send a message... ? */
-        {
-            INT  iSysStat,iStat,mesg=0;
-            HMENU hMenu;
-
-            if (msg->message == WM_KEYUP || msg->message == WM_SYSKEYUP) {
-                mesg=1;
-            }
-            else
-                if (GetCapture())
-                    mesg=2;
-                else
-                if (!IsWindowEnabled(hWnd))
-                    mesg=3;
-                else
-                {
-                    Win32BaseWindow *window;
-
-                    window = Win32BaseWindow::GetWindowFromHandle(hWnd);
-                    if(!window) {
-                        return FALSE; //should never happen! (already checked)
-                    }
-
-                    hMenu = GetMenu(hWnd);
-
-                    iSysStat = (window->GetSysMenu()) ? GetMenuState(GetSubMenu(window->GetSysMenu(), 0),
-                                                                     cmd, MF_BYCOMMAND) : -1 ;
-                    iStat = (hMenu) ? GetMenuState(hMenu, cmd, MF_BYCOMMAND) : -1 ;
-
-                    if (iSysStat!=-1)
-                    {
-                        if (iSysStat & (MF_DISABLED|MF_GRAYED))
-                            mesg=4;
-                        else
-                            mesg=WM_SYSCOMMAND;
-                    }
-                    else
-                    {
-                        if (iStat!=-1)
-                        {
-                            if (IsIconic(hWnd)) {
-                                mesg=5;
-                            }
-                            else
-                            {
-                                if (iStat & (MF_DISABLED|MF_GRAYED))
-                                    mesg=6;
-                                else
-                                    mesg=WM_COMMAND;
-                            }
-                        }
-                        else
-                            mesg=WM_COMMAND;
-                    }
-                    RELEASE_WNDOBJ(window);
-                }
-                if ( mesg==WM_COMMAND || mesg==WM_SYSCOMMAND )
-                {
-                    SendMessageA(hWnd, mesg, cmd, 0x00010000L);
-                }
-                else
-                {
-                    /*  some reasons for NOT sending the WM_{SYS}COMMAND message:
-                     *   #0: unknown (please report!)
-                     *   #1: for WM_KEYUP,WM_SYSKEYUP
-                     *   #2: mouse is captured
-                     *   #3: window is disabled
-                     *   #4: it's a disabled system menu option
-                     *   #5: it's a menu option, but window is iconic
-                     *   #6: it's a menu option, but disabled
-                     */
-                    if(mesg==0)
-                            dprintf(("ERROR: unknown reason - please report!"));
-                    else    dprintf(("but won't send WM_{SYS}COMMAND, reason is #%d\n",mesg));
-
-                }
-                return TRUE;
-            }
-            dprintf(("TranslateAccelerator: not match for %x %x %x", fVirt, key, cmd));
-    }
-    return FALSE;
-}
-/*****************************************************************************
- * Name      : int WIN32API TranslateAcceleratorA
- * Purpose   : Translate WM_*KEYDOWN messages to WM_COMMAND messages
- *             according to Accelerator table
- * Parameters: HWND hwnd, HACCEL haccel, LPMSG lpmsg
- * Variables :
- * Result    : int FALSE (no accelerator found) TRUE (accelerator found)
- * Remark    : if a accelerator is found it is not neccesarely executed
- *             depends on window stat
- *
- *****************************************************************************/
-INT WINAPI TranslateAcceleratorA(HWND hWnd, HACCEL hAccel, LPMSG msg)
-{
-    /* YES, Accel16! */
-    LPACCEL lpAccelTbl;
-    int i;
-
-    SetLastError(ERROR_SUCCESS);
-    if (msg == NULL)
-    {
-          dprintf(("TranslateAcceleratorAmsg null; should hang here to be win compatible"));
-          SetLastError(ERROR_INVALID_PARAMETER);
-          return 0;
-    }
-    if (!hAccel || !(lpAccelTbl = (LPACCEL)GlobalLock(hAccel)))
-    {
-          dprintf(("TranslateAcceleratorA: invalid accel handle=%x", hAccel));
-          SetLastError(ERROR_INVALID_PARAMETER);
-          return 0;
-    }
-    if(!IsWindow(hWnd)) {
-          dprintf(("TranslateAccelerator, window %x not found", hWnd));
-          SetLastError(ERROR_INVALID_WINDOW_HANDLE);
-          return 0;
-    }
-    if ((msg->message != WM_KEYDOWN &&
-         msg->message != WM_KEYUP &&
-         msg->message != WM_SYSKEYDOWN &&
-         msg->message != WM_SYSKEYUP &&
-         msg->message != WM_CHAR))
-    {
-          return 0;
-    }
-
-/*    TRACE_(accel)("TranslateAccelerators hAccel=%04x, hWnd=%04x,"
-      "msg->hwnd=%04x, msg->message=%04x, wParam=%08x, lParam=%lx\n",
-      hAccel,hWnd,msg->hwnd,msg->message,msg->wParam,msg->lParam); */
-
-    i = 0;
-    do
-    {
-        if (KBD_translate_accelerator(hWnd,msg,lpAccelTbl[i].fVirt,
-                                      lpAccelTbl[i].key,lpAccelTbl[i].cmd))
-        {
-            return 1;
-        }
-    }
-    while ((lpAccelTbl[i++].fVirt & 0x80) == 0);
-
-//    WARN_(accel)("couldn't translate accelerator key\n");
-    return 0;
-}
 /**********************************************************************
  *			LoadAccelerators32W	[USER.177]
Index: trunk/src/user32/windowmsg.cpp
===================================================================
--- trunk/src/user32/windowmsg.cpp	(revision 10189)
+++ trunk/src/user32/windowmsg.cpp	(revision 10190)
@@ -1,3 +1,3 @@
-/* $Id: windowmsg.cpp,v 1.43 2003-07-28 11:27:50 sandervl Exp $ */
+/* $Id: windowmsg.cpp,v 1.44 2003-07-31 15:56:47 sandervl Exp $ */
 /*
  * Win32 window message APIs for OS/2
@@ -86,5 +86,5 @@
                 return 0; /* invalid winproc */
 
-	    return CallWindowProcA( (WNDPROC)msg->lParam, msg->hwnd,
+	    return CallWindowProcW( (WNDPROC)msg->lParam, msg->hwnd,
                                    msg->message, msg->wParam, GetTickCount() );
         }
@@ -319,4 +319,5 @@
     {
     case WM_GETTEXT:
+    case WM_ASKCBFORMATNAME:
         {
             LPARAM *ptr = (LPARAM *)HeapAlloc( GetProcessHeap(), 0,
@@ -330,4 +331,5 @@
     case WM_SETTEXT:
     case WM_WININICHANGE:
+    case WM_DEVMODECHANGE:
     case CB_DIR:
     case LB_DIR:
@@ -431,16 +433,19 @@
         return 1;
 
-    /* kso 2003-07-03: to make password field work, I took this from latest wine code. (winproc.c) */
+    case WM_CHARTOITEM:
+    case WM_MENUCHAR:
+    case WM_CHAR:
+    case WM_DEADCHAR:
+    case WM_SYSCHAR:
+    case WM_SYSDEADCHAR:
     case EM_SETPASSWORDCHAR:
         {
-            BYTE    ch = LOWORD(*pwparam);
-            WCHAR   wch = 0;
-            MultiByteToWideChar(CP_ACP, 0, (LPCSTR)&ch, 1, &wch, 1);
+            char ch = LOWORD(*pwparam);
+            WCHAR wch;
+            MultiByteToWideChar(CP_ACP, 0, &ch, 1, &wch, 1);
             *pwparam = MAKEWPARAM( wch, HIWORD(*pwparam) );
         }
         return 0;
 
-    case WM_ASKCBFORMATNAME:
-    case WM_DEVMODECHANGE:
     case WM_PAINTCLIPBOARD:
     case WM_SIZECLIPBOARD:
@@ -463,4 +468,5 @@
     {
     case WM_GETTEXT:
+    case WM_ASKCBFORMATNAME:
         {
             LPARAM *ptr = (LPARAM *)lParam - 1;
@@ -495,4 +501,5 @@
     case WM_SETTEXT:
     case WM_WININICHANGE:
+    case WM_DEVMODECHANGE:
     case CB_DIR:
     case LB_DIR:
@@ -569,11 +576,15 @@
  * Return value is -1 on error, 0 if OK, 1 if an UnmapMsg call is needed.
  */
-INT WINPROC_MapMsg32WTo32A( HWND hwnd, UINT msg, WPARAM wParam, LPARAM *plparam)
+INT WINPROC_MapMsg32WTo32A( HWND hwnd, UINT msg, WPARAM *pwparam, LPARAM *plparam)
 {   switch(msg)
     {
     case WM_GETTEXT:
-        {
+    case WM_ASKCBFORMATNAME:
+        {
+#ifdef __WIN32OS2__
+            *pwparam = *pwparam * sizeof( WCHAR );  //DBCS
+#endif
             LPARAM *ptr = (LPARAM *)HeapAlloc( GetProcessHeap(), 0,
-                                               wParam + sizeof(LPARAM) );
+                                               *pwparam + sizeof(LPARAM) );
             if (!ptr) return -1;
             *ptr++ = *plparam;  /* Store previous lParam */
@@ -584,4 +595,5 @@
     case WM_SETTEXT:
     case WM_WININICHANGE:
+    case WM_DEVMODECHANGE:
     case CB_DIR:
     case LB_DIR:
@@ -681,14 +693,30 @@
           if (!ptr) return -1;
           *ptr++ = *plparam;  /* Store previous lParam */
+#ifdef __WIN32OS2__
+          *((WORD *) ptr) = len * sizeof(WCHAR);   /* Store the length */
+#else
           *((WORD *) ptr) = len;   /* Store the length */
+#endif
           *plparam = (LPARAM)ptr;
         }
         return 1;
 
-    case WM_ASKCBFORMATNAME:
-    case WM_DEVMODECHANGE:
+    case WM_CHARTOITEM:
+    case WM_MENUCHAR:
+    case WM_CHAR:
+    case WM_DEADCHAR:
+    case WM_SYSCHAR:
+    case WM_SYSDEADCHAR:
+    case EM_SETPASSWORDCHAR:
+        {
+            WCHAR wch = LOWORD(*pwparam);
+            char ch;
+            WideCharToMultiByte( CP_ACP, 0, &wch, 1, &ch, 1, NULL, NULL );
+            *pwparam = MAKEWPARAM( ch, HIWORD(*pwparam) );
+        }
+        return 0;
+
     case WM_PAINTCLIPBOARD:
     case WM_SIZECLIPBOARD:
-    case EM_SETPASSWORDCHAR:
         // FIXME_(msg)("message %s (%04x) needs translation, please report\n",SPY_GetMsgName(msg),msg );
         return -1;
@@ -709,6 +737,11 @@
     {
     case WM_GETTEXT:
+    case WM_ASKCBFORMATNAME:
         {
             LPARAM *ptr = (LPARAM *)lParam - 1;
+
+#ifdef __WIN32OS2__
+            wParam = wParam / sizeof( WCHAR );
+#endif
             lstrcpynAtoW( (LPWSTR)*ptr, (LPSTR)lParam, wParam );
             HeapFree( GetProcessHeap(), 0, ptr );
@@ -718,4 +751,5 @@
     case WM_SETTEXT:
     case WM_WININICHANGE:
+    case WM_DEVMODECHANGE:
     case CB_DIR:
     case LB_DIR:
@@ -800,5 +834,9 @@
     case EM_GETLINE:
         { LPARAM * ptr = (LPARAM *)lParam - 1;  /* get the old lparam */
+#ifdef __WIN32OS2__
+          WORD len = *(WORD *)ptr/sizeof(WCHAR);
+#else
           WORD len = *(WORD *)ptr;
+#endif
           lstrcpynAtoW( (LPWSTR) *ptr, (LPSTR)lParam, len );
           HeapFree( GetProcessHeap(), 0, ptr );
@@ -819,7 +857,68 @@
     LRESULT result;
 
+#ifdef __WIN32OS2__
+    if( IsDBCSEnv() && msg == WM_CHAR )
+    {
+        static BYTE dbcsLead = 0;
+        WCHAR charA = wParam;
+        int size = dbcsLead ? 2 : 1;
+
+        if( dbcsLead )
+               charA = ( charA << 8 ) | dbcsLead;
+        else if( IsDBCSLeadByte( wParam ))
+        {
+            dbcsLead = wParam;
+            return 0;
+        }
+        MultiByteToWideChar( CP_ACP, 0, ( LPSTR )&charA, size, ( LPWSTR )&wParam, 1 );
+
+        dbcsLead = 0;
+    }
+    else
+#endif
     if (WINPROC_MapMsg32ATo32W( hwnd, msg, &wParam, &lParam ) == -1) return 0;
+
     result = func( hwnd, msg, wParam, lParam );
     WINPROC_UnmapMsg32ATo32W( hwnd, msg, wParam, lParam );
+
+#ifdef __WIN32OS2__
+    if(IsDBCSEnv()) 
+    {
+      switch( msg )
+      {
+        case WM_GETTEXTLENGTH :
+        {
+            LPWSTR ustr = ( LPWSTR )HeapAlloc( GetProcessHeap(), 0, ( result + 1 ) * sizeof( WCHAR ));
+            result = func( hwnd, WM_GETTEXT, ( WPARAM )( result + 1 ), ( LPARAM )ustr );
+            result = lstrlenWtoA( ustr, result );
+            HeapFree( GetProcessHeap(), 0, ustr );
+            break;
+        }
+
+        case LB_GETTEXTLEN :
+        {
+            LPWSTR ustr = ( LPWSTR )HeapAlloc( GetProcessHeap(), 0, ( result + 1 ) * sizeof( WCHAR ));
+            result = func( hwnd, LB_GETTEXT, wParam, ( LPARAM )ustr );
+            if( result != LB_ERR )
+                result = lstrlenWtoA( ustr, result );
+
+            HeapFree( GetProcessHeap(), 0, ustr );
+            break;
+        }
+
+
+        case CB_GETLBTEXTLEN :
+        {
+            LPWSTR ustr = ( LPWSTR )HeapAlloc( GetProcessHeap(), 0, ( result + 1 ) * sizeof( WCHAR ));
+            result = func( hwnd, CB_GETLBTEXT, wParam, ( LPARAM )ustr );
+            if( result != CB_ERR )
+                result = lstrlenWtoA( ustr, result );
+
+            HeapFree( GetProcessHeap(), 0, ustr );
+            break;
+        }
+      }
+    }
+#endif
     return result;
 }
@@ -836,8 +935,63 @@
     LRESULT result;
 
-    if (WINPROC_MapMsg32WTo32A( hwnd, msg, wParam, &lParam ) == -1) return 0;
+#ifdef __WIN32OS2__
+    if( IsDBCSEnv() && msg == WM_CHAR )
+    {
+        char charA[ 2 ];
+
+        if( WideCharToMultiByte( CP_ACP, 0, ( LPWSTR )&wParam, 1, ( LPSTR )charA, 2, 0, 0 ) > 1 )
+        {
+            func( hwnd, msg, ( WPARAM )charA[ 0 ], lParam );
+            wParam = charA[ 1 ];
+        }
+        else
+            wParam = charA[ 0 ];
+    }
+    else
+#endif
+    if (WINPROC_MapMsg32WTo32A( hwnd, msg, &wParam, &lParam ) == -1) return 0;
 
     result = func( hwnd, msg, wParam, lParam );
     WINPROC_UnmapMsg32WTo32A( hwnd, msg, wParam, lParam );
+
+#ifdef __WIN32OS2__
+    if( IsDBCSEnv() )
+    {
+      switch( msg )
+      {
+        case WM_GETTEXTLENGTH :
+        {
+            LPSTR astr = ( LPSTR )HeapAlloc( GetProcessHeap(), 0, result + 1 );
+            result = func( hwnd, WM_GETTEXT, ( WPARAM )( result + 1 ), ( LPARAM )astr );
+            result = lstrlenAtoW( astr, result );
+            HeapFree( GetProcessHeap(), 0, astr );
+            break;
+        }
+
+        case LB_GETTEXTLEN :
+        {
+            LPSTR astr = ( LPSTR )HeapAlloc( GetProcessHeap(), 0, result + 1 );
+            result = func( hwnd, LB_GETTEXT, wParam, ( LPARAM )astr );
+            if( result != LB_ERR )
+                result = lstrlenAtoW( astr, result );
+
+            HeapFree( GetProcessHeap(), 0, astr );
+            break;
+        }
+
+
+        case CB_GETLBTEXTLEN :
+        {
+            LPSTR astr = ( LPSTR )HeapAlloc( GetProcessHeap(), 0, result + 1 );
+            result = func( hwnd, CB_GETLBTEXT, wParam, ( LPARAM )astr );
+            if( result != CB_ERR )
+                result = lstrlenAtoW( astr, result );
+
+            HeapFree( GetProcessHeap(), 0, astr );
+            break;
+        }
+      }
+    }
+#endif
     return result;
 }
Index: trunk/src/user32/winkeyboard.cpp
===================================================================
--- trunk/src/user32/winkeyboard.cpp	(revision 10189)
+++ trunk/src/user32/winkeyboard.cpp	(revision 10190)
@@ -1,3 +1,3 @@
-/* $Id: winkeyboard.cpp,v 1.42 2003-04-02 12:58:02 sandervl Exp $ */
+/* $Id: winkeyboard.cpp,v 1.43 2003-07-31 15:56:48 sandervl Exp $ */
 /*
  * Win32 <-> PM key translation
@@ -1056,6 +1056,7 @@
 BOOL WIN32API SetKeyboardState(PBYTE lpKeyState)
 {
-  dprintf(("USER32: SetKeyboardState %x not implemented", lpKeyState));
-  return(TRUE);
+   dprintf(("USER32: SetKeyboardState %x not implemented", lpKeyState));
+
+   return(TRUE);
 }
 /***********************************************************************
@@ -1204,8 +1205,17 @@
        if(lpbKeyState[VK_LSHIFT]   & 0x80) shiftstate |= TCF_LSHIFT;
        if(lpbKeyState[VK_RSHIFT]   & 0x80) shiftstate |= TCF_RSHIFT;
+       else
+       if(lpbKeyState[VK_SHIFT]    & 0x80) shiftstate |= TCF_LSHIFT;
+
        if(lpbKeyState[VK_LCONTROL] & 0x80) shiftstate |= TCF_LCONTROL;
        if(lpbKeyState[VK_RCONTROL] & 0x80) shiftstate |= TCF_RCONTROL;
+       else
+       if(lpbKeyState[VK_CONTROL]  & 0x80) shiftstate |= TCF_LCONTROL;
+
        if(lpbKeyState[VK_LMENU]    & 0x80) shiftstate |= TCF_ALT;
        if(lpbKeyState[VK_RMENU]    & 0x80) shiftstate |= TCF_ALTGR;
+       else
+       if(lpbKeyState[VK_MENU]     & 0x80) shiftstate |= TCF_ALT;
+
        if(lpbKeyState[VK_CAPITAL]  & 1)    shiftstate |= TCF_CAPSLOCK;
        if(lpbKeyState[VK_NUMLOCK]  & 1)    shiftstate |= TCF_NUMLOCK;
@@ -1615,4 +1625,21 @@
     break;
 
+    case 0:
+    {
+      UINT ret;
+      if( uCode >= VK_A && uCode <= VK_Z) {
+           ret = OSLibWinTranslateChar('A' + uCode - VK_A, TC_CHARTOSCANCODE, 0);  
+           dprintf(("MapVirtualKeyA %x (%c) -> %x", uCode, 'A' + uCode - VK_A, ret));
+           return ret;
+      }
+      else
+      if( uCode >= VK_0 && uCode <= VK_0) {
+           ret = OSLibWinTranslateChar('0' + uCode - VK_0, TC_CHARTOSCANCODE, 0);  
+           dprintf(("MapVirtualKeyA %x (%c) -> %x", uCode, '0' + uCode - VK_0, ret));
+           return ret;
+      }
+      break;
+    }
+
     case 1:
     case 3:
