Index: trunk/src/user32/edit.cpp
===================================================================
--- trunk/src/user32/edit.cpp	(revision 2849)
+++ trunk/src/user32/edit.cpp	(revision 2852)
@@ -1,3 +1,3 @@
-/* $Id: edit.cpp,v 1.34 2000-02-20 18:28:31 cbratschi Exp $ */
+/* $Id: edit.cpp,v 1.35 2000-02-21 17:25:26 cbratschi Exp $ */
 /*
  *      Edit control
@@ -9,4 +9,5 @@
  *      Copyright  1999 Christoph Bratschi
  *
+ * Corel version: 20000212
  * WINE version: 991212
  *
@@ -257,5 +258,5 @@
 static void     EDIT_WM_Timer(HWND hwnd, EDITSTATE *es, INT id, TIMERPROC timer_proc);
 static LRESULT  EDIT_WM_VScroll(HWND hwnd, EDITSTATE *es, INT action, INT pos, HWND scroll_bar);
-
+static LRESULT EDIT_WM_MouseWheel(HWND hwnd,EDITSTATE *es,WPARAM wParam,LPARAM lParam);
 
 /*********************************************************************
@@ -290,4 +291,8 @@
 {
         EDIT_EM_ReplaceSel(hwnd, es, TRUE, "");
+       	if (es->flags & EF_UPDATE) {
+          	es->flags &= ~EF_UPDATE;
+	        EDIT_NOTIFY_PARENT(hwnd, EN_CHANGE);
+        }
 }
 
@@ -693,5 +698,4 @@
                  */
                 //DPRINTF_EDIT_MSG32("WM_MOUSEACTIVATE");
-                SetFocus(hwnd);
                 result = MA_ACTIVATE;
                 break;
@@ -748,4 +752,8 @@
                 //DPRINTF_EDIT_MSG32("WM_VSCROLL");
                 result = EDIT_WM_VScroll(hwnd, es, LOWORD(wParam), SHIWORD(wParam), (HWND)(lParam));
+                break;
+
+        case WM_MOUSEWHEEL:
+                result = EDIT_WM_MouseWheel(hwnd,es,wParam,lParam);
                 break;
 
@@ -2436,5 +2444,5 @@
         es->flags |= EF_UPDATE;
         EDIT_EM_ScrollCaret(hwnd, es);
-        EDIT_NOTIFY_PARENT(hwnd,EN_UPDATE);
+
         /* FIXME: really inefficient */
         EDIT_Refresh(hwnd,es,TRUE);
@@ -2875,4 +2883,9 @@
         //                es->undo_insert_count, es->undo_text);
 
+	if (es->flags & EF_UPDATE) {
+		es->flags &= ~EF_UPDATE;
+		EDIT_NOTIFY_PARENT(hwnd, EN_CHANGE);
+	}
+
         return TRUE;
 }
@@ -2917,10 +2930,22 @@
                                 EDIT_MoveDown_ML(hwnd, es, FALSE);
                         } else
+                        {
                                 EDIT_EM_ReplaceSel(hwnd, es, TRUE, "\r\n");
+				if (es->flags & EF_UPDATE) {
+					es->flags &= ~EF_UPDATE;
+   					EDIT_NOTIFY_PARENT(hwnd, EN_CHANGE);
+                                }
+                        }
                 }
                 break;
         case '\t':
                 if ((es->style & ES_MULTILINE) && !(es->style & ES_READONLY))
+                {
                         EDIT_EM_ReplaceSel(hwnd, es, TRUE, "\t");
+			if (es->flags & EF_UPDATE) {
+				es->flags &= ~EF_UPDATE;
+				EDIT_NOTIFY_PARENT(hwnd, EN_CHANGE);
+			}
+                }
                 break;
         case VK_BACK:
@@ -2936,4 +2961,15 @@
                 }
                 break;
+//CB: are these three keys documented or Linux style???
+	case 0x03: /* ^C */
+		SendMessageA(hwnd, WM_COPY, 0, 0);
+		break;
+	case 0x16: /* ^V */
+		SendMessageA(hwnd, WM_PASTE, 0, 0);
+		break;
+	case 0x18: /* ^X */
+		SendMessageA(hwnd, WM_CUT, 0, 0);
+		break;
+
         default:
                 if (!(es->style & ES_READONLY) && ((BYTE)c >= ' ') && (c != 127))
@@ -2949,4 +2985,9 @@
                   str[1] = '\0';
                   EDIT_EM_ReplaceSel(hwnd, es, TRUE, str);
+                  if (es->flags & EF_UPDATE)
+                  {
+                    es->flags &= ~EF_UPDATE;
+                    EDIT_NOTIFY_PARENT(hwnd, EN_CHANGE);
+                  }
                 } else MessageBeep(MB_ICONEXCLAMATION);
                 break;
@@ -3085,4 +3126,8 @@
            es->selection_start = es->selection_end = 0;
            EDIT_EM_ScrollCaret(hwnd, es);
+	   if (es->flags & EF_UPDATE) {
+		es->flags &= ~EF_UPDATE;
+		EDIT_NOTIFY_PARENT(hwnd, EN_CHANGE);
+	   }
        }
        return 0;
@@ -3097,4 +3142,7 @@
 static void EDIT_WM_Destroy(HWND hwnd, EDITSTATE *es)
 {
+        if (!es) /* Protect against multiple destroy messages */
+	    return;
+
         if (es->hloc) {
                 while (LocalUnlock(es->hloc)) ;
@@ -3311,6 +3359,28 @@
         HWND hLBox;
 
+	/********************************************************************
+	 * This if statement used to check to see if the parent of the
+	 * edit control was a 'combobox' by comparing the ATOM of the parent
+	 * to a table of internal window control ATOMs.  However, this check
+	 * would fail if the parent was a superclassed combobox (Although
+	 * having the same basic functionality of a combobox, it has a
+	 * different name and ATOM, thus defeating this check.)
+	 *
+	 * The safe way to determine if the parent is a combobox is to send it
+	 * a message only a combo box would understand.  I send it a message
+	 * CB_GETCOUNT, if I get 0 then the parent is not a combobox -
+         * return FALSE.  If I get > 0, then the parent IS a combobox
+         * (or sub/super classed derrivative thereof)
+	 ********************************************************************/
+#if 0 //CB: our code
         if (GetClassWord(GetParent(hwnd),GCW_ATOM) ==  GlobalFindAtomA(COMBOBOXCLASSNAME) &&
-                        (hLBox = COMBO_GetLBWindow(GetParent(hwnd)))) {
+                        (hLBox = COMBO_GetLBWindow(GetParent(hwnd))))
+#else	
+        if (
+             ((SendMessageA(GetParent(hwnd), CB_GETCOUNT, 0, 0)) > 0) &&
+             (hLBox = COMBO_GetLBWindow(GetParent(hwnd)))
+           )
+#endif
+        {
                 HWND hCombo = GetParent(hwnd);
                 BOOL bUIFlip = TRUE;
@@ -3521,5 +3591,5 @@
 
         if (!(es->flags & EF_FOCUSED))
-                return 0;
+          SetFocus(hwnd);
 
         es->bCaptureState = TRUE;
@@ -3759,17 +3829,17 @@
 
   ShowCaret(hwnd);
+}
+
+static VOID EDIT_Refresh(HWND hwnd,EDITSTATE *es,BOOL useCache)
+{
+  HDC hdc,hdcCompatible;
+  HBITMAP bitmap,oldbmp;
+  RECT rect;
 
   if (es->flags & EF_UPDATE)
   {
     es->flags &= ~EF_UPDATE;
-    EDIT_NOTIFY_PARENT(hwnd, EN_CHANGE);
+    EDIT_NOTIFY_PARENT(hwnd,EN_UPDATE);
   }
-}
-
-static VOID EDIT_Refresh(HWND hwnd,EDITSTATE *es,BOOL useCache)
-{
-  HDC hdc,hdcCompatible;
-  HBITMAP bitmap,oldbmp;
-  RECT rect;
 
   if (!IsWindowVisible(hwnd)) return;
@@ -3833,4 +3903,9 @@
                 EDIT_EM_ReplaceSel(hwnd, es, TRUE, src);
                 GlobalUnlock(hsrc);
+
+		if (es->flags & EF_UPDATE) {
+			es->flags &= ~EF_UPDATE;
+			EDIT_NOTIFY_PARENT(hwnd, EN_CHANGE);
+		}
         }
         CloseClipboard();
@@ -3923,5 +3998,9 @@
 static void EDIT_WM_SetText(HWND hwnd, EDITSTATE *es, LPCSTR text)
 {
-        EDIT_EM_SetSel(hwnd, es, 0, -1, FALSE);
+        es->selection_start = 0;
+        es->selection_end = lstrlenA(es->text);
+        if (es->flags & EF_FOCUSED)
+          EDIT_SetCaretPos(hwnd, es, es->selection_end, FALSE);
+
         if (text) {
                 //TRACE_(edit)("\t'%s'\n", text);
@@ -3941,5 +4020,14 @@
         EDIT_EM_ScrollCaret(hwnd, es);
         EDIT_UpdateScrollBars(hwnd,es,TRUE,TRUE);
-        if (es->flags & EF_UPDATE) EDIT_NOTIFY_PARENT(hwnd,EN_UPDATE);
+        if (es->flags & EF_UPDATE)
+        {
+          EDIT_NOTIFY_PARENT(hwnd,EN_UPDATE);
+          /* EN_CHANGE notification need to be sent too
+             Windows doc says it's only done after the display,
+             the doc is WRONG. EN_CHANGE notification is sent
+             while processing WM_SETTEXT */
+          EDIT_NOTIFY_PARENT(hwnd, EN_CHANGE);
+          es->flags &= EF_UPDATE;
+        }
 }
 
@@ -4117,4 +4205,24 @@
 }
 
+static LRESULT EDIT_WM_MouseWheel(HWND hwnd,EDITSTATE *es,WPARAM wParam,LPARAM lParam)
+{
+  short gcWheelDelta = 0;
+  UINT pulScrollLines = 3;
+  SystemParametersInfoW(SPI_GETWHEELSCROLLLINES,0, &pulScrollLines, 0);
+
+  if (wParam & (MK_SHIFT | MK_CONTROL))
+    return DefWindowProcA(hwnd,WM_MOUSEWHEEL, wParam, lParam);
+  gcWheelDelta -= (short) HIWORD(wParam);
+  if (abs(gcWheelDelta) >= WHEEL_DELTA && pulScrollLines)
+  {
+    int cLineScroll= (int) min((UINT) es->line_count, pulScrollLines);
+
+    cLineScroll *= (gcWheelDelta / WHEEL_DELTA);
+    return EDIT_EM_LineScroll(hwnd, es, 0, cLineScroll);
+  }
+
+  return 0;
+}
+
 BOOL EDIT_Register()
 {
Index: trunk/src/user32/listbox.cpp
===================================================================
--- trunk/src/user32/listbox.cpp	(revision 2849)
+++ trunk/src/user32/listbox.cpp	(revision 2852)
@@ -1,3 +1,3 @@
-/* $Id: listbox.cpp,v 1.19 2000-02-16 14:34:20 sandervl Exp $ */
+/* $Id: listbox.cpp,v 1.20 2000-02-21 17:25:27 cbratschi Exp $ */
 /*
  * Listbox controls
@@ -6,4 +6,5 @@
  * Copyright 1999 Christoph Bratschi (ported from WINE)
  *
+ * Corel version: 20000212
  * WINE version: 991212
  */
@@ -18,5 +19,5 @@
 #include <misc.h>
 
-#define DBG_LOCALLOG	DBG_listbox
+#define DBG_LOCALLOG    DBG_listbox
 #include "dbglocal.h"
 
@@ -81,4 +82,5 @@
     BOOL        caret_on;       /* Is caret on? */
     BOOL        captured;       /* Is mouse captured? */
+    BOOL        in_focus;
     HFONT       font;           /* Current font */
     LCID          locale;         /* Current locale for string comparisons */
@@ -172,5 +174,11 @@
     SCROLLINFO info;
 
-    if (!(descr->style & WS_VSCROLL)) return;
+    /* Check the listbox scroll bar flags individually before we call
+       SetScrollInfo otherwise when the listbox style is WS_HSCROLL and
+       no WS_VSCROLL, we end up with an uninitialized, visible horizontal
+       scroll bar when we do not need one.
+              if (!(descr->style & WS_VSCROLL)) return;
+          */
+
     /*   It is important that we check descr->style, and not wnd->dwStyle,
        for WS_VSCROLL, as the former is exactly the one passed in
@@ -194,8 +202,10 @@
         if (descr->style & LBS_DISABLENOSCROLL)
             info.fMask |= SIF_DISABLENOSCROLL;
-        SetScrollInfo( hwnd, SB_HORZ, &info, TRUE );
+        if (descr->style & WS_HSCROLL)
+          SetScrollInfo( hwnd, SB_HORZ, &info, TRUE );
         info.nMax = 0;
         info.fMask = SIF_RANGE;
-        SetScrollInfo( hwnd, SB_VERT, &info, TRUE );
+        if (descr->style & WS_VSCROLL)
+          SetScrollInfo( hwnd, SB_VERT, &info, TRUE );
     }
     else
@@ -208,6 +218,6 @@
         if (descr->style & LBS_DISABLENOSCROLL)
             info.fMask |= SIF_DISABLENOSCROLL;
-
-        SetScrollInfo( hwnd, SB_VERT, &info, TRUE );
+        if (descr->style & WS_VSCROLL)
+          SetScrollInfo( hwnd, SB_VERT, &info, TRUE );
 
         if (descr->horz_extent)
@@ -220,5 +230,6 @@
             if (descr->style & LBS_DISABLENOSCROLL)
                 info.fMask |= SIF_DISABLENOSCROLL;
-            SetScrollInfo( hwnd, SB_HORZ, &info, TRUE );
+            if (descr->style & WS_HSCROLL)
+              SetScrollInfo( hwnd, SB_HORZ, &info, TRUE );
         }
     }
@@ -314,7 +325,7 @@
 
     GetWindowRect( hwnd, &rectWindow );
-    OffsetRect(&rectWindow, -rectWindow.left, -rectWindow.top);
     GetClientRect( hwnd, &rect );
 
+    //CB: todo: doesn't works in ShellAbout dialog
     descr->width  = rect.right - rect.left;
     descr->height = rect.bottom - rect.top;
@@ -479,5 +490,5 @@
         if ((descr->focus_item == index) &&
             (descr->caret_on) &&
-            (GetFocus() == hwnd)) dis.itemState |= ODS_FOCUS;
+            (descr->in_focus)) dis.itemState |= ODS_FOCUS;
         if (dwStyle & WS_DISABLED) dis.itemState |= ODS_DISABLED;
         dis.itemData     = item ? item->data : 0;
@@ -532,5 +543,5 @@
         if ((descr->focus_item == index) &&
             (descr->caret_on) &&
-            (GetFocus() == hwnd)) DrawFocusRect( hdc, rect );
+            (descr->in_focus)) DrawFocusRect( hdc, rect );
     }
 }
@@ -878,5 +889,5 @@
 
     if (!descr->nb_items && (descr->focus_item != -1) && descr->caret_on &&
-        (GetFocus() == hwnd))
+        (descr->in_focus))
     {
         /* Special case for empty listbox: paint focus rect */
@@ -1071,5 +1082,4 @@
 static LRESULT LISTBOX_SetColumnWidth( HWND hwnd, LB_DESCR *descr, UINT width)
 {
-    width += 2;  /* For left and right margin */
     if (width == descr->column_width) return LB_OKAY;
     //TRACE("[%04x]: new column width = %d\n",
@@ -1203,9 +1213,9 @@
     if (index == oldfocus) return LB_OKAY;
     descr->focus_item = index;
-    if ((oldfocus != -1) && descr->caret_on && (GetFocus() == hwnd))
+    if ((oldfocus != -1) && descr->caret_on && (descr->in_focus))
         LISTBOX_RepaintItem( hwnd, descr, oldfocus, ODA_FOCUS );
 
     LISTBOX_MakeItemVisible( hwnd, descr, index, fully_visible );
-    if (descr->caret_on && (GetFocus() == hwnd))
+    if (descr->caret_on && (descr->in_focus))
         LISTBOX_RepaintItem( hwnd, descr, index, ODA_FOCUS );
 
@@ -1235,5 +1245,5 @@
         if (index != -1) descr->items[index].selected = TRUE;
         descr->selected_item = index;
-        if (oldsel != -1) LISTBOX_RepaintItem( hwnd, descr, oldsel, 0);
+        if (oldsel != -1) LISTBOX_RepaintItem( hwnd, descr, oldsel, ODA_SELECT);
         if (index != -1) LISTBOX_RepaintItem( hwnd, descr, index, ODA_SELECT );
         if (send_notify && descr->nb_items) SEND_NOTIFICATION( hwnd, descr,
@@ -1440,4 +1450,8 @@
     if (index == -1) index = descr->nb_items - 1;
     else if ((index < 0) || (index >= descr->nb_items)) return LB_ERR;
+
+    /* We need to Invalidate the original rect intead of the updated one. */
+    LISTBOX_InvalidateItems( hwnd, descr, index );
+
     LISTBOX_DeleteItem( hwnd, descr, index );
 
@@ -1480,5 +1494,5 @@
       }
     }
-    LISTBOX_InvalidateItems( hwnd, descr, index );
+
     if (descr->focus_item >= descr->nb_items)
     {
@@ -1733,4 +1747,21 @@
 }
 
+static LRESULT LISTBOX_HandleMouseWheel(HWND hwnd, LB_DESCR *descr,WPARAM wParam, LPARAM lParam )
+{
+    short gcWheelDelta = 0;
+    UINT pulScrollLines = 3;
+
+    SystemParametersInfoW(SPI_GETWHEELSCROLLLINES,0, &pulScrollLines, 0);
+
+    gcWheelDelta -= (short) HIWORD(wParam);
+
+    if (abs(gcWheelDelta) >= WHEEL_DELTA && pulScrollLines)
+    {
+        int cLineScroll = (int) min((UINT) descr->page_size, pulScrollLines);
+        cLineScroll *= (gcWheelDelta / WHEEL_DELTA);
+        LISTBOX_SetTopItem( hwnd, descr, descr->top_item + cLineScroll, TRUE );
+    }
+    return 0;
+}
 
 /***********************************************************************
@@ -1743,5 +1774,5 @@
     //TRACE("[%04x]: lbuttondown %d,%d item %d\n",
     //             wnd->hwndSelf, x, y, index );
-    if (!descr->caret_on && (GetFocus() == hwnd)) return 0;
+    if (!descr->caret_on && (descr->in_focus)) return 0;
     if (index != -1)
     {
@@ -1768,7 +1799,10 @@
     }
 
-    if( !descr->lphc ) SetFocus( hwnd );
-    else SetFocus( (descr->lphc->hWndEdit) ? descr->lphc->hWndEdit
+    if (!descr->in_focus)
+    {
+      if( !descr->lphc ) SetFocus( hwnd );
+      else SetFocus( (descr->lphc->hWndEdit) ? descr->lphc->hWndEdit
                                              : descr->lphc->hwndself ) ;
+    }
 
     descr->captured = TRUE;
@@ -2191,4 +2225,5 @@
     descr->tabs          = NULL;
     descr->caret_on      = TRUE;
+    descr->in_focus      = FALSE;
     descr->captured      = FALSE;
     descr->font          = 0;
@@ -2483,5 +2518,5 @@
             return LB_OKAY;
         descr->caret_on = TRUE;
-        if ((descr->focus_item != -1) && (GetFocus() == hwnd))
+        if ((descr->focus_item != -1) && (descr->in_focus))
             LISTBOX_RepaintItem( hwnd, descr, descr->focus_item, ODA_FOCUS );
         return LB_OKAY;
@@ -2491,5 +2526,5 @@
             return LB_OKAY;
         descr->caret_on = FALSE;
-        if ((descr->focus_item != -1) && (GetFocus() == hwnd))
+        if ((descr->focus_item != -1) && (descr->in_focus))
             LISTBOX_RepaintItem( hwnd, descr, descr->focus_item, ODA_FOCUS );
         return LB_OKAY;
@@ -2528,4 +2563,5 @@
         return 0;
     case WM_SETFOCUS:
+        descr->in_focus = TRUE;
         descr->caret_on = TRUE;
         if (descr->focus_item != -1)
@@ -2534,4 +2570,5 @@
         return 0;
     case WM_KILLFOCUS:
+        descr->in_focus = FALSE;
         if ((descr->focus_item != -1) && descr->caret_on)
             LISTBOX_RepaintItem( hwnd, descr, descr->focus_item, ODA_FOCUS );
@@ -2542,4 +2579,10 @@
     case WM_VSCROLL:
         return LISTBOX_HandleVScroll( hwnd, descr, wParam, lParam );
+    case WM_MOUSEACTIVATE:
+        return MA_NOACTIVATE;
+    case WM_MOUSEWHEEL:
+        if (wParam & (MK_SHIFT | MK_CONTROL))
+            return DefWindowProcA( hwnd, msg, wParam, lParam );
+        return LISTBOX_HandleMouseWheel( hwnd, descr, wParam, lParam );
     case WM_LBUTTONDOWN:
         return LISTBOX_HandleLButtonDown( hwnd, descr, wParam,
@@ -2650,5 +2693,5 @@
                  return LISTBOX_Create( hwnd, lphc );
             case WM_MOUSEMOVE:
-                 if (CB_GETTYPE(lphc) != CBS_SIMPLE)
+                 if (lphc && (CB_GETTYPE(lphc) != CBS_SIMPLE))
                  {
                    POINT   mousePos;
@@ -2691,4 +2734,6 @@
                  }
             case WM_LBUTTONUP:
+            if (lphc)
+            {
                  POINT mousePos;
                  RECT  clientRect;
@@ -2719,4 +2764,5 @@
                  }
                  return LISTBOX_HandleLButtonUp( hwnd, descr );
+            }
             case WM_LBUTTONDOWN:
                  return LISTBOX_HandleLButtonDownCombo( hwnd, descr, wParam,
@@ -2727,5 +2773,5 @@
                  return FALSE;
             case WM_KEYDOWN:
-                 if( CB_GETTYPE(lphc) != CBS_SIMPLE )
+                 if(lphc && (CB_GETTYPE(lphc) != CBS_SIMPLE))
                  {
                      /* for some reason(?) Windows makes it possible to
@@ -2746,5 +2792,5 @@
                  return lRet;
             case WM_NCDESTROY:
-                 if( CB_GETTYPE(lphc) != CBS_SIMPLE )
+                 if(lphc && (CB_GETTYPE(lphc) != CBS_SIMPLE))
                      lphc->hWndLBox = 0;
                  /* fall through */
Index: trunk/src/user32/menu.cpp
===================================================================
--- trunk/src/user32/menu.cpp	(revision 2849)
+++ trunk/src/user32/menu.cpp	(revision 2852)
@@ -1,3 +1,3 @@
-/* $Id: menu.cpp,v 1.17 2000-02-16 14:34:22 sandervl Exp $*/
+/* $Id: menu.cpp,v 1.18 2000-02-21 17:25:28 cbratschi Exp $*/
 /*
  * Menu functions
@@ -9,4 +9,5 @@
  * Copyright 1999 Christoph Bratschi
  *
+ * Corel version: 20000212
  * WINE version: 20000130
  *
@@ -30,8 +31,9 @@
 #include "menu.h"
 
-#define DBG_LOCALLOG	DBG_menu
+#define DBG_LOCALLOG    DBG_menu
 #include "dbglocal.h"
 
 //DEFAULT_DEBUG_CHANNEL(menu)
+//DECLARE_DEBUG_CHANNEL(winhelp)
 
 
@@ -129,4 +131,5 @@
 
 #define IS_STRING_ITEM(flags) (MENU_ITEM_TYPE ((flags)) == MF_STRING)
+#define IS_SEPARATOR_ITEM(flags) (MENU_ITEM_TYPE ((flags)) == MF_SEPARATOR)
 #define IS_BITMAP_ITEM(flags) (MENU_ITEM_TYPE ((flags)) == MF_BITMAP)
 
@@ -175,4 +178,16 @@
 static BOOL fEndMenu = FALSE;
 
+/*
+   The following variables and defines are used to keep track of which
+   menu item the mouse is currently over. (Used to implement a pause before
+   popup menus are displayed. )
+
+   See: MENU_MouseMove()
+        MENU_TrackMenu()
+*/
+#define     SUBMENU_POPUP_TIMERID    100
+#define     POPUP_MENU_DELAY         500
+static UINT mouseOverMenuID          = -1;
+static BOOL isTimerSet               = FALSE;
 
 /***********************************************************************
@@ -1084,4 +1099,6 @@
     rect = lpitem->rect;
 
+    //CB: todo: does Win98 use DrawEdge for menubars?
+
     if ((lpitem->fState & MF_HILITE) && !(IS_BITMAP_ITEM(lpitem->fType)))
             FillRect( hdc, &rect, GetSysColorBrush(COLOR_HIGHLIGHT) );
@@ -1123,6 +1140,17 @@
         if (lpitem->fState & MF_GRAYED)
             SetTextColor( hdc, GetSysColor( COLOR_GRAYTEXT ) );
+#if 1 //CB: WINE's Win98 menubar -> to check
+
         else
             SetTextColor( hdc, GetSysColor( COLOR_HIGHLIGHTTEXT ) );
+#else
+        else
+        {
+          if (menuBar)
+            SetTextColor(hdc,GetSysColor(COLOR_MENUTEXT));
+          else
+            SetTextColor( hdc, GetSysColor( COLOR_HIGHLIGHTTEXT ) );
+        }
+#endif
         SetBkColor( hdc, GetSysColor( COLOR_HIGHLIGHT ) );
     }
@@ -1761,5 +1789,5 @@
     {
         POPUPMENU *menu = MENU_GetMenu((UINT)id);
-        if (menu) menu->wFlags |= MF_POPUP;
+        if (IS_A_MENU(menu)) menu->wFlags |= MF_POPUP;
         else
         {
@@ -2102,7 +2130,7 @@
 
             GetWindowRect(menu->hWnd,&rectWindow);
-            rect.left = rectWindow.left + item->rect.right-arrow_bitmap_width;
+            rect.left = rectWindow.left + item->rect.right;
             rect.top = rectWindow.top + item->rect.top;
-            rect.right = item->rect.left - item->rect.right + 2*arrow_bitmap_width;
+            rect.right = item->rect.left - item->rect.right;
             rect.bottom = item->rect.top - item->rect.bottom;
         }
@@ -2339,6 +2367,58 @@
     else if( ptmenu->FocusedItem != id )
     {
-            MENU_SwitchTracking( pmt, hPtMenu, id );
-            pmt->hCurrentMenu = MENU_ShowSubPopup(pmt->hOwnerWnd, hPtMenu, FALSE, wFlags,&pmt->pt);
+       POPUPMENU *menu;
+       MENUITEM *item;
+
+	    MENU_SwitchTracking( pmt, hPtMenu, id );
+
+
+       /*
+          Test to see if we are trying to popup a submenu or not.
+          If we aren't, don't change the current menu pointer
+	  and return.
+       */
+       if (!(menu = (POPUPMENU *)MENU_GetMenu( hPtMenu )))
+       {
+          pmt->hCurrentMenu = hPtMenu;
+	  return TRUE;
+       }
+
+       if (!IsWindow( menu->hWnd ) ||
+           (menu->FocusedItem == NO_SELECTED_ITEM))
+       {
+          pmt->hCurrentMenu = hPtMenu;
+	  return TRUE;
+       }
+
+       item = &menu->items[menu->FocusedItem];
+       if (!(item->fType & MF_POPUP) ||
+           (item->fState & (MF_GRAYED | MF_DISABLED)))
+       {
+          pmt->hCurrentMenu =  hPtMenu;
+	  return TRUE;
+       }
+
+
+       /*
+         If we made it this far, we want to pop up a submenu.  Before we pop it up,
+	 we want a slight delay.  This is implemented by remembering the ID of the menu
+	 where the mouse is currently positioned, and setting up a timer.  When the
+	 timer fires (handled in MENU_TrackMenu() ), if the mouse is over the same
+	 submenu item, we popup it up.  Otherwise, we do nothing.
+       */
+       KillTimer (pmt->hOwnerWnd, SUBMENU_POPUP_TIMERID); /* Just in case another timer was set up and not fired yet... */
+       if ( (SetTimer (pmt->hOwnerWnd, SUBMENU_POPUP_TIMERID, POPUP_MENU_DELAY, NULL)) != SUBMENU_POPUP_TIMERID)
+       {
+          /*
+	    For some reason the timer wasn't set up properly... Revert to old
+	    functionality.
+	  */
+	
+	  pmt->hCurrentMenu = MENU_ShowSubPopup(pmt->hOwnerWnd, hPtMenu, FALSE, wFlags,&pmt->pt);
+          return TRUE;
+    }
+
+       mouseOverMenuID = id;
+       isTimerSet = TRUE;
     }
     return TRUE;
@@ -2711,4 +2791,40 @@
             } /* switch(msg.message) - mouse */
         }
+	else if (msg.message == WM_TIMER)
+	{
+	   UINT id = -1;
+           POPUPMENU *ptmenu = NULL;
+
+           if (isTimerSet)
+	   {
+              /*
+	        If we get here, an attempt was made to pop up a submenu.
+	        (See MENU_MouseMove() )
+	      */
+
+	      /* Get the ID of the menu item the mouse is over now. */
+	      if( hmenu )
+              {
+                 ptmenu = (POPUPMENU *)MENU_GetMenu( hmenu );
+                 if( IS_SYSTEM_MENU(ptmenu) )
+                   id = 0;
+                 else
+                   MENU_FindItemByCoords( ptmenu, mt.pt, &id );
+              }
+	
+	      /* If it is over the same item that set up the timer
+	         originally .... */
+	      if (mouseOverMenuID == id)
+	      {
+	         /* .... Pop up the menu */
+                 mt.hCurrentMenu = MENU_ShowSubPopup(mt.hOwnerWnd, hmenu, FALSE, wFlags,&mt.pt);
+	      }
+	
+	      /* Reset the timer so it doesn't fire again. (So we are ready for the next
+	         attempt to popup a submenu... ) */
+	      KillTimer (mt.hOwnerWnd, 100);
+	      isTimerSet = FALSE;
+	   }
+	}
         else if ((msg.message >= WM_KEYFIRST) && (msg.message <= WM_KEYLAST))
         {
@@ -2750,4 +2866,21 @@
                     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;
+			//TRACE_(winhelp)("Sending HELPINFO_MENUITEM to 0x%08x\n", hwnd);
+			SendMessageA(hwnd, WM_HELP, 0, (LPARAM)&hi);
+			break;
+		    }
+
                 default:
                     break;
@@ -2889,4 +3022,67 @@
 }
 
+MENUITEM  *MENU_HighlightedItem=NULL;
+UINT       MENU_HighlightedItemID=NO_SELECTED_ITEM;
+POPUPMENU *MENU_HighlightedMenu=NULL;
+
+void MENU_TrackMouseMenuBar_MouseMove(HWND hwnd,POINT pt,BOOL OnMenu)
+{
+    HMENU hMenu = getMenu(hwnd);
+    MENUITEM *item = NULL;
+    RECT rect;
+    HDC hdc;
+    BOOL UnHighlight = (OnMenu==TRUE)?FALSE:TRUE;
+    POPUPMENU *ptmenu = NULL;
+    UINT id = NO_SELECTED_ITEM;
+
+    if (OnMenu == TRUE && IsMenu(hMenu)) {
+
+        ptmenu=(POPUPMENU *)MENU_GetMenu( hMenu );
+
+        item=MENU_FindItemByCoords( ptmenu, pt, &id );
+
+        if(!item) {
+            /* No item selected, perhaps we are on the blank spot? */
+            UnHighlight = TRUE;
+            /* Paranoid setting */
+            item=NULL;
+        } else if(id == MENU_HighlightedItemID) {
+            /* If it's already highlighted, don't do it again */
+            return;
+        } else if(item->fState & MF_MOUSESELECT) {
+            /* If it's dropped, we let the DrawMenuItem draw the sunken border */
+            return;
+        } else if(item->fType & MF_BITMAP) {
+            UnHighlight = TRUE;
+            /* (Required) Paranoid setting */
+            item=NULL;
+        } else {
+            hdc = GetDCEx( ptmenu->hWnd, 0, DCX_CACHE | DCX_WINDOW);
+            rect = item->rect;
+            DrawEdge(hdc, &rect, BDR_RAISEDINNER, BF_RECT);
+            ReleaseDC( ptmenu->hWnd, hdc );
+
+            UnHighlight = TRUE;
+        }
+    }
+
+    if(UnHighlight == TRUE) {
+        if(MENU_HighlightedItem) {
+            if(!(MENU_HighlightedItem->fState & MF_MOUSESELECT)) {
+                hdc = GetDCEx( MENU_HighlightedMenu->hWnd, 0, DCX_CACHE | DCX_WINDOW);
+                rect = MENU_HighlightedItem->rect;
+
+                FrameRect(hdc, &rect, GetSysColorBrush(COLOR_MENU));
+                ReleaseDC( MENU_HighlightedMenu->hWnd, hdc );
+            }
+        }
+
+        /* Sets to NULL, NO_SELECTED_ITEM, NULL, unless it found a new
+            item, then it will be filled in with the proper values */
+        MENU_HighlightedItem = item;
+        MENU_HighlightedItemID = id;
+        MENU_HighlightedMenu= ptmenu;
+    }
+}
 
 /***********************************************************************
@@ -3333,5 +3529,5 @@
     dprintf(("USER32: GetMenuItemCount"));
 
-    if (!menu) return -1;
+    if (!IS_A_MENU(menu)) return -1;
     //TRACE("(%04x) returning %d\n",
     //              hMenu, menu->nItems );
@@ -3348,6 +3544,6 @@
     dprintf(("USER32: GetMenuItemID"));
 
-    if (!(lpmi = MENU_FindItem(&hMenu,(UINT*)&nPos,MF_BYPOSITION))) return 0;
-    if (lpmi->fType & MF_POPUP) return -1;
+    if (!(lpmi = MENU_FindItem(&hMenu,(UINT*)&nPos,MF_BYPOSITION))) return 0xFFFFFFFF;
+    if (lpmi->fType & MF_POPUP) return 0xFFFFFFFF;
     return lpmi->wID;
 
@@ -3544,5 +3740,5 @@
 
     if (!(hmenu = CreateMenu())) return 0;
-    menu = (POPUPMENU*)hmenu;
+    menu = MENU_GetMenu(hmenu);
     menu->wFlags |= MF_POPUP;
     menu->bTimeToHide = FALSE;
@@ -3633,6 +3829,5 @@
           SetWindowLongA(pTPWnd,0,0);
 
-        if (!IS_A_MENU(lppop)) lppop = NULL;
-        if (lppop)
+        if (IS_A_MENU(lppop))
         {
             lppop->wMagic = 0;  /* Mark it as destroyed */
@@ -3945,5 +4140,5 @@
 BOOL WINAPI IsMenu(HMENU hmenu)
 {
-    LPPOPUPMENU menu = (LPPOPUPMENU)hmenu;
+    LPPOPUPMENU menu = MENU_GetMenu(hmenu);
 
     dprintf(("USER32: IsMenu"));
@@ -4112,5 +4307,5 @@
         if (menu->hSubMenu) {
             POPUPMENU *subMenu = MENU_GetMenu((UINT)menu->hSubMenu);
-            if (subMenu) {
+            if (IS_A_MENU(subMenu)) {
                 subMenu->wFlags |= MF_POPUP;
                 menu->fType |= MF_POPUP;
@@ -4465,5 +4660,4 @@
 
     dprintf(("USER32: GetMenuContextHelpId"));
-    //TRACE("(0x%04x)\n", hMenu);
 
     menu = MENU_GetMenu(hMenu);
@@ -4481,7 +4675,14 @@
 {
     dprintf(("USER32: MenuItemFromPoint not implemented!"));
-    //FIXME("(0x%04x,0x%04x,(%ld,%ld)):stub\n",
-    //      hWnd, hMenu, ptScreen.x, ptScreen.y);
+
     return 0;
+}
+
+/**********************************************************************
+ *         IsMenuActive    (Internal)
+ */
+BOOL IsMenuActive()
+{
+    return pTopPopupWnd &&  (GetWindowLongA(pTopPopupWnd,GWL_STYLE) & WS_VISIBLE);
 }
 
Index: trunk/src/user32/static.cpp
===================================================================
--- trunk/src/user32/static.cpp	(revision 2849)
+++ trunk/src/user32/static.cpp	(revision 2852)
@@ -1,3 +1,3 @@
-/* $Id: static.cpp,v 1.17 2000-02-16 14:34:34 sandervl Exp $ */
+/* $Id: static.cpp,v 1.18 2000-02-21 17:25:29 cbratschi Exp $ */
 /*
  * Static control
@@ -7,4 +7,5 @@
  * Copyright  David W. Metcalfe, 1993
  *
+ * Corel version: 20000212
  * WINE version: 990923
  *
@@ -19,5 +20,5 @@
 #include "static.h"
 
-#define DBG_LOCALLOG	DBG_static
+#define DBG_LOCALLOG    DBG_static
 #include "dbglocal.h"
 
@@ -718,20 +719,52 @@
     FillRect( hdc, &rc, hbrush );
 
-    if (infoPtr->hIcon) {
+    if (infoPtr->hIcon)
+    {
         BITMAP bm;
-        SIZE sz;
-
-        if(GetObjectType(infoPtr->hIcon) != OBJ_BITMAP)
-            return;
+
+        if(GetObjectType(infoPtr->hIcon) != OBJ_BITMAP) return;
         if (!(hMemDC = CreateCompatibleDC( hdc ))) return;
-        GetObjectA(infoPtr->hIcon, sizeof(bm), &bm);
-        GetBitmapDimensionEx(infoPtr->hIcon, &sz);
-        oldbitmap = SelectObject(hMemDC, infoPtr->hIcon);
-        if (dwStyle & SS_CENTERIMAGE)
-          BitBlt(hdc,sz.cx,sz.cy,bm.bmWidth,bm.bmHeight,hMemDC,(rc.right-bm.bmWidth)/2,(rc.bottom-bm.bmHeight)/2,SRCCOPY);
+
+	GetObjectA(infoPtr->hIcon, sizeof(bm), &bm);
+	oldbitmap = SelectObject(hMemDC, infoPtr->hIcon);
+
+	// Paint the image in center area
+	if(dwStyle & SS_CENTERIMAGE)
+	{
+            SIZE szbm;
+            SIZE szdc;
+
+            if(bm.bmWidth > rc.right - rc.left)
+            {
+                szdc.cx = 0;
+                szbm.cx = (bm.bmWidth - (rc.right - rc.left)) / 2;
+                bm.bmWidth = rc.right - rc.left;
+            }
+            else
+            {
+                szbm.cx = 0;
+                szdc.cx = ((rc.right - rc.left) - bm.bmWidth) / 2;
+            }
+            if(bm.bmHeight > rc.bottom - rc.top)
+            {
+                szdc.cy = 0;
+                szbm.cy = (bm.bmHeight - (rc.bottom - rc.top)) / 2;
+                bm.bmWidth = rc.bottom - rc.top;
+            }
+            else
+            {
+                szbm.cy = 0;
+                szdc.cy = ((rc.bottom - rc.top) - bm.bmHeight) / 2;
+            }
+            BitBlt(hdc, szdc.cx, szdc.cy, bm.bmWidth, bm.bmHeight, hMemDC,
+                szbm.cx, szbm.cy, SRCCOPY);
+        }
         else
-          BitBlt(hdc,sz.cx,sz.cy,bm.bmWidth,bm.bmHeight,hMemDC,0,0,SRCCOPY);
-        SelectObject(hMemDC, oldbitmap);
-        DeleteDC(hMemDC);
+        {
+            BitBlt(hdc, 0, 0, bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY);
+        }
+
+	SelectObject(hMemDC, oldbitmap);
+	DeleteDC(hMemDC);
     }
 }
@@ -764,5 +797,6 @@
   di.itemData   = 0;
 
-  SendMessageA(GetParent(hwnd),WM_DRAWITEM,GetWindowLongA(hwnd,GWL_ID),(LPARAM)&di);
+  SendMessageA(GetParent(hwnd),WM_CTLCOLORSTATIC,hdc,hwnd);
+  SendMessageA(GetParent(hwnd),WM_DRAWITEM,di.CtlID,(LPARAM)&di);
 }
 
Index: trunk/src/user32/uitools.cpp
===================================================================
--- trunk/src/user32/uitools.cpp	(revision 2849)
+++ trunk/src/user32/uitools.cpp	(revision 2852)
@@ -1,3 +1,3 @@
-/* $Id: uitools.cpp,v 1.23 2000-02-16 14:34:37 sandervl Exp $ */
+/* $Id: uitools.cpp,v 1.24 2000-02-21 17:25:29 cbratschi Exp $ */
 /*
  * User Interface Functions
@@ -16,5 +16,5 @@
 #include "win32wbase.h"
 
-#define DBG_LOCALLOG	DBG_uitools
+#define DBG_LOCALLOG    DBG_uitools
 #include "dbglocal.h"
 
@@ -1826,256 +1826,4 @@
   return (TRUE);
 }
-
-
-/*****************************************************************************
- * Name      : VOID WIN32API DrawCaption
- * Purpose   : The DrawCaption function draws a window caption.
- * Parameters: HDC hdc        handle of device context
- *             LPRECT lprc    address of bounding rectangle coordinates
- *             HFONT hfont    handle of font for caption
- *             HICON hicon    handle of icon in caption
- *             LPSTR lpszText address of caption string
- *             WORD wFlags    drawing options
- * Variables :
- * Result    :
- * Remark    :
- * Status    : UNTESTED STUB
- *
- * Author    : Patrick Haller [Thu, 1998/02/26 11:55]
- *****************************************************************************/
-
-BOOL WIN32API DrawCaption (HWND hwnd,
-                           HDC  hdc,
-                           const RECT *lprc,
-                           UINT wFlags)
-{
-  dprintf(("USER32:DrawCaption (%08xh,%08xh,%08xh,%08xh) not implemented.\n",
-         hwnd,
-         hdc,
-         lprc,
-         wFlags));
-
-  return FALSE;
-}
-/***********************************************************************
- * DrawCaptionTemp32A [USER32.599]
- *
- * PARAMS
- *
- * RETURNS
- *     Success:
- *     Failure:
- */
-
-BOOL WIN32API DrawCaptionTempA(HWND       hwnd,
-                               HDC        hdc,
-                               const RECT *rect,
-                               HFONT      hFont,
-                               HICON      hIcon,
-                               LPCSTR     str,
-                               UINT       uFlags)
-{
-  RECT   rc = *rect;
-
-  dprintf(("USER32: DrawCaptionTempA(%08xh,%08xh,%08xh,%08xh,%08xh,%08xh,%08xh)\n",
-           hwnd,
-           hdc,
-           rect,
-           hFont,
-           hIcon,
-           str,
-           uFlags));
-
-  /* drawing background */
-  if (uFlags & DC_INBUTTON)
-  {
-    O32_FillRect (hdc,
-                  &rc,
-                  GetSysColorBrush (COLOR_3DFACE));
-
-    if (uFlags & DC_ACTIVE)
-    {
-      HBRUSH hbr = O32_SelectObject (hdc,
-                                     GetSysColorBrush (COLOR_ACTIVECAPTION));
-      O32_PatBlt (hdc,
-                  rc.left,
-                  rc.top,
-                  rc.right - rc.left,
-                  rc.bottom - rc.top,
-                  0xFA0089);
-
-      O32_SelectObject (hdc,
-                        hbr);
-    }
-  }
-  else
-  {
-    O32_FillRect (hdc,
-                  &rc,
-                  GetSysColorBrush ((uFlags & DC_ACTIVE) ?
-                    COLOR_ACTIVECAPTION : COLOR_INACTIVECAPTION));
-  }
-
-
-  /* drawing icon */
-  if ((uFlags & DC_ICON) && !(uFlags & DC_SMALLCAP))
-  {
-    POINT pt;
-
-    pt.x = rc.left + 2;
-    pt.y = (rc.bottom + rc.top - O32_GetSystemMetrics(SM_CYSMICON)) / 2;
-
-    if (hIcon)
-    {
-      DrawIconEx (hdc,
-                  pt.x,
-                  pt.y,
-                  hIcon,
-                  O32_GetSystemMetrics(SM_CXSMICON),
-                  O32_GetSystemMetrics(SM_CYSMICON),
-                  0,
-                  0,
-                  DI_NORMAL);
-    }
-    else
-    {
-    /* @@@PH 1999/06/08 not ported yet, just don't draw any icon
-      WND *wndPtr = WIN_FindWndPtr(hwnd);
-      HICON hAppIcon = 0;
-
-      if (wndPtr->class->hIconSm)
-        hAppIcon = wndPtr->class->hIconSm;
-      else
-        if (wndPtr->class->hIcon)
-          hAppIcon = wndPtr->class->hIcon;
-
-      DrawIconEx (hdc,
-                  pt.x,
-                  pt.y,
-                  hAppIcon,
-                  GetSystemMetrics(SM_CXSMICON),
-                  GetSystemMetrics(SM_CYSMICON),
-                  0,
-                  0,
-                  DI_NORMAL);
-
-      WIN_ReleaseWndPtr(wndPtr);
-      */
-    }
-
-    rc.left += (rc.bottom - rc.top);
-  }
-
-  /* drawing text */
-  if (uFlags & DC_TEXT)
-  {
-    HFONT hOldFont;
-
-    if (uFlags & DC_INBUTTON)
-      O32_SetTextColor (hdc,
-                        O32_GetSysColor (COLOR_BTNTEXT));
-    else
-      if (uFlags & DC_ACTIVE)
-        O32_SetTextColor (hdc,
-                          O32_GetSysColor (COLOR_CAPTIONTEXT));
-      else
-        O32_SetTextColor (hdc,
-                          O32_GetSysColor (COLOR_INACTIVECAPTIONTEXT));
-
-    O32_SetBkMode (hdc,
-                   TRANSPARENT);
-
-    if (hFont)
-      hOldFont = O32_SelectObject (hdc,
-                                   hFont);
-    else
-    {
-      NONCLIENTMETRICSA nclm;
-      HFONT             hNewFont;
-
-      nclm.cbSize = sizeof(NONCLIENTMETRICSA);
-      O32_SystemParametersInfo (SPI_GETNONCLIENTMETRICS,
-                                0,
-                                &nclm,
-                                0);
-      hNewFont = O32_CreateFontIndirect ((uFlags & DC_SMALLCAP) ?
-                                 &nclm.lfSmCaptionFont : &nclm.lfCaptionFont);
-      hOldFont = O32_SelectObject (hdc,
-                                   hNewFont);
-    }
-
-    if (str)
-      DrawTextA (hdc,
-                    str,
-                    -1,
-                    &rc,
-                    DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX | DT_LEFT);
-    else
-    {
-      CHAR szText[128];
-      INT  nLen;
-
-      nLen = O32_GetWindowText (Win32BaseWindow::Win32ToOS2FrameHandle(hwnd),
-                                szText,
-                                128);
-
-      DrawTextA (hdc,
-                    szText,
-                    nLen,
-                    &rc,
-                    DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX | DT_LEFT);
-    }
-
-    if (hFont)
-      O32_SelectObject (hdc,
-                        hOldFont);
-    else
-      O32_DeleteObject (O32_SelectObject (hdc,
-                                          hOldFont));
-  }
-
-  /* drawing focus ??? */
-  if (uFlags & 0x2000)
-  {
-    dprintf(("USER32: DrawCaptionTempA undocumented flag (0x2000)!\n"));
-  }
-
-  return 0;
-}
-
-
-/***********************************************************************
- * DrawCaptionTemp32W [USER32.602]
- *
- * PARAMS
- *
- * RETURNS
- *     Success:
- *     Failure:
- */
-
-BOOL WIN32API DrawCaptionTempW (HWND       hwnd,
-                                HDC        hdc,
-                                const RECT *rect,
-                                HFONT      hFont,
-                                HICON      hIcon,
-                                LPCWSTR    str,
-                                UINT       uFlags)
-{
-  LPSTR strAscii = UnicodeToAsciiString((LPWSTR)str);
-
-  BOOL res = DrawCaptionTempA (hwnd,
-                               hdc,
-                               rect,
-                               hFont,
-                               hIcon,
-                               strAscii,
-                               uFlags);
-
-  FreeAsciiString(strAscii);
-
-  return res;
-}
-
 //******************************************************************************
 //******************************************************************************
Index: trunk/src/user32/user32.cpp
===================================================================
--- trunk/src/user32/user32.cpp	(revision 2849)
+++ trunk/src/user32/user32.cpp	(revision 2852)
@@ -1,3 +1,3 @@
-/* $Id: user32.cpp,v 1.73 2000-02-16 14:34:39 sandervl Exp $ */
+/* $Id: user32.cpp,v 1.74 2000-02-21 17:25:29 cbratschi Exp $ */
 
 /*
@@ -42,5 +42,5 @@
 #include <winuser.h>
 
-#define DBG_LOCALLOG	DBG_user32
+#define DBG_LOCALLOG    DBG_user32
 #include "dbglocal.h"
 
@@ -705,5 +705,6 @@
 
     case SM_CYCAPTION:
-        rc = OSLibWinQuerySysValue(OSLIB_HWND_DESKTOP,SVOS_CYTITLEBAR);
+        rc = 19;
+        //rc = OSLibWinQuerySysValue(OSLIB_HWND_DESKTOP,SVOS_CYTITLEBAR);
         break;
 
Index: trunk/src/user32/win32wbase.cpp
===================================================================
--- trunk/src/user32/win32wbase.cpp	(revision 2849)
+++ trunk/src/user32/win32wbase.cpp	(revision 2852)
@@ -1,3 +1,3 @@
-/* $Id: win32wbase.cpp,v 1.165 2000-02-20 18:28:34 cbratschi Exp $ */
+/* $Id: win32wbase.cpp,v 1.166 2000-02-21 17:25:31 cbratschi Exp $ */
 /*
  * Win32 Window Base Class for OS/2
@@ -8,4 +8,5 @@
  *
  * Parts based on Wine Windows code (windows\win.c)
+ *   Corel version: corel20000212
  *
  * Copyright 1993, 1994, 1996 Alexandre Julliard
@@ -53,7 +54,4 @@
 #include "dbglocal.h"
 
-#define SC_ABOUTWINE            (SC_SCREENSAVE+1)
-#define SC_PUTMARK              (SC_SCREENSAVE+2)
-
 /* bits in the dwKeyData */
 #define KEYDATA_ALT         0x2000
@@ -138,5 +136,6 @@
   windowClass      = 0;
 
-  iconResource       = NULL;
+  hIcon              = 0;
+  hIconSm            = 0;
 
   EraseBkgndFlag     = TRUE;
@@ -581,7 +580,10 @@
   fakeWinBase.pWindowClass = windowClass;
 
-  //Set icon from class
-  if(windowClass->getIcon())
-        SetIcon(windowClass->getIcon());
+  //Set icon from window or class
+  if (hIcon)
+    OSLibWinSetIcon(OS2HwndFrame,hIcon);
+  else if (windowClass->getIcon())
+    OSLibWinSetIcon(OS2HwndFrame,windowClass->getIcon());
+
   /* Get class or window DC if needed */
   if(windowClass->getStyle() & CS_OWNDC) {
@@ -1479,10 +1481,10 @@
         if( hdc )
         {
-          if( (getStyle() & WS_MINIMIZE) && getWindowClass()->getIcon())
+          if( (getStyle() & WS_MINIMIZE) && (getWindowClass()->getIcon() && hIcon))
           {
             int x = (rectWindow.right - rectWindow.left - GetSystemMetrics(SM_CXICON))/2;
             int y = (rectWindow.bottom - rectWindow.top - GetSystemMetrics(SM_CYICON))/2;
             dprintf(("Painting class icon: vis rect=(%i,%i - %i,%i)\n", ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right, ps.rcPaint.bottom ));
-            DrawIcon(hdc, x, y, getWindowClass()->getIcon() );
+            DrawIcon(hdc, x, y, hIcon ? hIcon:getWindowClass()->getIcon() );
           }
           EndPaint(getWindowHandle(), &ps );
@@ -1532,9 +1534,17 @@
     {
       POINT point;
+      LRESULT retvalue;
 
       point.x = (SHORT)LOWORD(lParam);
       point.y = (SHORT)HIWORD(lParam);
 
-      return HandleNCHitTest(point);
+      retvalue = HandleNCHitTest(point);
+#if 0 //CB: let the Corel people fix the bugs first
+      if(retvalue == HTMENU)
+        MENU_TrackMouseMenuBar_MouseMove(Win32Hwnd,point,TRUE);
+      else
+        MENU_TrackMouseMenuBar_MouseMove(Win32Hwnd,point,FALSE);
+#endif
+      return retvalue;
     }
 
@@ -1636,5 +1646,5 @@
         if ((dwStyle & WS_VISIBLE) && wParam) return 0;
         else if (!(dwStyle & WS_VISIBLE) && !wParam) return 0;
-        ShowWindow(wParam ? SW_SHOWNOACTIVATE : SW_HIDE);
+        ShowWindow(wParam ? SW_SHOW:SW_HIDE);
         return 0;
 
@@ -1652,13 +1662,13 @@
     case WM_QUERYDRAGICON:
         {
-            HICON hIcon = windowClass->getCursor();
+            HICON hDragIcon = windowClass->getCursor();
             UINT len;
 
-            if(hIcon) return (LRESULT)hIcon;
+            if(hDragIcon) return (LRESULT)hDragIcon;
             for(len = 1; len < 64; len++)
             {
-              hIcon = LoadIconA(hInstance,MAKEINTRESOURCEA(len));
-              if(hIcon)
-                return (LRESULT)hIcon;
+              hDragIcon = LoadIconA(hInstance,MAKEINTRESOURCEA(len));
+              if(hDragIcon)
+                return (LRESULT)hDragIcon;
             }
             return (LRESULT)LoadIconA(0,IDI_APPLICATIONA);
@@ -1674,19 +1684,29 @@
     case WM_SETICON:
     case WM_GETICON:
-    {
-            LRESULT result = 0;
-            if (!windowClass) return result;
-            int index = GCL_HICON;
-
-            if (wParam == ICON_SMALL)
-                index = GCL_HICONSM;
-
-            result = windowClass->getClassLongA(index);
-
+        {
+          LRESULT result = 0;
+          if (!windowClass) return result;
+          /* Set the appropriate icon members in the window structure. */
+          if (wParam == ICON_SMALL)
+          {
+            result = hIconSm;
             if (Msg == WM_SETICON)
-                windowClass->setClassLongA(index, lParam);
-
-            return result;
-    }
+              hIconSm = (HICON)lParam;
+          }
+          else
+          {
+            result = hIcon;
+            if (Msg == WM_SETICON)
+            {
+              hIcon = (HICON)lParam;
+              OSLibWinSetIcon(OS2HwndFrame,hIcon);
+            }
+          }
+          return result;
+        }
+
+    case WM_HELP:
+	if (getParent()) getParent()->SendInternalMessageA(Msg,wParam,lParam);
+	break;
 
     case WM_NOTIFY:
@@ -1957,16 +1977,4 @@
         window = parentwindow;
    }
-}
-//******************************************************************************
-//******************************************************************************
-BOOL Win32BaseWindow::SetIcon(HICON hIcon)
-{
-    dprintf(("Win32BaseWindow::SetIcon %x", hIcon));
-    if(OSLibWinSetIcon(OS2HwndFrame, hIcon) == TRUE) {
-//TODO: Wine does't send these. Correct?
-//        SendInternalMessageA(WM_SETICON, ICON_BIG, hIcon);
-        return TRUE;
-    }
-    return FALSE;
 }
 //******************************************************************************
Index: trunk/src/user32/win32wbase.h
===================================================================
--- trunk/src/user32/win32wbase.h	(revision 2849)
+++ trunk/src/user32/win32wbase.h	(revision 2852)
@@ -1,3 +1,3 @@
-/* $Id: win32wbase.h,v 1.83 2000-02-07 20:32:43 cbratschi Exp $ */
+/* $Id: win32wbase.h,v 1.84 2000-02-21 17:25:31 cbratschi Exp $ */
 /*
  * Win32 Window Base Class for OS/2
@@ -193,6 +193,6 @@
          HMENU  GetSysMenu()                        { return hSysMenu; }
 
-         BOOL   SetIcon(HICON hIcon);
-         HICON  GetIcon()                           { return (HICON) iconResource; };
+         HICON  GetIcon()                           { return hIcon; }
+         HICON  GetSmallIcon()                      { return hIconSm; }
 
          void   SetWindowRegion(HRGN hRegion)       { hWindowRegion = hRegion; };
@@ -357,5 +357,5 @@
 
    Win32BaseWindow *owner;
-     Win32Resource *iconResource;
+        HICON   hIcon,hIconSm;
 
         char   *windowNameA;
Index: trunk/src/user32/win32wbasenonclient.cpp
===================================================================
--- trunk/src/user32/win32wbasenonclient.cpp	(revision 2849)
+++ trunk/src/user32/win32wbasenonclient.cpp	(revision 2852)
@@ -1,3 +1,3 @@
-/* $Id: win32wbasenonclient.cpp,v 1.12 2000-02-20 18:28:35 cbratschi Exp $ */
+/* $Id: win32wbasenonclient.cpp,v 1.13 2000-02-21 17:25:32 cbratschi Exp $ */
 /*
  * Win32 Window Base Class for OS/2 (non-client methods)
@@ -6,4 +6,5 @@
  *
  * Based on Wine code (windows\nonclient.c)
+ *  Corel Version 20000212
  *
  * Copyright 1994 Alexandre Julliard
@@ -42,12 +43,9 @@
 #include "dbglocal.h"
 
-#define SC_ABOUTODIN            (SC_SCREENSAVE+1)
-#define SC_PUTMARK              (SC_SCREENSAVE+2)
-
 /* bits in the dwKeyData */
 #define KEYDATA_ALT         0x2000
 #define KEYDATA_PREVSTATE   0x4000
 
-static INT bitmapW = 16,bitmapH = 14; //CB: todo: use these values
+static INT bitmapW = 16,bitmapH = 14;
 static HBITMAP hbitmapClose     = 0;
 static HBITMAP hbitmapCloseD    = 0;
@@ -479,12 +477,12 @@
       {
         /* Check if there is an user icon */
-        HICON hIcon = (HICON) GetClassLongA(Win32Hwnd, GCL_HICONSM);
-        if(!hIcon) hIcon = (HICON) GetClassLongA(Win32Hwnd, GCL_HICON);
+        HICON hSysIcon = hIconSm;
+        if(!hSysIcon) hSysIcon = (HICON) GetClassLongA(Win32Hwnd,GCL_HICONSM);
 
         /* If there is an icon associated with the window OR              */
         /* If there is no hIcon specified and this is not a modal dialog, */
         /* there is a system menu icon.                                   */
-        if((hIcon != 0) || (!(dwStyle & DS_MODALFRAME)))
-        rect.left += GetSystemMetrics(SM_CYCAPTION) - 1;
+        if((hSysIcon != 0) || (!(dwStyle & DS_MODALFRAME)))
+          rect.left += GetSystemMetrics(SM_CYCAPTION) - 1;
       }
       if (pt.x < rect.left) return HTSYSMENU;
@@ -492,11 +490,16 @@
       /* Check close button */
       if (dwStyle & WS_SYSMENU)
-      rect.right -= GetSystemMetrics(SM_CYCAPTION) - 1;
+        rect.right -= GetSystemMetrics(SM_CYCAPTION) - 1;
       if (pt.x > rect.right) return HTCLOSE;
+
+      //Check context help
+      if (dwExStyle & WS_EX_CONTEXTHELP)
+        rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
+      if (pt.x > rect.right) return HTHELP;
 
       /* Check maximize box */
       /* In win95 there is automatically a Maximize button when there is a minimize one*/
       if ((dwStyle & WS_MAXIMIZEBOX)|| (dwStyle & WS_MINIMIZEBOX))
-      rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
+        rect.right -= GetSystemMetrics(SM_CXSIZE) + 1;
       if (pt.x > rect.right) return HTMAXBUTTON;
 
@@ -548,6 +551,7 @@
   }
 
-  /* Should never get here */
-  return HTERROR;
+  /* Has to return HTNOWHERE if nothing was found
+     Could happen when a window has a customized non client area */
+  return HTNOWHERE;
 }
 
@@ -621,5 +625,5 @@
 BOOL Win32BaseWindow::DrawSysButton(HDC hdc,RECT *rect)
 {
-  HICON  hIcon;
+  HICON  hSysIcon;
   RECT r;
 
@@ -627,20 +631,29 @@
   else r = *rect;
 
-  hIcon = (HICON) GetClassLongA(Win32Hwnd, GCL_HICONSM);
-  if(!hIcon) hIcon = (HICON) GetClassLongA(Win32Hwnd, GCL_HICON);
+  hSysIcon = hIconSm;
+
+  /* if no small icon and no large icon, use class small icon */
+  if (!hSysIcon && !hIcon)
+    hSysIcon =  (HICON) GetClassLongA(Win32Hwnd, GCL_HICONSM);
+
+  /* otherwise use the large icon */
+  if (!hSysIcon) hSysIcon = hIcon;
+
+  /* if all else fails, use the application icon. */
+  if(!hSysIcon) hSysIcon = (HICON) GetClassLongA(Win32Hwnd, GCL_HICON);
 
   /* If there is no hIcon specified or this is not a modal dialog, */
   /* get the default one.                                          */
-  if(hIcon == 0)
+  if(hSysIcon == 0)
     if (!(dwStyle & DS_MODALFRAME))
-      hIcon = LoadImageA(0, MAKEINTRESOURCEA(OIC_ODINICON), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR);
+      hSysIcon = LoadImageA(0, MAKEINTRESOURCEA(OIC_ODINICON), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR);
 //CB: todo: add icons (including Odin icon) to user32.rc
-  if (hIcon)
-    DrawIconEx(hdc,r.left+2,r.top+2,hIcon,
+  if (hSysIcon)
+    DrawIconEx(hdc,r.left+2,r.top+2,hSysIcon,
                GetSystemMetrics(SM_CXSMICON),
                GetSystemMetrics(SM_CYSMICON),
                0, 0, DI_NORMAL);
 
-  return (hIcon != 0);
+  return (hSysIcon != 0);
 }
 //******************************************************************************
@@ -701,19 +714,39 @@
   else r = *rect;
 
-  hdcMem = CreateCompatibleDC( hdc );
-  hBmp = down ? hbitmapCloseD : hbitmapClose;
-  hOldBmp = SelectObject (hdcMem, hBmp);
-  GetObjectA (hBmp, sizeof(BITMAP), &bmp);
-
-  BitBlt (hdc, r.right - (GetSystemMetrics(SM_CYCAPTION) + 1 + bmp.bmWidth) / 2,
-          r.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2,
-          bmp.bmWidth, bmp.bmHeight, hdcMem, 0, 0, SRCCOPY);
-
-  if(bGrayed)
-    DrawGrayButton(hdc,r.right - (GetSystemMetrics(SM_CYCAPTION) + 1 + bmp.bmWidth) / 2 + 2,
-                   r.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2 + 2);
-
-  SelectObject (hdcMem, hOldBmp);
-  DeleteDC (hdcMem);
+  /* A tool window has a smaller Close button */
+  if (dwExStyle & WS_EX_TOOLWINDOW)
+  {
+    RECT toolRect;	
+    INT iBmpHeight = 11; /* Windows does not use SM_CXSMSIZE and SM_CYSMSIZE   */
+    INT iBmpWidth = 11;  /* it uses 11x11 for  the close button in tool window */ 	  	
+    INT iCaptionHeight = GetSystemMetrics(SM_CYSMCAPTION);
+
+
+    toolRect.top = r.top + (iCaptionHeight - 1 - iBmpHeight) / 2;
+    toolRect.left = r.right - (iCaptionHeight + 1 + iBmpWidth) / 2;
+    toolRect.bottom = toolRect.top + iBmpHeight;
+    toolRect.right = toolRect.left + iBmpWidth;
+    DrawFrameControl(hdc,&toolRect,
+                     DFC_CAPTION,DFCS_CAPTIONCLOSE |
+                     down ? DFCS_PUSHED : 0 |
+                     bGrayed ? DFCS_INACTIVE : 0);
+  } else
+  {
+    hdcMem = CreateCompatibleDC( hdc );
+    hBmp = down ? hbitmapCloseD : hbitmapClose;
+    hOldBmp = SelectObject (hdcMem, hBmp);
+    GetObjectA (hBmp, sizeof(BITMAP), &bmp);
+
+    BitBlt (hdc, r.right - (GetSystemMetrics(SM_CYCAPTION) + 1 + bmp.bmWidth) / 2,
+            r.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2,
+            bmp.bmWidth, bmp.bmHeight, hdcMem, 0, 0, SRCCOPY);
+
+    if(bGrayed)
+      DrawGrayButton(hdc,r.right - (GetSystemMetrics(SM_CYCAPTION) + 1 + bmp.bmWidth) / 2 + 2,
+                     r.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2 + 2);
+
+    SelectObject (hdcMem, hOldBmp);
+    DeleteDC (hdcMem);
+  }
 }
 //******************************************************************************
@@ -738,4 +771,7 @@
     r.right -= GetSystemMetrics(SM_CYCAPTION) + 1;
 
+  if (dwExStyle & WS_EX_CONTEXTHELP)
+    r.right -= bmp.bmWidth;
+
   BitBlt( hdc, r.right - (GetSystemMetrics(SM_CXSIZE) + bmp.bmWidth) / 2,
         r.top + (GetSystemMetrics(SM_CYCAPTION) - 1 - bmp.bmHeight) / 2,
@@ -769,4 +805,7 @@
     r.right -= GetSystemMetrics(SM_CYCAPTION) + 1;
 
+  if (dwExStyle & WS_EX_CONTEXTHELP)
+    r.right -= bmp.bmWidth;
+
   /* In win 95 there is always a Maximize box when there is a Minimize one */
   if ((dwStyle & WS_MAXIMIZEBOX) || (dwStyle & WS_MINIMIZEBOX))
@@ -796,16 +835,12 @@
   if (!rect) GetInsideRect(&r);
   else r = *rect;
-#if 0 //CB: todo
-  hdcMem = CreateCompatibleDC( hdc );
-  hBmp = down ? hbitmapMinimizeD : hbitmapMinimize;
-  hOldBmp= SelectObject( hdcMem, hBmp );
-  GetObjectA (hBmp, sizeof(BITMAP), &bmp);
+
+  hdcMem = CreateCompatibleDC(hdc);
+  hBmp = down ? hbitmapHelpD : hbitmapHelp;
+  hOldBmp = SelectObject(hdcMem,hBmp);
+  GetObjectA(hBmp,sizeof(BITMAP),&bmp);
 
   if (dwStyle & WS_SYSMENU)
-    r.right -= GetSystemMetrics(SM_CYCAPTION) + 1;
-
-  /* In win 95 there is always a Maximize box when there is a Minimize one */
-  if ((dwStyle & WS_MAXIMIZEBOX) || (dwStyle & WS_MINIMIZEBOX))
-    r.right -= bmp.bmWidth;
+    r.right -= GetSystemMetrics(SM_CYCAPTION)+1;
 
   BitBlt( hdc, r.right - (GetSystemMetrics(SM_CXSIZE) + bmp.bmWidth) / 2,
@@ -820,5 +855,4 @@
   SelectObject (hdcMem, hOldBmp);
   DeleteDC( hdcMem );
-#endif
 }
 //******************************************************************************
@@ -912,8 +946,6 @@
     if (dwExStyle & WS_EX_CONTEXTHELP)
     {
-#if 0      //CB: todo: integrate help button
-      DrawHelpButton(memDC,&r2,FALSE);
-      r.right -= bitmapW;
-#endif
+      DrawHelpButton(memDC,&r2,FALSE,FALSE);
+      r.right -= GetSystemMetrics(SM_CXSIZE) + 1;
     }
 
@@ -1288,4 +1320,250 @@
     return 0;
 }
-//******************************************************************************
-//******************************************************************************
+/*****************************************************************************
+ * Name      : VOID WIN32API DrawCaption
+ * Purpose   : The DrawCaption function draws a window caption.
+ * Parameters: HDC hdc        handle of device context
+ *             LPRECT lprc    address of bounding rectangle coordinates
+ *             HFONT hfont    handle of font for caption
+ *             HICON hicon    handle of icon in caption
+ *             LPSTR lpszText address of caption string
+ *             WORD wFlags    drawing options
+ * Variables :
+ * Result    :
+ * Remark    :
+ * Status    : UNTESTED STUB
+ *
+ * Author    : Patrick Haller [Thu, 1998/02/26 11:55]
+ *****************************************************************************/
+
+BOOL WIN32API DrawCaption (HWND hwnd,
+                           HDC  hdc,
+                           const RECT *lprc,
+                           UINT wFlags)
+{
+  dprintf(("USER32:DrawCaption (%08xh,%08xh,%08xh,%08xh) not implemented.\n",
+         hwnd,
+         hdc,
+         lprc,
+         wFlags));
+
+  return FALSE;
+}
+/***********************************************************************
+ * DrawCaptionTemp32A [USER32.599]
+ *
+ * PARAMS
+ *
+ * RETURNS
+ *     Success:
+ *     Failure:
+ */
+
+BOOL WIN32API DrawCaptionTempA(HWND       hwnd,
+                               HDC        hdc,
+                               const RECT *rect,
+                               HFONT      hFont,
+                               HICON      hIcon,
+                               LPCSTR     str,
+                               UINT       uFlags)
+{
+  RECT   rc = *rect;
+
+  dprintf(("USER32: DrawCaptionTempA(%08xh,%08xh,%08xh,%08xh,%08xh,%08xh,%08xh)\n",
+           hwnd,
+           hdc,
+           rect,
+           hFont,
+           hIcon,
+           str,
+           uFlags));
+
+  /* drawing background */
+  if (uFlags & DC_INBUTTON)
+  {
+    O32_FillRect (hdc,
+                  &rc,
+                  GetSysColorBrush (COLOR_3DFACE));
+
+    if (uFlags & DC_ACTIVE)
+    {
+      HBRUSH hbr = O32_SelectObject (hdc,
+                                     GetSysColorBrush (COLOR_ACTIVECAPTION));
+      O32_PatBlt (hdc,
+                  rc.left,
+                  rc.top,
+                  rc.right - rc.left,
+                  rc.bottom - rc.top,
+                  0xFA0089);
+
+      O32_SelectObject (hdc,
+                        hbr);
+    }
+  }
+  else
+  {
+    O32_FillRect (hdc,
+                  &rc,
+                  GetSysColorBrush ((uFlags & DC_ACTIVE) ?
+                    COLOR_ACTIVECAPTION : COLOR_INACTIVECAPTION));
+  }
+
+
+  /* drawing icon */
+  if ((uFlags & DC_ICON) && !(uFlags & DC_SMALLCAP))
+  {
+    POINT pt;
+
+    pt.x = rc.left + 2;
+    pt.y = (rc.bottom + rc.top - O32_GetSystemMetrics(SM_CYSMICON)) / 2;
+
+    if (hIcon)
+    {
+      DrawIconEx (hdc,
+                  pt.x,
+                  pt.y,
+                  hIcon,
+                  O32_GetSystemMetrics(SM_CXSMICON),
+                  O32_GetSystemMetrics(SM_CYSMICON),
+                  0,
+                  0,
+                  DI_NORMAL);
+    }
+    else
+    {
+    /* @@@PH 1999/06/08 not ported yet, just don't draw any icon
+      WND *wndPtr = WIN_FindWndPtr(hwnd);
+      HICON hAppIcon = 0;
+
+      if (wndPtr->class->hIconSm)
+        hAppIcon = wndPtr->class->hIconSm;
+      else
+        if (wndPtr->class->hIcon)
+          hAppIcon = wndPtr->class->hIcon;
+
+      DrawIconEx (hdc,
+                  pt.x,
+                  pt.y,
+                  hAppIcon,
+                  GetSystemMetrics(SM_CXSMICON),
+                  GetSystemMetrics(SM_CYSMICON),
+                  0,
+                  0,
+                  DI_NORMAL);
+
+      WIN_ReleaseWndPtr(wndPtr);
+      */
+    }
+
+    rc.left += (rc.bottom - rc.top);
+  }
+
+  /* drawing text */
+  if (uFlags & DC_TEXT)
+  {
+    HFONT hOldFont;
+
+    if (uFlags & DC_INBUTTON)
+      O32_SetTextColor (hdc,
+                        O32_GetSysColor (COLOR_BTNTEXT));
+    else
+      if (uFlags & DC_ACTIVE)
+        O32_SetTextColor (hdc,
+                          O32_GetSysColor (COLOR_CAPTIONTEXT));
+      else
+        O32_SetTextColor (hdc,
+                          O32_GetSysColor (COLOR_INACTIVECAPTIONTEXT));
+
+    O32_SetBkMode (hdc,
+                   TRANSPARENT);
+
+    if (hFont)
+      hOldFont = O32_SelectObject (hdc,
+                                   hFont);
+    else
+    {
+      NONCLIENTMETRICSA nclm;
+      HFONT             hNewFont;
+
+      nclm.cbSize = sizeof(NONCLIENTMETRICSA);
+      O32_SystemParametersInfo (SPI_GETNONCLIENTMETRICS,
+                                0,
+                                &nclm,
+                                0);
+      hNewFont = O32_CreateFontIndirect ((uFlags & DC_SMALLCAP) ?
+                                 &nclm.lfSmCaptionFont : &nclm.lfCaptionFont);
+      hOldFont = O32_SelectObject (hdc,
+                                   hNewFont);
+    }
+
+    if (str)
+      DrawTextA (hdc,
+                    str,
+                    -1,
+                    &rc,
+                    DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX | DT_LEFT);
+    else
+    {
+      CHAR szText[128];
+      INT  nLen;
+
+      nLen = O32_GetWindowText (Win32BaseWindow::Win32ToOS2FrameHandle(hwnd),
+                                szText,
+                                128);
+
+      DrawTextA (hdc,
+                    szText,
+                    nLen,
+                    &rc,
+                    DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX | DT_LEFT);
+    }
+
+    if (hFont)
+      O32_SelectObject (hdc,
+                        hOldFont);
+    else
+      O32_DeleteObject (O32_SelectObject (hdc,
+                                          hOldFont));
+  }
+
+  /* drawing focus ??? */
+  if (uFlags & 0x2000)
+  {
+    dprintf(("USER32: DrawCaptionTempA undocumented flag (0x2000)!\n"));
+  }
+
+  return 0;
+}
+/***********************************************************************
+ * DrawCaptionTemp32W [USER32.602]
+ *
+ * PARAMS
+ *
+ * RETURNS
+ *     Success:
+ *     Failure:
+ */
+
+BOOL WIN32API DrawCaptionTempW (HWND       hwnd,
+                                HDC        hdc,
+                                const RECT *rect,
+                                HFONT      hFont,
+                                HICON      hIcon,
+                                LPCWSTR    str,
+                                UINT       uFlags)
+{
+  LPSTR strAscii = UnicodeToAsciiString((LPWSTR)str);
+
+  BOOL res = DrawCaptionTempA (hwnd,
+                               hdc,
+                               rect,
+                               hFont,
+                               hIcon,
+                               strAscii,
+                               uFlags);
+
+  FreeAsciiString(strAscii);
+
+  return res;
+}
+
Index: trunk/src/user32/win32wmdiclient.cpp
===================================================================
--- trunk/src/user32/win32wmdiclient.cpp	(revision 2849)
+++ trunk/src/user32/win32wmdiclient.cpp	(revision 2852)
@@ -1,3 +1,3 @@
-/* $Id: win32wmdiclient.cpp,v 1.24 2000-02-16 14:28:24 sandervl Exp $ */
+/* $Id: win32wmdiclient.cpp,v 1.25 2000-02-21 17:25:32 cbratschi Exp $ */
 /*
  * Win32 MDI Client Window Class for OS/2
@@ -36,5 +36,5 @@
 #include "win32wndhandle.h"
 
-#define DBG_LOCALLOG	DBG_win32wmdiclient
+#define DBG_LOCALLOG    DBG_win32wmdiclient
 #include "dbglocal.h"
 
@@ -857,7 +857,17 @@
   // In Win 95 look, the system menu is replaced by the child icon
 
-  HICON hIcon = GetClassLongA(child->getWindowHandle(), GCL_HICONSM);
-  if (!hIcon)
-    hIcon = GetClassLongA(child->getWindowHandle(), GCL_HICON);
+  /* Find small icon */
+  HICON hIcon = child->GetSmallIcon();
+
+  /* If no small icon or overwridden large icon, use class small icon.. */
+  if (!hIcon && !child->GetIcon())
+    hIcon = GetClassLongA(child->getWindowHandle(),GCL_HICONSM);
+
+  /* Use large icon */
+  if (!hIcon) hIcon = child->GetIcon();
+
+  /* If all else fails, use large class icon. */
+  if (!hIcon) hIcon = GetClassLongA(child->getWindowHandle(),GCL_HICON);
+
   if (hIcon)
   {
Index: trunk/src/user32/window.cpp
===================================================================
--- trunk/src/user32/window.cpp	(revision 2849)
+++ trunk/src/user32/window.cpp	(revision 2852)
@@ -1,3 +1,3 @@
-/* $Id: window.cpp,v 1.55 2000-02-16 14:28:26 sandervl Exp $ */
+/* $Id: window.cpp,v 1.56 2000-02-21 17:25:33 cbratschi Exp $ */
 /*
  * Win32 window apis for OS/2
@@ -32,5 +32,5 @@
 #include <win\winpos.h>
 
-#define DBG_LOCALLOG	DBG_window
+#define DBG_LOCALLOG    DBG_window
 #include "dbglocal.h"
 
@@ -670,5 +670,5 @@
 
     if(hwnd == 0x68000034) {
-	window = 0;
+        window = 0;
     }
     dprintf(("GetWindowRect %x (%d,%d) (%d,%d)", hwnd, pRect->left, pRect->top, pRect->right, pRect->bottom));
@@ -857,4 +857,5 @@
 
     dprintf(("AdjustWindowRectEx returned (%d,%d)(%d,%d)\n", rect->left, rect->top, rect->right, rect->bottom));
+
     return TRUE;
 }
@@ -929,6 +930,6 @@
     wnd = Win32BaseWindow::GetWindowFromHandle (hwnd);
     if (!wnd) {
-	dprintf(("warning: ScreenToClient: window %x not found!", hwnd));
-	return (TRUE);
+        dprintf(("warning: ScreenToClient: window %x not found!", hwnd));
+        return (TRUE);
     }
 #ifdef DEBUG
@@ -1057,5 +1058,5 @@
     wnd = Win32BaseWindow::GetWindowFromHandle (hwnd);
     if (!wnd) {
-    	dprintf(("warning: ClientToScreen window %x not found!", hwnd));
+        dprintf(("warning: ClientToScreen window %x not found!", hwnd));
         SetLastError(ERROR_INVALID_WINDOW_HANDLE);
         return (FALSE);
@@ -1066,5 +1067,5 @@
     rc = mapWin32Point(wnd->getOS2WindowHandle(),OSLIB_HWND_DESKTOP,(OSLIBPOINT*)pt);
     dprintf(("ClientToScreen %x (%d,%d) -> (%d,%d)", hwnd, tmp.x, tmp.y, pt->x, pt->y));
-    
+
     return rc;
 }
@@ -1078,5 +1079,5 @@
     if (count <= 0)
     {
-   	dprintf(("USER32: BeginDeferWindowPos invalid param %d", count));
+        dprintf(("USER32: BeginDeferWindowPos invalid param %d", count));
         SetLastError(ERROR_INVALID_PARAMETER);
         return 0;
