Status Bar updates

Dimitrie O. Paun dpaun at rogers.com
Mon Apr 8 14:14:16 CDT 2002


[Again, without the linewrap]

ChangeLog:
  -- get rid of parent handle from info struct
  -- store hwnd in info struct, do not pass it around
  -- use unicode functions wherever possible
  -- consistent indentation
  -- bugs in Unicode handling fixed
  -- fix handling of error conditions
  -- fix initialization bugs, etc.
  -- complete tooltip support
  -- typesafety
  -- update the FIXME list to the latest specs

Index: dlls/comctl32/status.c
===================================================================
RCS file: /var/cvs/wine/dlls/comctl32/status.c,v
retrieving revision 1.39
diff -u -r1.39 status.c
--- dlls/comctl32/status.c	9 Mar 2002 23:29:34 -0000	1.39
+++ dlls/comctl32/status.c	7 Apr 2002 08:10:45 -0000
@@ -3,6 +3,7 @@
  *
  * Copyright 1996 Bruce Milner
  * Copyright 1998, 1999 Eric Kohl
+ * Copyright 2002 Dimitrie O. Paun
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -17,16 +18,17 @@
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-/*
- * FIXME/TODO
- * 1) Don't hard code bar to bottom of window, allow CCS_TOP also.
- * 2) Tooltip support (almost done).
- * 3) where else should we use infoPtr->hwndParent instead of GetParent() ?
- * 4) send WM_QUERYFORMAT
+ *
+ * FIXME:
+ * 1) Implement all CCS_* styles.
+ * 2) Send WM_QUERYFORMAT
+ * 3) Use DrawEdge to draw the SizeGrip
+ * 4) Implement DrawStatusText and use it.
+ *
  */
 
 #include <string.h>
+
 #include "winbase.h"
 #include "wine/unicode.h"
 #include "commctrl.h"
@@ -36,27 +38,26 @@
 
 typedef struct
 {
-    INT	x;
-    INT	style;
+    INT 	x;
+    INT 	style;
     RECT	bound;
     LPWSTR	text;
-    HICON     hIcon;
+    HICON       hIcon;
 } STATUSWINDOWPART;
 
 typedef struct
 {
-    HWND              hwndParent;
+    HWND              Self;
     WORD              numParts;
-    WORD              textHeight;
     UINT              height;
     BOOL              simple;
     HWND              hwndToolTip;
     HFONT             hFont;
     HFONT             hDefaultFont;
-    COLORREF            clrBk;     /* background color */
-    BOOL              bUnicode;  /* unicode flag */
-    STATUSWINDOWPART	part0;	   /* simple window */
-    STATUSWINDOWPART   *parts;
+    COLORREF          clrBk;		/* background color */
+    BOOL              bUnicode;		/* unicode flag */
+    STATUSWINDOWPART  part0;		/* simple window */
+    STATUSWINDOWPART* parts;
 } STATUSWINDOWINFO;
 
 /*
@@ -69,11 +70,16 @@
 #define VERT_BORDER 2
 #define HORZ_GAP    2
 
-#define STATUSBAR_GetInfoPtr(hwnd) ((STATUSWINDOWINFO *)GetWindowLongA (hwnd, 0))
+#define STATUSBAR_GetInfoPtr(hwnd) ((STATUSWINDOWINFO *)GetWindowLongW (hwnd, 0))
 
 /* prototype */
 static void
-STATUSBAR_SetPartBounds (STATUSWINDOWINFO *infoPtr, HWND hwnd);
+STATUSBAR_SetPartBounds (STATUSWINDOWINFO *infoPtr);
+
+static inline LPCSTR debugstr_t(LPCWSTR text, BOOL isW)
+{
+  return isW ? debugstr_w(text) : debugstr_a((LPCSTR)text);
+}
 
 static void
 STATUSBAR_DrawSizeGrip (HDC hdc, LPRECT lpRect)
@@ -83,6 +89,8 @@
     INT i;
 
     TRACE("draw size grip %d,%d - %d,%d\n", lpRect->left, lpRect->top, lpRect->right, lpRect->bottom);
+
+    //FIXME: use DrawEdge to draw this
     pt.x = lpRect->right - 1;
     pt.y = lpRect->bottom - 1;
 
@@ -121,9 +129,9 @@
 
     TRACE("part bound %d,%d - %d,%d\n", r.left, r.top, r.right, r.bottom);
     if (part->style & SBT_POPOUT)
-      border = BDR_RAISEDOUTER;
+        border = BDR_RAISEDOUTER;
     else if (part->style & SBT_NOBORDERS)
-      border = 0;
+        border = 0;
 
     DrawEdge(hdc, &r, border, BF_RECT|BF_ADJUST);
 
@@ -138,35 +146,34 @@
 
     /* now draw text */
     if (part->text) {
-      int oldbkmode = SetBkMode(hdc, TRANSPARENT);
-      LPWSTR p = (LPWSTR)part->text;
-      UINT align = DT_LEFT;
-      if (*p == L'\t') {
-	p++;
-	align = DT_CENTER;
-
-	if (*p == L'\t') {
-	  p++;
-	  align = DT_RIGHT;
-	}
-      }
-      r.left += 3;
-      TRACE("%s at %d,%d - %d,%d\n", debugstr_w(p), r.left, r.top, r.right, r.bottom);
-      DrawTextW (hdc, p, -1, &r, align|DT_VCENTER|DT_SINGLELINE);
-      if (oldbkmode != TRANSPARENT)
+        int oldbkmode = SetBkMode(hdc, TRANSPARENT);
+        LPWSTR p = (LPWSTR)part->text;
+        UINT align = DT_LEFT;
+        if (*p == L'\t') {
+	    p++;
+	    align = DT_CENTER;
+
+	    if (*p == L'\t') {
+	        p++;
+	        align = DT_RIGHT;
+	    }
+        }
+        r.left += 3;
+        TRACE("%s at %d,%d - %d,%d\n", debugstr_w(p), r.left, r.top, r.right, r.bottom);
+        DrawTextW (hdc, p, -1, &r, align|DT_VCENTER|DT_SINGLELINE);
 	SetBkMode(hdc, oldbkmode);
     }
 }
 
 
-static VOID
-STATUSBAR_RefreshPart (STATUSWINDOWINFO *infoPtr, HWND hwnd, STATUSWINDOWPART *part, HDC hdc, int itemID)
+static void
+STATUSBAR_RefreshPart (STATUSWINDOWINFO *infoPtr, STATUSWINDOWPART *part, HDC hdc, int itemID)
 {
     HBRUSH hbrBk;
     HFONT  hOldFont;
 
     TRACE("item %d\n", itemID);
-    if (!IsWindowVisible (hwnd))
+    if (!IsWindowVisible (infoPtr->Self))
         return;
 
     if (part->bound.right < part->bound.left) return;
@@ -182,13 +189,13 @@
     if (part->style & SBT_OWNERDRAW) {
 	DRAWITEMSTRUCT dis;
 
-	dis.CtlID = GetWindowLongA (hwnd, GWL_ID);
+	dis.CtlID = GetWindowLongW (infoPtr->Self, GWL_ID);
 	dis.itemID = itemID;
-	dis.hwndItem = hwnd;
+	dis.hwndItem = infoPtr->Self;
 	dis.hDC = hdc;
 	dis.rcItem = part->bound;
 	dis.itemData = (INT)part->text;
-	SendMessageA (GetParent (hwnd), WM_DRAWITEM,
+	SendMessageW (GetParent (infoPtr->Self), WM_DRAWITEM,
 		(WPARAM)dis.CtlID, (LPARAM)&dis);
     } else
 	STATUSBAR_DrawPart (hdc, part);
@@ -198,17 +205,17 @@
     if (infoPtr->clrBk != CLR_DEFAULT)
 	DeleteObject (hbrBk);
 
-    if (GetWindowLongA (hwnd, GWL_STYLE) & SBARS_SIZEGRIP) {
+    if (GetWindowLongW (infoPtr->Self, GWL_STYLE) & SBARS_SIZEGRIP) {
 	RECT rect;
 
-	GetClientRect (hwnd, &rect);
+	GetClientRect (infoPtr->Self, &rect);
 	STATUSBAR_DrawSizeGrip (hdc, &rect);
     }
 }
 
 
-static BOOL
-STATUSBAR_Refresh (STATUSWINDOWINFO *infoPtr, HWND hwnd, HDC hdc)
+static LRESULT
+STATUSBAR_Refresh (STATUSWINDOWINFO *infoPtr, HDC hdc)
 {
     int      i;
     RECT   rect;
@@ -216,12 +223,12 @@
     HFONT  hOldFont;
 
     TRACE("\n");
-    if (!IsWindowVisible(hwnd))
-        return (TRUE);
+    if (!IsWindowVisible(infoPtr->Self))
+        return 0;
 
-    STATUSBAR_SetPartBounds(infoPtr, hwnd);
+    STATUSBAR_SetPartBounds(infoPtr);
 
-    GetClientRect (hwnd, &rect);
+    GetClientRect (infoPtr->Self, &rect);
 
     if (infoPtr->clrBk != CLR_DEFAULT)
 	hbrBk = CreateSolidBrush (infoPtr->clrBk);
@@ -232,22 +239,22 @@
     hOldFont = SelectObject (hdc, infoPtr->hFont ? infoPtr->hFont : infoPtr->hDefaultFont);
 
     if (infoPtr->simple) {
-	STATUSBAR_RefreshPart (infoPtr, hwnd, &infoPtr->part0, hdc, 0);
+	STATUSBAR_RefreshPart (infoPtr, &infoPtr->part0, hdc, 0);
     } else {
 	for (i = 0; i < infoPtr->numParts; i++) {
 	    if (infoPtr->parts[i].style & SBT_OWNERDRAW) {
 		DRAWITEMSTRUCT dis;
 
-		dis.CtlID = GetWindowLongA (hwnd, GWL_ID);
+		dis.CtlID = GetWindowLongW (infoPtr->Self, GWL_ID);
 		dis.itemID = i;
-		dis.hwndItem = hwnd;
+		dis.hwndItem = infoPtr->Self;
 		dis.hDC = hdc;
 		dis.rcItem = infoPtr->parts[i].bound;
 		dis.itemData = (INT)infoPtr->parts[i].text;
-		SendMessageA (GetParent (hwnd), WM_DRAWITEM,
+		SendMessageW (GetParent (infoPtr->Self), WM_DRAWITEM,
 			(WPARAM)dis.CtlID, (LPARAM)&dis);
 	    } else
-		STATUSBAR_RefreshPart (infoPtr, hwnd, &infoPtr->parts[i], hdc, i);
+		STATUSBAR_RefreshPart (infoPtr, &infoPtr->parts[i], hdc, i);
 	}
     }
 
@@ -256,22 +263,22 @@
     if (infoPtr->clrBk != CLR_DEFAULT)
 	DeleteObject (hbrBk);
 
-    if (GetWindowLongA(hwnd, GWL_STYLE) & SBARS_SIZEGRIP)
+    if (GetWindowLongW (infoPtr->Self, GWL_STYLE) & SBARS_SIZEGRIP)
 	STATUSBAR_DrawSizeGrip (hdc, &rect);
 
-    return TRUE;
+    return 0;
 }
 
 
 static void
-STATUSBAR_SetPartBounds (STATUSWINDOWINFO *infoPtr, HWND hwnd)
+STATUSBAR_SetPartBounds (STATUSWINDOWINFO *infoPtr)
 {
     STATUSWINDOWPART *part;
     RECT rect, *r;
     int	i;
 
     /* get our window size */
-    GetClientRect (hwnd, &rect);
+    GetClientRect (infoPtr->Self, &rect);
     TRACE("client wnd size is %d,%d - %d,%d\n", rect.left, rect.top, rect.right, rect.bottom);
 
     rect.top += VERT_BORDER;
@@ -295,26 +302,26 @@
 	    r->right = part->x;
 
 	if (infoPtr->hwndToolTip) {
-	    TTTOOLINFOA ti;
+	    TTTOOLINFOW ti;
 
-	    ti.cbSize = sizeof(TTTOOLINFOA);
-	    ti.hwnd = hwnd;
+	    ti.cbSize = sizeof(TTTOOLINFOW);
+	    ti.hwnd = infoPtr->Self;
 	    ti.uId = i;
 	    ti.rect = *r;
-	    SendMessageA (infoPtr->hwndToolTip, TTM_NEWTOOLRECTA,
+	    SendMessageW (infoPtr->hwndToolTip, TTM_NEWTOOLRECTW,
 			    0, (LPARAM)&ti);
 	}
     }
 }
 
 
-static VOID
-STATUSBAR_RelayEvent (HWND hwndTip, HWND hwndMsg, UINT uMsg,
-		      WPARAM wParam, LPARAM lParam)
+static LRESULT
+STATUSBAR_Relay2Tip (STATUSWINDOWINFO *infoPtr, UINT uMsg,
+		     WPARAM wParam, LPARAM lParam)
 {
     MSG msg;
 
-    msg.hwnd = hwndMsg;
+    msg.hwnd = infoPtr->Self;
     msg.message = uMsg;
     msg.wParam = wParam;
     msg.lParam = lParam;
@@ -322,15 +329,13 @@
     msg.pt.x = LOWORD(GetMessagePos ());
     msg.pt.y = HIWORD(GetMessagePos ());
 
-    SendMessageA (hwndTip, TTM_RELAYEVENT, 0, (LPARAM)&msg);
+    return SendMessageW (infoPtr->hwndToolTip, TTM_RELAYEVENT, 0, (LPARAM)&msg);
 }
 
 
-inline static LRESULT
-STATUSBAR_GetBorders (LPARAM lParam)
+static BOOL
+STATUSBAR_GetBorders (INT out[])
 {
-    LPINT out = (LPINT) lParam;
-
     TRACE("\n");
     out[0] = HORZ_BORDER; /* horizontal border width */
     out[1] = VERT_BORDER; /* vertical border width */
@@ -340,12 +345,9 @@
 }
 
 
-static LRESULT
-STATUSBAR_GetIcon (STATUSWINDOWINFO *infoPtr, HWND hwnd, WPARAM wParam)
+static HICON
+STATUSBAR_GetIcon (STATUSWINDOWINFO *infoPtr, INT nPart)
 {
-    INT nPart;
-
-    nPart = (INT)wParam & 0x00ff;
     TRACE("%d\n", nPart);
     if ((nPart < -1) || (nPart >= infoPtr->numParts))
 	return 0;
@@ -357,34 +359,25 @@
 }
 
 
-static LRESULT
-STATUSBAR_GetParts (STATUSWINDOWINFO *infoPtr, HWND hwnd, WPARAM wParam, LPARAM lParam)
+static INT
+STATUSBAR_GetParts (STATUSWINDOWINFO *infoPtr, INT num_parts, INT parts[])
 {
-    LPINT parts;
-    INT   num_parts;
     INT   i;
 
-    num_parts = (INT) wParam;
     TRACE("(%d)\n", num_parts);
-    parts = (LPINT) lParam;
     if (parts) {
 	for (i = 0; i < num_parts; i++) {
 	    parts[i] = infoPtr->parts[i].x;
 	}
     }
-    return (infoPtr->numParts);
+    return infoPtr->numParts;
 }
 
 
-static LRESULT
-STATUSBAR_GetRect (STATUSWINDOWINFO *infoPtr, HWND hwnd, WPARAM wParam, LPARAM lParam)
+static BOOL
+STATUSBAR_GetRect (STATUSWINDOWINFO *infoPtr, INT nPart, LPRECT rect)
 {
-    int	nPart;
-    LPRECT  rect;
-
-    nPart = ((INT) wParam) & 0x00ff;
     TRACE("part %d\n", nPart);
-    rect = (LPRECT) lParam;
     if (infoPtr->simple)
 	*rect = infoPtr->part0.bound;
     else
@@ -394,13 +387,11 @@
 
 
 static LRESULT
-STATUSBAR_GetTextA (STATUSWINDOWINFO *infoPtr, HWND hwnd, WPARAM wParam, LPARAM lParam)
+STATUSBAR_GetTextA (STATUSWINDOWINFO *infoPtr, INT nPart, LPSTR buf)
 {
     STATUSWINDOWPART *part;
-    INT   nPart;
     LRESULT result;
 
-    nPart = ((INT) wParam) & 0x00ff;
     TRACE("part %d\n", nPart);
     if (infoPtr->simple)
 	part = &infoPtr->part0;
@@ -413,21 +404,19 @@
         DWORD len = part->text ? WideCharToMultiByte( CP_ACP, 0, part->text, -1,
                                                       NULL, 0, NULL, NULL ) - 1 : 0;
         result = MAKELONG( len, part->style );
-        if (lParam && len)
-            WideCharToMultiByte( CP_ACP, 0, part->text, -1, (LPSTR)lParam, len+1, NULL, NULL );
+        if (part->text && buf)
+            WideCharToMultiByte( CP_ACP, 0, part->text, -1, buf, len+1, NULL, NULL );
     }
     return result;
 }
 
 
 static LRESULT
-STATUSBAR_GetTextW (STATUSWINDOWINFO *infoPtr, HWND hwnd, WPARAM wParam, LPARAM lParam)
+STATUSBAR_GetTextW (STATUSWINDOWINFO *infoPtr, INT nPart, LPWSTR buf)
 {
     STATUSWINDOWPART *part;
-    INT   nPart;
     LRESULT result;
 
-    nPart = ((INT)wParam) & 0x00ff;
     TRACE("part %d\n", nPart);
     if (infoPtr->simple)
 	part = &infoPtr->part0;
@@ -439,22 +428,19 @@
     else {
 	result = part->text ? strlenW (part->text) : 0;
 	result |= (part->style << 16);
-	if (part->text && lParam)
-	    strcpyW ((LPWSTR)lParam, part->text);
+	if (part->text && buf)
+	    strcpyW (buf, part->text);
     }
     return result;
 }
 
 
 static LRESULT
-STATUSBAR_GetTextLength (STATUSWINDOWINFO *infoPtr, HWND hwnd, WPARAM wParam)
+STATUSBAR_GetTextLength (STATUSWINDOWINFO *infoPtr, INT nPart)
 {
     STATUSWINDOWPART *part;
-    INT nPart;
     DWORD result;
 
-    nPart = ((INT) wParam) & 0x00ff;
-
     TRACE("part %d\n", nPart);
     if (infoPtr->simple)
 	part = &infoPtr->part0;
@@ -470,12 +456,10 @@
     return result;
 }
 
-
 static LRESULT
-STATUSBAR_GetTipTextA (STATUSWINDOWINFO *infoPtr, HWND hwnd, WPARAM wParam, LPARAM lParam)
+STATUSBAR_GetTipTextA (STATUSWINDOWINFO *infoPtr, INT id, LPSTR tip, INT size)
 {
-    LPSTR tip = (LPSTR)lParam;
-
+    TRACE("\n");
     if (tip) {
         CHAR buf[INFOTIPSIZE];
         buf[0]='\0';
@@ -483,22 +467,20 @@
         if (infoPtr->hwndToolTip) {
             TTTOOLINFOA ti;
             ti.cbSize = sizeof(TTTOOLINFOA);
-            ti.hwnd = hwnd;
-            ti.uId = LOWORD(wParam);
+            ti.hwnd = infoPtr->Self;
+            ti.uId = id;
             ti.lpszText = buf;
-            SendMessageA(infoPtr->hwndToolTip, TTM_GETTEXTA, 0, (LPARAM)&ti);
+            SendMessageA (infoPtr->hwndToolTip, TTM_GETTEXTA, 0, (LPARAM)&ti);
         }
-        lstrcpynA(tip, buf, HIWORD(wParam));
+        lstrcpynA (tip, buf, size);
     }
     return 0;
 }
 
 
 static LRESULT
-STATUSBAR_GetTipTextW (STATUSWINDOWINFO *infoPtr, HWND hwnd, WPARAM wParam, LPARAM lParam)
+STATUSBAR_GetTipTextW (STATUSWINDOWINFO *infoPtr, INT id, LPWSTR tip, INT size)
 {
-    LPWSTR tip = (LPWSTR)lParam;
-
     TRACE("\n");
     if (tip) {
         WCHAR buf[INFOTIPSIZE];
@@ -507,124 +489,103 @@
 	if (infoPtr->hwndToolTip) {
 	    TTTOOLINFOW ti;
 	    ti.cbSize = sizeof(TTTOOLINFOW);
-	    ti.hwnd = hwnd;
-	    ti.uId = LOWORD(wParam);
+	    ti.hwnd = infoPtr->Self;
+	    ti.uId = id;
             ti.lpszText = buf;
 	    SendMessageW(infoPtr->hwndToolTip, TTM_GETTEXTW, 0, (LPARAM)&ti);
 	}
-	lstrcpynW(tip, buf, HIWORD(wParam));
+	lstrcpynW(tip, buf, size);
     }
 
     return 0;
 }
 
 
-inline static LRESULT
-STATUSBAR_GetUnicodeFormat (STATUSWINDOWINFO *infoPtr, HWND hwnd)
-{
-    return infoPtr->bUnicode;
-}
-
-
-inline static LRESULT
-STATUSBAR_IsSimple (STATUSWINDOWINFO *infoPtr, HWND hwnd)
-{
-    return infoPtr->simple;
-}
-
-
-static LRESULT
-STATUSBAR_SetBkColor (STATUSWINDOWINFO *infoPtr, HWND hwnd, WPARAM wParam, LPARAM lParam)
+static COLORREF
+STATUSBAR_SetBkColor (STATUSWINDOWINFO *infoPtr, COLORREF color)
 {
     COLORREF oldBkColor;
 
     oldBkColor = infoPtr->clrBk;
-    infoPtr->clrBk = (COLORREF)lParam;
-    InvalidateRect(hwnd, NULL, FALSE);
+    infoPtr->clrBk = color;
+    InvalidateRect(infoPtr->Self, NULL, FALSE);
 
     TRACE("CREF: %08lx -> %08lx\n", oldBkColor, infoPtr->clrBk);
     return oldBkColor;
 }
 
 
-static LRESULT
-STATUSBAR_SetIcon (STATUSWINDOWINFO *infoPtr, HWND hwnd, WPARAM wParam, LPARAM lParam)
+static BOOL
+STATUSBAR_SetIcon (STATUSWINDOWINFO *infoPtr, INT nPart, HICON hIcon)
 {
-    INT nPart = (INT)wParam & 0x00ff;
-
     if ((nPart < -1) || (nPart >= infoPtr->numParts))
 	return FALSE;
 
-    TRACE("setting part %d, icon %lx\n",nPart,lParam);
+    TRACE("setting part %d\n", nPart);
 
     if (nPart == -1) {
-	if (infoPtr->part0.hIcon == (HICON)lParam) /* same as - no redraw */
+	if (infoPtr->part0.hIcon == hIcon) /* same as - no redraw */
 	    return TRUE;
-	infoPtr->part0.hIcon = (HICON)lParam;
+	infoPtr->part0.hIcon = hIcon;
 	if (infoPtr->simple)
-            InvalidateRect(hwnd, &infoPtr->part0.bound, FALSE);
+            InvalidateRect(infoPtr->Self, &infoPtr->part0.bound, FALSE);
     } else {
-	if (infoPtr->parts[nPart].hIcon == (HICON)lParam) /* same as - no redraw */
+	if (infoPtr->parts[nPart].hIcon == hIcon) /* same as - no redraw */
 	    return TRUE;
 
-	infoPtr->parts[nPart].hIcon = (HICON)lParam;
+	infoPtr->parts[nPart].hIcon = hIcon;
 	if (!(infoPtr->simple))
-            InvalidateRect(hwnd, &infoPtr->parts[nPart].bound, FALSE);
+            InvalidateRect(infoPtr->Self, &infoPtr->parts[nPart].bound, FALSE);
     }
     return TRUE;
 }
 
 
-static LRESULT
-STATUSBAR_SetMinHeight (STATUSWINDOWINFO *infoPtr, HWND hwnd, WPARAM wParam, LPARAM lParam)
+static BOOL
+STATUSBAR_SetMinHeight (STATUSWINDOWINFO *infoPtr, INT height)
 {
 
-    TRACE("\n");
-    if (IsWindowVisible (hwnd)) {
-	HWND parent = GetParent (hwnd);
+    TRACE("(height=%d)\n", height);
+    if (IsWindowVisible (infoPtr->Self)) {
 	INT  width, x, y;
 	RECT parent_rect;
 
-	GetClientRect (parent, &parent_rect);
-	infoPtr->height = (INT)wParam + VERT_BORDER;
+	GetClientRect (GetParent (infoPtr->Self), &parent_rect);
+	infoPtr->height = height + VERT_BORDER;
 	width = parent_rect.right - parent_rect.left;
 	x = parent_rect.left;
 	y = parent_rect.bottom - infoPtr->height;
-	MoveWindow (hwnd, parent_rect.left,
+	MoveWindow (infoPtr->Self, parent_rect.left,
 		      parent_rect.bottom - infoPtr->height,
 		      width, infoPtr->height, TRUE);
-	STATUSBAR_SetPartBounds (infoPtr, hwnd);
+	STATUSBAR_SetPartBounds (infoPtr);
     }
 
     return TRUE;
 }
 
 
-static LRESULT
-STATUSBAR_SetParts (STATUSWINDOWINFO *infoPtr, HWND hwnd, WPARAM wParam, LPARAM lParam)
+static BOOL
+STATUSBAR_SetParts (STATUSWINDOWINFO *infoPtr, INT count, LPINT parts)
 {
     STATUSWINDOWPART *tmp;
-    LPINT parts;
-    int	i;
-    int	oldNumParts;
+    int	i, oldNumParts;
 
-    TRACE("(%d,%p)\n",wParam,(LPVOID)lParam);
+    TRACE("(%d,%p)\n", count, parts);
 
-    /* FIXME: should return FALSE sometimes (maybe when wParam == 0 ?) */
     if (infoPtr->simple)
 	infoPtr->simple = FALSE;
 
     oldNumParts = infoPtr->numParts;
-    infoPtr->numParts = (INT) wParam;
-    parts = (LPINT) lParam;
+    infoPtr->numParts = count;
     if (oldNumParts > infoPtr->numParts) {
 	for (i = infoPtr->numParts ; i < oldNumParts; i++) {
 	    if (infoPtr->parts[i].text && !(infoPtr->parts[i].style & SBT_OWNERDRAW))
 		COMCTL32_Free (infoPtr->parts[i].text);
 	}
-    }
-    if (oldNumParts < infoPtr->numParts) {
+    } else if (oldNumParts < infoPtr->numParts) {
 	tmp = COMCTL32_Alloc (sizeof(STATUSWINDOWPART) * infoPtr->numParts);
+	if (!tmp) return FALSE;
 	for (i = 0; i < oldNumParts; i++) {
 	    tmp[i] = infoPtr->parts[i];
 	}
@@ -633,7 +594,7 @@
 	infoPtr->parts = tmp;
     }
     if (oldNumParts == infoPtr->numParts) {
-	for (i=0;i<oldNumParts;i++)
+	for (i=0; i < oldNumParts; i++)
 	    if (infoPtr->parts[i].x != parts[i])
 		break;
 	if (i==oldNumParts) /* Unchanged? no need to redraw! */
@@ -644,57 +605,51 @@
 	infoPtr->parts[i].x = parts[i];
 
     if (infoPtr->hwndToolTip) {
-	INT nTipCount =
-	    SendMessageA (infoPtr->hwndToolTip, TTM_GETTOOLCOUNT, 0, 0);
+	INT nTipCount, i;
+	TTTOOLINFOW ti;
 
+	ZeroMemory (&ti, sizeof(TTTOOLINFOW));
+	ti.cbSize = sizeof(TTTOOLINFOW);
+	ti.hwnd = infoPtr->Self;
+
+	nTipCount = SendMessageW (infoPtr->hwndToolTip, TTM_GETTOOLCOUNT, 0, 0);
 	if (nTipCount < infoPtr->numParts) {
 	    /* add tools */
-	    TTTOOLINFOA ti;
-	    INT i;
-
-	    ZeroMemory (&ti, sizeof(TTTOOLINFOA));
-	    ti.cbSize = sizeof(TTTOOLINFOA);
-	    ti.hwnd = hwnd;
 	    for (i = nTipCount; i < infoPtr->numParts; i++) {
 		TRACE("add tool %d\n", i);
 		ti.uId = i;
-		SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA,
+		SendMessageW (infoPtr->hwndToolTip, TTM_ADDTOOLW,
 				0, (LPARAM)&ti);
 	    }
 	}
 	else if (nTipCount > infoPtr->numParts) {
 	    /* delete tools */
-	    INT i;
-
 	    for (i = nTipCount - 1; i >= infoPtr->numParts; i--) {
-		FIXME("delete tool %d\n", i);
+		TRACE("delete tool %d\n", i);
+		ti.uId = i;
+		SendMessageW (infoPtr->hwndToolTip, TTM_DELTOOLW,
+				0, (LPARAM)&ti);
 	    }
 	}
     }
-    STATUSBAR_SetPartBounds (infoPtr, hwnd);
-    InvalidateRect(hwnd, NULL, FALSE);
+    STATUSBAR_SetPartBounds (infoPtr);
+    InvalidateRect(infoPtr->Self, NULL, FALSE);
     return TRUE;
 }
 
 
-static LRESULT
-STATUSBAR_SetTextA (STATUSWINDOWINFO *infoPtr, HWND hwnd, WPARAM wParam, LPARAM lParam)
+static BOOL
+STATUSBAR_SetTextT (STATUSWINDOWINFO *infoPtr, INT nPart, WORD style, 
+		    LPCWSTR text, BOOL isW)
 {
     STATUSWINDOWPART *part=NULL;
-    int	nPart;
-    int	style;
-    LPSTR text;
-    BOOL	changed = FALSE;
-
-    text = (LPSTR) lParam;
-    nPart = ((INT) wParam) & 0x00ff;
-    style = ((INT) wParam) & 0xff00;
+    BOOL changed = FALSE;
 
-    TRACE("part %d, text %s\n",nPart,debugstr_a(text));
+    TRACE("part %d, text %s\n", nPart, debugstr_t(text, isW));
 
-    if (nPart==255)
+    if (nPart == 0x00ff)
 	part = &infoPtr->part0;
-    else if (!infoPtr->simple && infoPtr->parts!=NULL)
+    else if (!infoPtr->simple && infoPtr->parts)
 	part = &infoPtr->parts[nPart];
     if (!part) return FALSE;
 
@@ -703,104 +658,56 @@
 
     part->style = style;
     if (style & SBT_OWNERDRAW) {
-	if (part->text == (LPWSTR)text)
+	if (part->text == text)
 	    return TRUE;
 	part->text = (LPWSTR)text;
     } else {
 	LPWSTR ntext;
 
+	if (text && !isW) {
+	    LPCSTR atxt = (LPCSTR)text;
+            DWORD len = MultiByteToWideChar( CP_ACP, 0, atxt, -1, NULL, 0 );
+	    ntext = COMCTL32_Alloc( (len + 1)*sizeof(WCHAR) );
+	    if (!ntext) return FALSE;
+            MultiByteToWideChar( CP_ACP, 0, atxt, -1, ntext, len );
+	} else if (text) {
+	    ntext = COMCTL32_Alloc( (strlenW(text) + 1)*sizeof(WCHAR) );
+	    if (!ntext) return FALSE;
+	    strcpyW (ntext, text);
+	} else ntext = 0;
+
 	/* check if text is unchanged -> no need to redraw */
 	if (text) {
-            DWORD len = MultiByteToWideChar( CP_ACP, 0, text, -1, NULL, 0 );
-	    LPWSTR tmptext = COMCTL32_Alloc(len*sizeof(WCHAR));
-            MultiByteToWideChar( CP_ACP, 0, text, -1, tmptext, len );
-
-	    if (!changed && part->text && !lstrcmpW(tmptext,part->text)) {
-		COMCTL32_Free(tmptext);
+	    if (!changed && part->text && !lstrcmpW(ntext, part->text)) {
+		if (!isW) COMCTL32_Free(ntext);
 		return TRUE;
 	    }
-	    ntext = tmptext;
 	} else {
 	    if (!changed && !part->text) 
 		return TRUE;
-	    ntext = 0;
 	}
 
 	if (part->text)
 	    COMCTL32_Free (part->text);
 	part->text = ntext;
     }
-    InvalidateRect(hwnd, &part->bound, FALSE);
+    InvalidateRect(infoPtr->Self, &part->bound, FALSE);
 
     return TRUE;
 }
 
 
 static LRESULT
-STATUSBAR_SetTextW (STATUSWINDOWINFO *infoPtr, HWND hwnd, WPARAM wParam, LPARAM lParam)
+STATUSBAR_SetTipTextA (STATUSWINDOWINFO *infoPtr, INT id, LPSTR text)
 {
-    STATUSWINDOWPART *part;
-    INT  nPart, style, len;
-    LPWSTR text;
-    BOOL bRedraw = FALSE;
-
-    text = (LPWSTR) lParam;
-    nPart = ((INT) wParam) & 0x00ff;
-    style = ((INT) wParam) & 0xff00;
-
-    TRACE("part %d -> %s with style %04x\n", nPart, debugstr_w(text), style);
-    if ((infoPtr->simple) || (infoPtr->parts==NULL) || (nPart==255))
-	part = &infoPtr->part0;
-    else
-	part = &infoPtr->parts[nPart];
-    if (!part) return FALSE;
-
-    if(part->style != style)
-        bRedraw = TRUE;
-
-    part->style = style;
-
-    /* FIXME: not sure how/if we can check for change in string with ownerdraw(remove this if we can't)... */
-    if (style & SBT_OWNERDRAW)
-    {
-	part->text = text;
-        bRedraw = TRUE;
-    } else if(!text)
-    {
-        if(part->text)
-        {
-            COMCTL32_Free(part->text);
-            bRedraw = TRUE;
-        }
-        part->text = 0;
-    } else if(!part->text || strcmpW(part->text, text)) /* see if the new string differs from the existing string */
-    {
-	if(part->text) COMCTL32_Free(part->text);
-
-        len = strlenW(text);
-        part->text = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
-	strcpyW(part->text, text);
-        bRedraw = TRUE;
-    }
-
-    if(bRedraw)
-        InvalidateRect(hwnd, &part->bound, FALSE);
-
-    return TRUE;
-}
-
-
-static LRESULT
-STATUSBAR_SetTipTextA (STATUSWINDOWINFO *infoPtr, HWND hwnd, WPARAM wParam, LPARAM lParam)
-{
-    TRACE("part %d: \"%s\"\n", (INT)wParam, (LPSTR)lParam);
+    TRACE("part %d: \"%s\"\n", id, text);
     if (infoPtr->hwndToolTip) {
 	TTTOOLINFOA ti;
 	ti.cbSize = sizeof(TTTOOLINFOA);
-	ti.hwnd = hwnd;
-	ti.uId = (INT)wParam;
+	ti.hwnd = infoPtr->Self;
+	ti.uId = id;
 	ti.hinst = 0;
-	ti.lpszText = (LPSTR)lParam;
+	ti.lpszText = text;
 	SendMessageA (infoPtr->hwndToolTip, TTM_UPDATETIPTEXTA,
 			0, (LPARAM)&ti);
     }
@@ -810,16 +717,16 @@
 
 
 static LRESULT
-STATUSBAR_SetTipTextW (STATUSWINDOWINFO *infoPtr, HWND hwnd, WPARAM wParam, LPARAM lParam)
+STATUSBAR_SetTipTextW (STATUSWINDOWINFO *infoPtr, INT id, LPWSTR text)
 {
-    TRACE("part %d: \"%s\"\n", (INT)wParam, (LPSTR)lParam);
+    TRACE("part %d: \"%s\"\n", id, debugstr_w(text));
     if (infoPtr->hwndToolTip) {
 	TTTOOLINFOW ti;
 	ti.cbSize = sizeof(TTTOOLINFOW);
-	ti.hwnd = hwnd;
-	ti.uId = (INT)wParam;
+	ti.hwnd = infoPtr->Self;
+	ti.uId = id;
 	ti.hinst = 0;
-	ti.lpszText = (LPWSTR)lParam;
+	ti.lpszText = text;
 	SendMessageW (infoPtr->hwndToolTip, TTM_UPDATETIPTEXTW,
 			0, (LPARAM)&ti);
     }
@@ -829,69 +736,98 @@
 
 
 inline static LRESULT
-STATUSBAR_SetUnicodeFormat (STATUSWINDOWINFO *infoPtr, HWND hwnd, WPARAM wParam)
+STATUSBAR_SetUnicodeFormat (STATUSWINDOWINFO *infoPtr, BOOL bUnicode)
 {
     BOOL bOld = infoPtr->bUnicode;
 
-    TRACE("(0x%x)\n", (BOOL)wParam);
-    infoPtr->bUnicode = (BOOL)wParam;
+    TRACE("(0x%x)\n", bUnicode);
+    infoPtr->bUnicode = bUnicode;
 
     return bOld;
 }
 
 
-static LRESULT
-STATUSBAR_Simple (STATUSWINDOWINFO *infoPtr, HWND hwnd, WPARAM wParam, LPARAM lParam)
+static BOOL
+STATUSBAR_Simple (STATUSWINDOWINFO *infoPtr, BOOL simple)
 {
     NMHDR  nmhdr;
 
-    TRACE("(is simple: %d)\n", wParam);
-    if (infoPtr->simple == wParam) /* no need to change */
+    TRACE("(simple=%d)\n", simple);
+    if (infoPtr->simple == simple) /* no need to change */
 	return TRUE;
 
-    infoPtr->simple = (BOOL)wParam;
+    infoPtr->simple = simple;
 
     /* send notification */
-    nmhdr.hwndFrom = hwnd;
-    nmhdr.idFrom = GetWindowLongA (hwnd, GWL_ID);
+    nmhdr.hwndFrom = infoPtr->Self;
+    nmhdr.idFrom = GetWindowLongW (infoPtr->Self, GWL_ID);
     nmhdr.code = SBN_SIMPLEMODECHANGE;
-    SendMessageA (GetParent (hwnd), WM_NOTIFY, 0, (LPARAM)&nmhdr);
-    InvalidateRect(hwnd, NULL, FALSE);
+    SendMessageW (GetParent (infoPtr->Self), WM_NOTIFY, 0, (LPARAM)&nmhdr);
+    InvalidateRect(infoPtr->Self, NULL, FALSE);
     return TRUE;
 }
 
 
 static LRESULT
-STATUSBAR_WMCreate (HWND hwnd, WPARAM wParam, LPARAM lParam)
+STATUSBAR_WMDestroy (STATUSWINDOWINFO *infoPtr)
 {
-    LPCREATESTRUCTA lpCreate = (LPCREATESTRUCTA)lParam;
-    NONCLIENTMETRICSA nclm;
+    int	i;
+
+    TRACE("\n");
+    for (i = 0; i < infoPtr->numParts; i++) {
+	if (infoPtr->parts[i].text && !(infoPtr->parts[i].style & SBT_OWNERDRAW))
+	    COMCTL32_Free (infoPtr->parts[i].text);
+    }
+    if (infoPtr->part0.text && !(infoPtr->part0.style & SBT_OWNERDRAW))
+	COMCTL32_Free (infoPtr->part0.text);
+    COMCTL32_Free (infoPtr->parts);
+
+    /* delete default font */
+    if (infoPtr->hDefaultFont)
+	DeleteObject (infoPtr->hDefaultFont);
+
+    /* delete tool tip control */
+    if (infoPtr->hwndToolTip)
+	DestroyWindow (infoPtr->hwndToolTip);
+
+    COMCTL32_Free (infoPtr);
+    SetWindowLongW(infoPtr->Self, 0, 0);
+    return 0;
+}
+
+
+static LRESULT
+STATUSBAR_WMCreate (HWND hwnd, LPCREATESTRUCTA lpCreate)
+{
+    STATUSWINDOWINFO *infoPtr;
+    NONCLIENTMETRICSW nclm;
     DWORD dwStyle;
-    RECT	rect;
-    int	        width, len;
+    RECT rect;
+    int	width, len, textHeight = 0;
     HDC	hdc;
-    STATUSWINDOWINFO *infoPtr;
 
     TRACE("\n");
     infoPtr = (STATUSWINDOWINFO*)COMCTL32_Alloc (sizeof(STATUSWINDOWINFO));
-    SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
+    if (!infoPtr) goto create_fail;
+    SetWindowLongW (hwnd, 0, (DWORD)infoPtr);
 
-    infoPtr->hwndParent = lpCreate->hwndParent;
+    infoPtr->Self = hwnd;
     infoPtr->numParts = 1;
     infoPtr->parts = 0;
     infoPtr->simple = FALSE;
     infoPtr->clrBk = CLR_DEFAULT;
     infoPtr->hFont = 0;
 
-    /* TODO: send unicode parent notification query (WM_QUERYFORMAT) here */
+    /* FIXME: send unicode parent notification query (WM_QUERYFORMAT) here */
 
     GetClientRect (hwnd, &rect);
     InvalidateRect (hwnd, &rect, 0);
     UpdateWindow(hwnd);
 
-    nclm.cbSize = sizeof(NONCLIENTMETRICSA);
-    SystemParametersInfoA (SPI_GETNONCLIENTMETRICS, nclm.cbSize, &nclm, 0);
-    infoPtr->hDefaultFont = CreateFontIndirectA (&nclm.lfStatusFont);
+    ZeroMemory (&nclm, sizeof(nclm));
+    nclm.cbSize = sizeof(nclm);
+    SystemParametersInfoW (SPI_GETNONCLIENTMETRICS, nclm.cbSize, &nclm, 0);
+    infoPtr->hDefaultFont = CreateFontIndirectW (&nclm.lfStatusFont);
 
     /* initialize simple case */
     infoPtr->part0.bound = rect;
@@ -902,6 +838,7 @@
 
     /* initialize first part */
     infoPtr->parts = COMCTL32_Alloc (sizeof(STATUSWINDOWPART));
+    if (!infoPtr->parts) goto create_fail;
     infoPtr->parts[0].bound = rect;
     infoPtr->parts[0].text = 0;
     infoPtr->parts[0].x = -1;
@@ -913,6 +850,7 @@
 	if (lpCreate->lpszName &&
 	    (len = strlenW ((LPCWSTR)lpCreate->lpszName))) {
 	    infoPtr->parts[0].text = COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
+	    if (!infoPtr->parts[0].text) goto create_fail;
 	    strcpyW (infoPtr->parts[0].text, (LPCWSTR)lpCreate->lpszName);
 	}
     }
@@ -921,104 +859,74 @@
 	    (len = strlen((LPCSTR)lpCreate->lpszName))) {
             DWORD lenW = MultiByteToWideChar( CP_ACP, 0, (LPCSTR)lpCreate->lpszName, -1, NULL, 0 );
 	    infoPtr->parts[0].text = COMCTL32_Alloc (lenW*sizeof(WCHAR));
+	    if (!infoPtr->parts[0].text) goto create_fail;
             MultiByteToWideChar( CP_ACP, 0, (LPCSTR)lpCreate->lpszName, -1,
                                  infoPtr->parts[0].text, lenW );
 	}
     }
 
-    dwStyle = GetWindowLongA(hwnd, GWL_STYLE);
+    dwStyle = GetWindowLongW (hwnd, GWL_STYLE);
 
     /* statusbars on managed windows should not have SIZEGRIP style */
     if ((dwStyle & SBARS_SIZEGRIP) && lpCreate->hwndParent)
-        if (GetWindowLongA(lpCreate->hwndParent, GWL_EXSTYLE) & WS_EX_MANAGED)
-            SetWindowLongA (hwnd, GWL_STYLE, dwStyle & ~SBARS_SIZEGRIP);
+        if (GetWindowLongW (lpCreate->hwndParent, GWL_EXSTYLE) & WS_EX_MANAGED)
+            SetWindowLongW (hwnd, GWL_STYLE, dwStyle & ~SBARS_SIZEGRIP);
 
     if ((hdc = GetDC (0))) {
-	TEXTMETRICA tm;
+	TEXTMETRICW tm;
 	HFONT hOldFont;
 
-	hOldFont = SelectObject (hdc,infoPtr->hDefaultFont);
-	GetTextMetricsA(hdc, &tm);
-	infoPtr->textHeight = tm.tmHeight;
+	hOldFont = SelectObject (hdc, infoPtr->hDefaultFont);
+	GetTextMetricsW (hdc, &tm);
+	textHeight = tm.tmHeight;
 	SelectObject (hdc, hOldFont);
-	ReleaseDC(0, hdc);
+	ReleaseDC (0, hdc);
     }
+    TRACE("    textHeight=%d\n", textHeight);
 
     if (dwStyle & SBT_TOOLTIPS) {
 	infoPtr->hwndToolTip =
-	    CreateWindowExA (0, TOOLTIPS_CLASSA, NULL, 0,
+	    CreateWindowExW (0, TOOLTIPS_CLASSW, NULL, 0,
 			       CW_USEDEFAULT, CW_USEDEFAULT,
 			       CW_USEDEFAULT, CW_USEDEFAULT,
 			     hwnd, 0,
-			     GetWindowLongA (hwnd, GWL_HINSTANCE), NULL);
+			     GetWindowLongW (hwnd, GWL_HINSTANCE), NULL);
 
 	if (infoPtr->hwndToolTip) {
 	    NMTOOLTIPSCREATED nmttc;
 
 	    nmttc.hdr.hwndFrom = hwnd;
-	    nmttc.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID);
+	    nmttc.hdr.idFrom = GetWindowLongW (hwnd, GWL_ID);
 	    nmttc.hdr.code = NM_TOOLTIPSCREATED;
 	    nmttc.hwndToolTips = infoPtr->hwndToolTip;
 
-	    SendMessageA (lpCreate->hwndParent, WM_NOTIFY,
+	    SendMessageW (lpCreate->hwndParent, WM_NOTIFY,
 			    (WPARAM)nmttc.hdr.idFrom, (LPARAM)&nmttc);
-	}
+	} 
     }
 
-    if (!(dwStyle & CCS_NORESIZE)) /* don't resize wnd if it doesn't want it ! */
-    {
+    if (!(dwStyle & CCS_NORESIZE)) { /* don't resize wnd if it doesn't want it ! */
         GetClientRect (GetParent (hwnd), &rect);
         width = rect.right - rect.left;
-        infoPtr->height = infoPtr->textHeight + 4 + VERT_BORDER;
+        infoPtr->height = textHeight + 4 + VERT_BORDER;
         SetWindowPos(hwnd, 0, lpCreate->x, lpCreate->y - 1,
 			width, infoPtr->height, SWP_NOZORDER);
-        STATUSBAR_SetPartBounds (infoPtr, hwnd);
+        STATUSBAR_SetPartBounds (infoPtr);
     }
 
     return 0;
-}
-
-
-static LRESULT
-STATUSBAR_WMDestroy (STATUSWINDOWINFO *infoPtr, HWND hwnd)
-{
-    int	i;
-
-    TRACE("\n");
-    for (i = 0; i < infoPtr->numParts; i++) {
-	if (infoPtr->parts[i].text && !(infoPtr->parts[i].style & SBT_OWNERDRAW))
-	    COMCTL32_Free (infoPtr->parts[i].text);
-    }
-    if (infoPtr->part0.text && !(infoPtr->part0.style & SBT_OWNERDRAW))
-	COMCTL32_Free (infoPtr->part0.text);
-    COMCTL32_Free (infoPtr->parts);
-
-    /* delete default font */
-    if (infoPtr->hDefaultFont)
-	DeleteObject (infoPtr->hDefaultFont);
-
-    /* delete tool tip control */
-    if (infoPtr->hwndToolTip)
-	DestroyWindow (infoPtr->hwndToolTip);
-
-    COMCTL32_Free (infoPtr);
-    SetWindowLongA(hwnd, 0, 0);
-    return 0;
-}
-
-
-static inline LRESULT
-STATUSBAR_WMGetFont (STATUSWINDOWINFO *infoPtr, HWND hwnd)
-{
-    TRACE("\n");
-    return infoPtr->hFont? infoPtr->hFont : infoPtr->hDefaultFont;
+    
+create_fail:
+    TRACE("    failed!\n");
+    if (infoPtr) STATUSBAR_WMDestroy(infoPtr);
+    return -1;
 }
 
 
 /* in contrast to SB_GETTEXT*, WM_GETTEXT handles the text
  * of the first part only (usual behaviour) */
-static LRESULT
-STATUSBAR_WMGetText (STATUSWINDOWINFO *infoPtr, HWND hwnd, WPARAM wParam, LPARAM lParam)
+static INT
+STATUSBAR_WMGetText (STATUSWINDOWINFO *infoPtr, INT size, LPWSTR buf)
 {
     INT len;
 
@@ -1030,12 +938,12 @@
     else
         len = WideCharToMultiByte( CP_ACP, 0, infoPtr->parts[0].text, -1, NULL, 0, NULL, NULL )-1;
 
-    if (wParam > len) {
+    if (size > len) {
 	if (infoPtr->bUnicode)
-	    strcpyW ((LPWSTR)lParam, infoPtr->parts[0].text);
+	    strcpyW (buf, infoPtr->parts[0].text);
 	else
             WideCharToMultiByte( CP_ACP, 0, infoPtr->parts[0].text, -1,
-                                 (LPSTR)lParam, len+1, NULL, NULL );
+                                 (LPSTR)buf, len+1, NULL, NULL );
 	return len;
     }
 
@@ -1043,28 +951,18 @@
 }
 
 
-inline static LRESULT
-STATUSBAR_WMMouseMove (STATUSWINDOWINFO *infoPtr, HWND hwnd, WPARAM wParam, LPARAM lParam)
-{
-    if (infoPtr->hwndToolTip)
-	STATUSBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
-			      WM_MOUSEMOVE, wParam, lParam);
-    return 0;
-}
-
-
-static LRESULT
-STATUSBAR_WMNCHitTest (HWND hwnd, WPARAM wParam, LPARAM lParam)
+static BOOL
+STATUSBAR_WMNCHitTest (STATUSWINDOWINFO *infoPtr, INT x, INT y)
 {
-    if (GetWindowLongA (hwnd, GWL_STYLE) & SBARS_SIZEGRIP) {
+    if (GetWindowLongW (infoPtr->Self, GWL_STYLE) & SBARS_SIZEGRIP) {
 	RECT  rect;
 	POINT pt;
 
-	GetClientRect (hwnd, &rect);
+	GetClientRect (infoPtr->Self, &rect);
 
-	pt.x = (INT)LOWORD(lParam);
-	pt.y = (INT)HIWORD(lParam);
-	ScreenToClient (hwnd, &pt);
+	pt.x = x;
+	pt.y = y;
+	ScreenToClient (infoPtr->Self, &pt);
 
 	rect.left = rect.right - 13;
 	rect.top += 2;
@@ -1073,59 +971,39 @@
 	    return HTBOTTOMRIGHT;
     }
 
-    /* FIXME: instead check result in StatusWindowProc and call if needed ? */
-    return DefWindowProcA (hwnd, WM_NCHITTEST, wParam, lParam);
-}
-
-
-static inline LRESULT
-STATUSBAR_WMNCLButtonDown (HWND hwnd, WPARAM wParam, LPARAM lParam)
-{
-    TRACE("\n");
-    PostMessageA (GetParent (hwnd), WM_NCLBUTTONDOWN, wParam, lParam);
-    return 0;
-}
-
-
-static inline LRESULT
-STATUSBAR_WMNCLButtonUp (HWND hwnd, WPARAM wParam, LPARAM lParam)
-{
-    TRACE("\n");
-    PostMessageA (GetParent (hwnd), WM_NCLBUTTONUP, wParam, lParam);
-    return 0;
+    return HTERROR;
 }
 
 
 static LRESULT
-STATUSBAR_WMPaint (STATUSWINDOWINFO *infoPtr, HWND hwnd, WPARAM wParam)
+STATUSBAR_WMPaint (STATUSWINDOWINFO *infoPtr, HDC hdc)
 {
-    HDC hdc;
     PAINTSTRUCT ps;
 
     TRACE("\n");
-    hdc = wParam==0 ? BeginPaint (hwnd, &ps) : (HDC)wParam;
-    STATUSBAR_Refresh (infoPtr, hwnd, hdc);
-    if (!wParam)
-	EndPaint (hwnd, &ps);
+    if (hdc) return STATUSBAR_Refresh (infoPtr, hdc);
+    hdc = BeginPaint (infoPtr->Self, &ps);
+    STATUSBAR_Refresh (infoPtr, hdc);
+    EndPaint (infoPtr->Self, &ps);
 
     return 0;
 }
 
 
 static LRESULT
-STATUSBAR_WMSetFont (STATUSWINDOWINFO *infoPtr, HWND hwnd, WPARAM wParam, LPARAM lParam)
+STATUSBAR_WMSetFont (STATUSWINDOWINFO *infoPtr, HFONT font, BOOL redraw)
 {
-    infoPtr->hFont = (HFONT)wParam;
+    infoPtr->hFont = font;
     TRACE("%04x\n", infoPtr->hFont);
-    if (LOWORD(lParam) == TRUE)
-        InvalidateRect(hwnd, NULL, FALSE);
+    if (redraw)
+        InvalidateRect(infoPtr->Self, NULL, FALSE);
 
     return 0;
 }
 
 
-static LRESULT
-STATUSBAR_WMSetText (STATUSWINDOWINFO *infoPtr, HWND hwnd, WPARAM wParam, LPARAM lParam)
+static BOOL
+STATUSBAR_WMSetText (STATUSWINDOWINFO *infoPtr, LPCSTR text)
 {
     STATUSWINDOWPART *part;
     int len;
@@ -1140,59 +1018,52 @@
         COMCTL32_Free (part->text);
     part->text = 0;
     if (infoPtr->bUnicode) {
-	if (lParam && (len = strlenW((LPCWSTR)lParam))) {
+	if (text && (len = strlenW((LPCWSTR)text))) {
 	    part->text = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));
-	    strcpyW (part->text, (LPCWSTR)lParam);
+	    if (!part->text) return FALSE;
+	    strcpyW (part->text, (LPCWSTR)text);
 	}
     }
     else {
-	if (lParam && (len = lstrlenA((LPCSTR)lParam))) {
-            DWORD lenW = MultiByteToWideChar( CP_ACP, 0, (LPCSTR)lParam, -1, NULL, 0 );
+	if (text && (len = lstrlenA(text))) {
+            DWORD lenW = MultiByteToWideChar( CP_ACP, 0, text, -1, NULL, 0 );
             part->text = COMCTL32_Alloc (lenW*sizeof(WCHAR));
-            MultiByteToWideChar( CP_ACP, 0, (LPCSTR)lParam, -1, part->text, lenW );
+	    if (!part->text) return FALSE;
+            MultiByteToWideChar( CP_ACP, 0, text, -1, part->text, lenW );
 	}
     }
 
-    InvalidateRect(hwnd, &part->bound, FALSE);
+    InvalidateRect(infoPtr->Self, &part->bound, FALSE);
 
     return TRUE;
 }
 
 
-static LRESULT
-STATUSBAR_WMSize (STATUSWINDOWINFO *infoPtr, HWND hwnd, WPARAM wParam, LPARAM lParam)
+static BOOL
+STATUSBAR_WMSize (STATUSWINDOWINFO *infoPtr, WORD flags)
 {
-    INT  width, x, y, flags;
+    INT  width, x, y;
     RECT parent_rect;
-    DWORD dwStyle;
 
     /* Need to resize width to match parent */
-    flags = (INT) wParam;
-
     TRACE("flags %04x\n", flags);
-    /* FIXME for flags =
-     * SIZE_MAXIMIZED, SIZE_MAXSHOW, SIZE_MINIMIZED, SIZE_RESTORED
-     */
-
-    dwStyle = GetWindowLongA(hwnd, GWL_STYLE);
-    if (!(dwStyle & CCS_NORESIZE)) /* don't resize wnd if it doesn't want it ! */
-    {
-        if (flags == SIZE_RESTORED) {
-	    /* width and height don't apply */
-	    GetClientRect (infoPtr->hwndParent, &parent_rect);
-	    width = parent_rect.right - parent_rect.left;
-	    x = parent_rect.left;
-	    y = parent_rect.bottom - infoPtr->height;
-	    MoveWindow (hwnd, parent_rect.left, 
-		      parent_rect.bottom - infoPtr->height,
-		      width, infoPtr->height, TRUE);
-	    STATUSBAR_SetPartBounds (infoPtr, hwnd);
-        }
-	return 0; /* FIXME: ok to return here ? */
-    }
 
-    /* FIXME: instead check result in StatusWindowProc and call if needed ? */
-    return DefWindowProcA (hwnd, WM_SIZE, wParam, lParam);
+    if (flags != SIZE_RESTORED) {
+	WARN("flags MUST be SIZE_RESTORED\n");
+	return FALSE;
+    }
+    if (GetWindowLongW(infoPtr->Self, GWL_STYLE) & CCS_NORESIZE) return FALSE;
+    
+    /* width and height don't apply */
+    GetClientRect (GetParent(infoPtr->Self), &parent_rect);
+    width = parent_rect.right - parent_rect.left;
+    x = parent_rect.left;
+    y = parent_rect.bottom - infoPtr->height;
+    MoveWindow (infoPtr->Self, parent_rect.left, 
+		parent_rect.bottom - infoPtr->height,
+		width, infoPtr->height, TRUE);
+    STATUSBAR_SetPartBounds (infoPtr);
+    return TRUE;
 }
 
 
@@ -1203,9 +1074,9 @@
 
     TRACE("code %04x\n", code);
     nmhdr.hwndFrom = hwnd;
-    nmhdr.idFrom = GetWindowLongA (hwnd, GWL_ID);
+    nmhdr.idFrom = GetWindowLongW (hwnd, GWL_ID);
     nmhdr.code = code;
-    SendMessageA (GetParent (hwnd), WM_NOTIFY, 0, (LPARAM)&nmhdr);
+    SendMessageW (GetParent (hwnd), WM_NOTIFY, 0, (LPARAM)&nmhdr);
     return 0;
 }
 
@@ -1215,91 +1086,92 @@
 StatusWindowProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
 {
     STATUSWINDOWINFO *infoPtr = STATUSBAR_GetInfoPtr(hwnd);
+    INT nPart = ((INT) wParam) & 0x00ff;
+    LRESULT res;
 
     TRACE("hwnd=%x msg=%x wparam=%x lparam=%lx\n", hwnd, msg, wParam, lParam);
-    if (!(infoPtr) && (msg != WM_CREATE))
-        return DefWindowProcA (hwnd, msg, wParam, lParam);
+    if (!infoPtr && msg != WM_CREATE)
+        return DefWindowProcW (hwnd, msg, wParam, lParam);
 
     switch (msg) {
 	case SB_GETBORDERS:
-	    return STATUSBAR_GetBorders (lParam);
+	    return STATUSBAR_GetBorders ((INT *)lParam);
 
 	case SB_GETICON:
-	    return STATUSBAR_GetIcon (infoPtr, hwnd, wParam);
+	    return STATUSBAR_GetIcon (infoPtr, nPart);
 
 	case SB_GETPARTS:
-	    return STATUSBAR_GetParts (infoPtr, hwnd, wParam, lParam);
+	    return STATUSBAR_GetParts (infoPtr, (INT)wParam, (INT *)lParam);
 
 	case SB_GETRECT:
-	    return STATUSBAR_GetRect (infoPtr, hwnd, wParam, lParam);
+	    return STATUSBAR_GetRect (infoPtr, nPart, (LPRECT)lParam);
 
 	case SB_GETTEXTA:
-	    return STATUSBAR_GetTextA (infoPtr, hwnd, wParam, lParam);
+	    return STATUSBAR_GetTextA (infoPtr, nPart, (LPSTR)lParam);
 
 	case SB_GETTEXTW:
-	    return STATUSBAR_GetTextW (infoPtr, hwnd, wParam, lParam);
+	    return STATUSBAR_GetTextW (infoPtr, nPart, (LPWSTR)lParam);
 
 	case SB_GETTEXTLENGTHA:
 	case SB_GETTEXTLENGTHW:
-	    return STATUSBAR_GetTextLength (infoPtr, hwnd, wParam);
+	    return STATUSBAR_GetTextLength (infoPtr, nPart);
 
 	case SB_GETTIPTEXTA:
-	    return STATUSBAR_GetTipTextA (infoPtr, hwnd, wParam, lParam);
+	    return STATUSBAR_GetTipTextA (infoPtr,  LOWORD(wParam), (LPSTR)lParam,  HIWORD(wParam));
 
 	case SB_GETTIPTEXTW:
-	    return STATUSBAR_GetTipTextW (infoPtr, hwnd, wParam, lParam);
+	    return STATUSBAR_GetTipTextW (infoPtr,  LOWORD(wParam), (LPWSTR)lParam,  HIWORD(wParam));
 
 	case SB_GETUNICODEFORMAT:
-	    return STATUSBAR_GetUnicodeFormat (infoPtr, hwnd);
+	    return infoPtr->bUnicode;
 
 	case SB_ISSIMPLE:
-	    return STATUSBAR_IsSimple (infoPtr, hwnd);
+	    return infoPtr->simple;
 
 	case SB_SETBKCOLOR:
-	    return STATUSBAR_SetBkColor (infoPtr, hwnd, wParam, lParam);
+	    return STATUSBAR_SetBkColor (infoPtr, (COLORREF)lParam);
 
 	case SB_SETICON:
-	    return STATUSBAR_SetIcon (infoPtr, hwnd, wParam, lParam);
+	    return STATUSBAR_SetIcon (infoPtr, nPart, (HICON)lParam);
 
 	case SB_SETMINHEIGHT:
-	    return STATUSBAR_SetMinHeight (infoPtr, hwnd, wParam, lParam);
+	    return STATUSBAR_SetMinHeight (infoPtr, (INT)wParam);
 
 	case SB_SETPARTS:	
-	    return STATUSBAR_SetParts (infoPtr, hwnd, wParam, lParam);
+	    return STATUSBAR_SetParts (infoPtr, (INT)wParam, (LPINT)lParam);
 
 	case SB_SETTEXTA:
-	    return STATUSBAR_SetTextA (infoPtr, hwnd, wParam, lParam);
+	    return STATUSBAR_SetTextT (infoPtr, nPart, wParam & 0xff00, (LPCWSTR)lParam, FALSE);
 
 	case SB_SETTEXTW:
-	    return STATUSBAR_SetTextW (infoPtr, hwnd, wParam, lParam);
+	    return STATUSBAR_SetTextT (infoPtr, nPart, wParam & 0xff00, (LPCWSTR)lParam, TRUE);
 
 	case SB_SETTIPTEXTA:
-	    return STATUSBAR_SetTipTextA (infoPtr, hwnd, wParam, lParam);
+	    return STATUSBAR_SetTipTextA (infoPtr, (INT)wParam, (LPSTR)lParam);
 
 	case SB_SETTIPTEXTW:
-	    return STATUSBAR_SetTipTextW (infoPtr, hwnd, wParam, lParam);
+	    return STATUSBAR_SetTipTextW (infoPtr, (INT)wParam, (LPWSTR)lParam);
 
 	case SB_SETUNICODEFORMAT:
-	    return STATUSBAR_SetUnicodeFormat (infoPtr, hwnd, wParam);
+	    return STATUSBAR_SetUnicodeFormat (infoPtr, (BOOL)wParam);
 
 	case SB_SIMPLE:
-	    return STATUSBAR_Simple (infoPtr, hwnd, wParam, lParam);
-
+	    return STATUSBAR_Simple (infoPtr, (BOOL)wParam);
 
 	case WM_CREATE:
-	    return STATUSBAR_WMCreate (hwnd, wParam, lParam);
+	    return STATUSBAR_WMCreate (hwnd, (LPCREATESTRUCTA)lParam);
 
 	case WM_DESTROY:
-	    return STATUSBAR_WMDestroy (infoPtr, hwnd);
+	    return STATUSBAR_WMDestroy (infoPtr);
 
 	case WM_GETFONT:
-            return STATUSBAR_WMGetFont (infoPtr, hwnd);
+	    return infoPtr->hFont? infoPtr->hFont : infoPtr->hDefaultFont;
 
 	case WM_GETTEXT:
-            return STATUSBAR_WMGetText (infoPtr, hwnd, wParam, lParam);
+            return STATUSBAR_WMGetText (infoPtr, (INT)wParam, (LPWSTR)lParam);
 
 	case WM_GETTEXTLENGTH:
-	    return STATUSBAR_GetTextLength (infoPtr, hwnd, 0);
+	    return STATUSBAR_GetTextLength (infoPtr, 0);
 
 	case WM_LBUTTONDBLCLK:
             return STATUSBAR_SendNotify (hwnd, NM_DBLCLK);
@@ -1308,19 +1180,21 @@
 	    return STATUSBAR_SendNotify (hwnd, NM_CLICK);
 
 	case WM_MOUSEMOVE:
-            return STATUSBAR_WMMouseMove (infoPtr, hwnd, wParam, lParam);
+	    return STATUSBAR_Relay2Tip (infoPtr, msg, wParam, lParam);
 
 	case WM_NCHITTEST:
-            return STATUSBAR_WMNCHitTest (hwnd, wParam, lParam);
-
-	case WM_NCLBUTTONDOWN:
-	    return STATUSBAR_WMNCLButtonDown (hwnd, wParam, lParam);
+	    res = STATUSBAR_WMNCHitTest(infoPtr, (INT)LOWORD(lParam),
+			                (INT)HIWORD(lParam));
+	    if (res != HTERROR) return res;
+	    return DefWindowProcW (hwnd, msg, wParam, lParam);
 
 	case WM_NCLBUTTONUP:
-	    return STATUSBAR_WMNCLButtonUp (hwnd, wParam, lParam);
+	case WM_NCLBUTTONDOWN:
+    	    PostMessageW (GetParent (hwnd), msg, wParam, lParam);
+	    return 0;
 
 	case WM_PAINT:
-	    return STATUSBAR_WMPaint (infoPtr, hwnd, wParam);
+	    return STATUSBAR_WMPaint (infoPtr, (HDC)wParam);
 
 	case WM_RBUTTONDBLCLK:
 	    return STATUSBAR_SendNotify (hwnd, NM_RDBLCLK);
@@ -1329,19 +1203,21 @@
 	    return STATUSBAR_SendNotify (hwnd, NM_RCLICK);
 
 	case WM_SETFONT:
-	    return STATUSBAR_WMSetFont (infoPtr, hwnd, wParam, lParam);
+	    return STATUSBAR_WMSetFont (infoPtr, (HFONT)wParam, LOWORD(lParam));
 
 	case WM_SETTEXT:
-	    return STATUSBAR_WMSetText (infoPtr, hwnd, wParam, lParam);
+	    return STATUSBAR_WMSetText (infoPtr, (LPCSTR)lParam);
+
 
 	case WM_SIZE:
-	    return STATUSBAR_WMSize (infoPtr, hwnd, wParam, lParam);
+	    if (STATUSBAR_WMSize (infoPtr, (WORD)wParam)) return 0;
+            return DefWindowProcW (hwnd, msg, wParam, lParam);
 
 	default:
 	    if (msg >= WM_USER)
 		ERR("unknown msg %04x wp=%04x lp=%08lx\n",
 		     msg, wParam, lParam);
-	    return DefWindowProcA (hwnd, msg, wParam, lParam);
+	    return DefWindowProcW (hwnd, msg, wParam, lParam);
     }
     return 0;
 }
@@ -1353,21 +1229,21 @@
  * Registers the status window class.
  */
 
-VOID
+void
 STATUS_Register (void)
 {
-    WNDCLASSA wndClass;
+    WNDCLASSW wndClass;
 
-    ZeroMemory (&wndClass, sizeof(WNDCLASSA));
+    ZeroMemory (&wndClass, sizeof(WNDCLASSW));
     wndClass.style         = CS_GLOBALCLASS | CS_DBLCLKS | CS_VREDRAW;
     wndClass.lpfnWndProc   = (WNDPROC)StatusWindowProc;
     wndClass.cbClsExtra    = 0;
     wndClass.cbWndExtra    = sizeof(STATUSWINDOWINFO *);
-    wndClass.hCursor       = LoadCursorA (0, IDC_ARROWA);
+    wndClass.hCursor       = LoadCursorW (0, IDC_ARROWW);
     wndClass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
-    wndClass.lpszClassName = STATUSCLASSNAMEA;
+    wndClass.lpszClassName = STATUSCLASSNAMEW;
  
-    RegisterClassA (&wndClass);
+    RegisterClassW (&wndClass);
 }
 
 
@@ -1377,9 +1253,9 @@
  * Unregisters the status window class.
  */
 
-VOID
+void
 STATUS_Unregister (void)
 {
-    UnregisterClassA (STATUSCLASSNAMEA, (HINSTANCE)NULL);
+    UnregisterClassW (STATUSCLASSNAMEW, (HINSTANCE)NULL);
 }
 


-- 
Dimi.




More information about the wine-patches mailing list