Index: trunk/src/comctl32/CCBase.cpp
===================================================================
--- trunk/src/comctl32/CCBase.cpp	(revision 2893)
+++ trunk/src/comctl32/CCBase.cpp	(revision 2895)
@@ -1,3 +1,3 @@
-/* $Id: CCBase.cpp,v 1.1 2000-02-23 17:09:39 cbratschi Exp $ */
+/* $Id: CCBase.cpp,v 1.2 2000-02-25 17:00:15 cbratschi Exp $ */
 /*
  * COMCTL32 Base Functions and Macros for all Controls
@@ -30,4 +30,5 @@
 
   setInfoPtr(hwnd,infoPtr);
+  ZeroMemory(infoPtr,dwSize);
   infoPtr->dwSize        = dwSize;
   infoPtr->iVersion      = 0;
@@ -90,5 +91,5 @@
       } else return IsWindowUnicode(hwnd);
 
-    case WM_NOTIFY:
+    case WM_NOTIFYFORMAT:
     {
       infoPtr = getInfoPtr(hwnd);
@@ -128,4 +129,18 @@
 //Notifications
 
+BOOL isUnicodeNotify(COMCTL32_HEADER *infoPtr)
+{
+  if (!infoPtr) return FALSE;
+
+  return infoPtr->uNotifyFormat == NFR_UNICODE;
+}
+
+BOOL isUnicodeNotify(HWND hwnd)
+{
+  COMCTL32_HEADER *infoPtr = getInfoPtr(hwnd);
+
+  return isUnicodeNotify(infoPtr);
+}
+
 LRESULT sendNotify(HWND hwnd,UINT code)
 {
@@ -136,5 +151,5 @@
   nmhdr.code     = code;
 
-  return SendMessageA(hwnd,WM_NOTIFY,nmhdr.idFrom,(LPARAM)&nmhdr);
+  return SendMessageA(GetParent(hwnd),WM_NOTIFY,nmhdr.idFrom,(LPARAM)&nmhdr);
 }
 
@@ -147,5 +162,5 @@
   nmhdr->code     = code;
 
-  return SendMessageA(hwnd,WM_NOTIFY,nmhdr->idFrom,(LPARAM)nmhdr);
+  return SendMessageA(GetParent(hwnd),WM_NOTIFY,nmhdr->idFrom,(LPARAM)nmhdr);
 }
 
Index: trunk/src/comctl32/CCBase.h
===================================================================
--- trunk/src/comctl32/CCBase.h	(revision 2893)
+++ trunk/src/comctl32/CCBase.h	(revision 2895)
@@ -1,3 +1,3 @@
-/* $Id: CCBase.h,v 1.2 2000-02-23 17:09:40 cbratschi Exp $ */
+/* $Id: CCBase.h,v 1.3 2000-02-25 17:00:15 cbratschi Exp $ */
 /*
  * COMCTL32 Base Functions and Macros for all Controls
@@ -25,4 +25,7 @@
 LRESULT defComCtl32ProcW(HWND hwnd,UINT Msg,WPARAM wParam,LPARAM lParam);
 
+BOOL isUnicodeNotify(COMCTL32_HEADER *infoPtr);
+BOOL isUnicodeNotify(HWND hwnd);
+
 LRESULT sendNotify(HWND hwnd,UINT code);
 LRESULT sendNotify(HWND hwnd,UINT code,LPNMHDR nmhdr);
Index: trunk/src/comctl32/comboex.cpp
===================================================================
--- trunk/src/comctl32/comboex.cpp	(revision 2893)
+++ trunk/src/comctl32/comboex.cpp	(revision 2895)
@@ -1,3 +1,3 @@
-/* $Id: comboex.cpp,v 1.1 2000-02-23 17:09:40 cbratschi Exp $ */
+/* $Id: comboex.cpp,v 1.2 2000-02-25 17:00:15 cbratschi Exp $ */
 /*
  * ComboBoxEx control
@@ -311,7 +311,4 @@
     WNDCLASSA wndClass;
 
-//SvL: Don't check this now
-//    if (GlobalFindAtomA (WC_COMBOBOXEXA)) return;
-
     ZeroMemory (&wndClass, sizeof(WNDCLASSA));
     wndClass.style         = CS_GLOBALCLASS;
@@ -330,6 +327,5 @@
 COMBOEX_Unregister (VOID)
 {
-    if (GlobalFindAtomA (WC_COMBOBOXEXA))
-        UnregisterClassA (WC_COMBOBOXEXA, (HINSTANCE)NULL);
-}
-
+    UnregisterClassA (WC_COMBOBOXEXA, (HINSTANCE)NULL);
+}
+
Index: trunk/src/comctl32/datetime.cpp
===================================================================
--- trunk/src/comctl32/datetime.cpp	(revision 2893)
+++ trunk/src/comctl32/datetime.cpp	(revision 2895)
@@ -1,3 +1,3 @@
-/* $Id: datetime.cpp,v 1.1 2000-02-23 17:09:41 cbratschi Exp $ */
+/* $Id: datetime.cpp,v 1.2 2000-02-25 17:00:15 cbratschi Exp $ */
 /*
  * Date and time picker control
@@ -19,4 +19,5 @@
 #include "winbase.h"
 #include "commctrl.h"
+#include "ccbase.h"
 #include "datetime.h"
 #include "monthcal.h"
@@ -25,8 +26,5 @@
 
 
-#define DATETIME_GetInfoPtr(hwnd) ((DATETIME_INFO *)GetWindowLongA (hwnd, 0))
-static BOOL
-
-DATETIME_SendSimpleNotify (HWND hwnd, UINT code);
+#define DATETIME_GetInfoPtr(hwnd) ((DATETIME_INFO*)getInfoPtr(hwnd))
 
 static char *days[] = {"Sunday", "Monday", "Tuesday", "Wednesday",
@@ -282,5 +280,5 @@
 
                         SetFocus (hwnd);
-                        DATETIME_SendSimpleNotify (hwnd, DTN_DROPDOWN);
+                        sendNotify(hwnd,DTN_DROPDOWN);
         }
     return 0;
@@ -335,5 +333,5 @@
 
         if (infoPtr->select) {
-                        DATETIME_SendSimpleNotify (hwnd, NM_KILLFOCUS);
+                        sendNotify(hwnd,NM_KILLFOCUS);
                         infoPtr->select&= ~DTHT_GOTFOCUS;
         }
@@ -356,5 +354,5 @@
 
         if (infoPtr->select) {
-                        DATETIME_SendSimpleNotify (hwnd, NM_SETFOCUS);
+                        sendNotify(hwnd,NM_SETFOCUS);
                         infoPtr->select|=DTHT_GOTFOCUS;
         }
@@ -367,23 +365,4 @@
 
 
-static BOOL
-DATETIME_SendSimpleNotify (HWND hwnd, UINT code)
-{
-    NMHDR nmhdr;
-
-    //TRACE("%x\n",code);
-    nmhdr.hwndFrom = hwnd;
-    nmhdr.idFrom   = GetWindowLongA( hwnd, GWL_ID);
-    nmhdr.code     = code;
-
-    return (BOOL) SendMessageA (GetParent (hwnd), WM_NOTIFY,
-                                   (WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr);
-}
-
-
-
-
-
-
 static LRESULT
 DATETIME_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
@@ -393,11 +372,9 @@
 
     /* allocate memory for info structure */
-    infoPtr = (DATETIME_INFO *)COMCTL32_Alloc (sizeof(DATETIME_INFO));
+    infoPtr = (DATETIME_INFO*)initControl(hwnd,sizeof(DATETIME_INFO));
     if (infoPtr == NULL) {
         //ERR("could not allocate info memory!\n");
         return 0;
     }
-
-    SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
 
         if (dwStyle & DTS_SHOWNONE) {
@@ -431,7 +408,6 @@
 DATETIME_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
 {
-    DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);
-
-    COMCTL32_Free (infoPtr);
+    doneControl(hwnd);
+
     return 0;
 }
@@ -513,5 +489,5 @@
                 //ERR("unknown msg %04x wp=%08x lp=%08lx\n",
                 //     uMsg, wParam, lParam);
-            return DefWindowProcA (hwnd, uMsg, wParam, lParam);
+            return defComCtl32ProcA (hwnd, uMsg, wParam, lParam);
     }
     return 0;
@@ -523,7 +499,4 @@
 {
     WNDCLASSA wndClass;
-
-//SvL: Don't check this now
-//    if (GlobalFindAtomA (DATETIMEPICK_CLASSA)) return;
 
     ZeroMemory (&wndClass, sizeof(WNDCLASSA));
@@ -543,6 +516,5 @@
 DATETIME_Unregister (void)
 {
-    if (GlobalFindAtomA (DATETIMEPICK_CLASSA))
-        UnregisterClassA (DATETIMEPICK_CLASSA, (HINSTANCE)NULL);
-}
-
+    UnregisterClassA (DATETIMEPICK_CLASSA, (HINSTANCE)NULL);
+}
+
Index: trunk/src/comctl32/flatsb.cpp
===================================================================
--- trunk/src/comctl32/flatsb.cpp	(revision 2893)
+++ trunk/src/comctl32/flatsb.cpp	(revision 2895)
@@ -1,3 +1,3 @@
-/* $Id: flatsb.cpp,v 1.1 2000-02-23 17:09:41 cbratschi Exp $ */
+/* $Id: flatsb.cpp,v 1.2 2000-02-25 17:00:15 cbratschi Exp $ */
 /*
  * Flat Scrollbar control
@@ -20,8 +20,9 @@
 #include "winbase.h"
 #include "commctrl.h"
+#include "ccbase.h"
 #include "flatsb.h"
 
 
-#define FlatSB_GetInfoPtr(hwnd) ((FLATSB_INFO*)GetWindowLongA (hwnd, 0))
+#define FlatSB_GetInfoPtr(hwnd) ((FLATSB_INFO*)getInfoPtr(hwnd))
 
 
@@ -144,5 +145,5 @@
 //              ERR_(datetime)("unknown msg %04x wp=%08x lp=%08lx\n",
 //                   uMsg, wParam, lParam);
-            return DefWindowProcA (hwnd, uMsg, wParam, lParam);
+            return defComCtl32ProcA (hwnd, uMsg, wParam, lParam);
     }
     return 0;
@@ -154,7 +155,4 @@
 {
     WNDCLASSA wndClass;
-
-//SvL: Don't check this now
-//    if (GlobalFindAtomA (FLATSB_CLASSA)) return;
 
     ZeroMemory (&wndClass, sizeof(WNDCLASSA));
@@ -174,6 +172,5 @@
 FLATSB_Unregister (VOID)
 {
-    if (GlobalFindAtomA (FLATSB_CLASSA))
-        UnregisterClassA (FLATSB_CLASSA, (HINSTANCE)NULL);
+    UnregisterClassA (FLATSB_CLASSA, (HINSTANCE)NULL);
 }
 
Index: trunk/src/comctl32/header.cpp
===================================================================
--- trunk/src/comctl32/header.cpp	(revision 2893)
+++ trunk/src/comctl32/header.cpp	(revision 2895)
@@ -1,3 +1,3 @@
-/* $Id: header.cpp,v 1.1 2000-02-23 17:09:42 cbratschi Exp $ */
+/* $Id: header.cpp,v 1.2 2000-02-25 17:00:15 cbratschi Exp $ */
 /*
  *  Header control
@@ -21,4 +21,5 @@
 #include "winbase.h"
 #include "commctrl.h"
+#include "ccbase.h"
 #include "header.h"
 #include "comctl32.h"
@@ -33,5 +34,5 @@
 #define TIMER_MS       200
 
-#define HEADER_GetInfoPtr(hwnd) ((HEADER_INFO *)GetWindowLongA(hwnd,0))
+#define HEADER_GetInfoPtr(hwnd) ((HEADER_INFO*)getInfoPtr(hwnd))
 
 static VOID
@@ -46,37 +47,14 @@
     if (phdi->iImage == I_IMAGECALLBACK)
     {
-      if (IsWindowUnicode(GetParent(hwnd)))
-      {
-        NMHDDISPINFOW nmhdr;
-
-        nmhdr.hdr.hwndFrom = hwnd;
-        nmhdr.hdr.idFrom   = GetWindowLongW(hwnd,GWL_ID);
-        nmhdr.hdr.code     = HDN_GETDISPINFOW;
-        nmhdr.iItem      = iItem;
-        nmhdr.mask       = HDI_IMAGE;
-        nmhdr.iImage     = 0;
-        nmhdr.lParam     = phdi->lParam;
-
-        SendMessageW(GetParent(hwnd),WM_NOTIFY,(WPARAM)nmhdr.hdr.idFrom,(LPARAM)&nmhdr);
-
-        iImage = nmhdr.iImage;
-        if (nmhdr.mask & HDI_DI_SETITEM) phdi->iImage = iImage;
-      } else
-      {
-        NMHDDISPINFOA nmhdr;
-
-        nmhdr.hdr.hwndFrom = hwnd;
-        nmhdr.hdr.idFrom   = GetWindowLongA(hwnd,GWL_ID);
-        nmhdr.hdr.code     = HDN_GETDISPINFOA;
-        nmhdr.iItem      = iItem;
-        nmhdr.mask       = HDI_IMAGE;
-        nmhdr.iImage     = 0;
-        nmhdr.lParam     = phdi->lParam;
-
-        SendMessageA(GetParent(hwnd),WM_NOTIFY,(WPARAM)nmhdr.hdr.idFrom,(LPARAM)&nmhdr);
-
-        iImage = nmhdr.iImage;
-        if (nmhdr.mask & HDI_DI_SETITEM) phdi->iImage = iImage;
-      }
+      NMHDDISPINFOW nmhdr;
+
+      nmhdr.iItem      = iItem;
+      nmhdr.mask       = HDI_IMAGE;
+      nmhdr.iImage     = 0;
+      nmhdr.lParam     = phdi->lParam;
+      sendNotify(hwnd,isUnicodeNotify(&infoPtr->header) ? HDN_GETDISPINFOW:HDN_GETDISPINFOA,&nmhdr.hdr);
+
+      iImage = nmhdr.iImage;
+      if (nmhdr.mask & HDI_DI_SETITEM) phdi->iImage = iImage;
     } else iImage = phdi->iImage;
 
@@ -280,22 +258,25 @@
       if (phdi->pszText == LPSTR_TEXTCALLBACKW)
       {
-        if (IsWindowUnicode(GetParent(hwnd)))
-        {
-          NMHDDISPINFOW nmhdr;
-
-          nmhdr.hdr.hwndFrom = hwnd;
-          nmhdr.hdr.idFrom   = GetWindowLongW(hwnd,GWL_ID);
-          nmhdr.hdr.code     = HDN_GETDISPINFOW;
-          nmhdr.iItem      = iItem;
-          nmhdr.mask       = HDI_TEXT;
-          nmhdr.cchTextMax = phdi->cchTextMax;
+        NMHDDISPINFOW nmhdr;
+
+        nmhdr.iItem      = iItem;
+        nmhdr.mask       = HDI_TEXT;
+        nmhdr.cchTextMax = phdi->cchTextMax;
+        if (isUnicodeNotify(&infoPtr->header))
+        {
           nmhdr.pszText    = (WCHAR*)COMCTL32_Alloc(phdi->cchTextMax*sizeof(WCHAR));
           if (nmhdr.pszText) nmhdr.pszText[0] = 0;
-          nmhdr.lParam     = phdi->lParam;
-
-          SendMessageW(GetParent(hwnd),WM_NOTIFY,(WPARAM)nmhdr.hdr.idFrom,(LPARAM)&nmhdr);
-
-          pszText = nmhdr.pszText;
-          if (nmhdr.mask & HDI_DI_SETITEM)
+        } else
+        {
+          nmhdr.pszText    = (WCHAR*)COMCTL32_Alloc(phdi->cchTextMax*sizeof(CHAR));
+          if (nmhdr.pszText) ((LPSTR)nmhdr.pszText)[0] = 0;
+        }
+        nmhdr.lParam     = phdi->lParam;
+        sendNotify(hwnd,isUnicodeNotify(&infoPtr->header) ? HDN_GETDISPINFOW:HDN_GETDISPINFOA,&nmhdr.hdr);
+
+        pszText = nmhdr.pszText;
+        if (nmhdr.mask & HDI_DI_SETITEM)
+        {
+          if (isUnicodeNotify(&infoPtr->header))
           {
             INT len = pszText ? lstrlenW(pszText):0;
@@ -308,33 +289,18 @@
             COMCTL32_Free(pszText);
             pszText = phdi->pszText;
+          } else
+          {
+            INT len = nmhdr.pszText ? lstrlenA((LPSTR)nmhdr.pszText):0;
+
+            if (len)
+            {
+              pszText = (WCHAR*)COMCTL32_Alloc((len+1)*sizeof(WCHAR));
+              lstrcpyAtoW(pszText,(LPSTR)nmhdr.pszText);
+            } else pszText = NULL;
+            COMCTL32_Free(nmhdr.pszText);
+
+            if (nmhdr.mask & HDI_DI_SETITEM)
+              phdi->pszText = pszText;
           }
-        } else
-        {
-          NMHDDISPINFOA nmhdr;
-          INT len;
-
-          nmhdr.hdr.hwndFrom = hwnd;
-          nmhdr.hdr.idFrom   = GetWindowLongA(hwnd,GWL_ID);
-          nmhdr.hdr.code     = HDN_GETDISPINFOA;
-          nmhdr.iItem      = iItem;
-          nmhdr.mask       = HDI_TEXT;
-          nmhdr.cchTextMax = phdi->cchTextMax;
-          nmhdr.pszText    = (CHAR*)COMCTL32_Alloc(phdi->cchTextMax);
-          if (nmhdr.pszText) nmhdr.pszText[0] = 0;
-          nmhdr.lParam     = phdi->lParam;
-
-          SendMessageA(GetParent(hwnd),WM_NOTIFY,(WPARAM)nmhdr.hdr.idFrom,(LPARAM)&nmhdr);
-
-          len = nmhdr.pszText ? lstrlenA(nmhdr.pszText):0;
-
-          if (len)
-          {
-            pszText = (WCHAR*)COMCTL32_Alloc((len+1)*sizeof(WCHAR));
-            lstrcpyAtoW(pszText,nmhdr.pszText);
-          } else pszText = NULL;
-          COMCTL32_Free(nmhdr.pszText);
-
-          if (nmhdr.mask & HDI_DI_SETITEM)
-            phdi->pszText = pszText;
         }
       }
@@ -395,7 +361,4 @@
 
     //Custom draw
-    cdraw.hdr.hwndFrom = hwnd;
-    cdraw.hdr.idFrom   = GetWindowLongA(hwnd,GWL_ID);
-    cdraw.hdr.code     = NM_CUSTOMDRAW;
     cdraw.dwDrawStage  = CDDS_PREPAINT;
     cdraw.hdc          = hdc;
@@ -405,5 +368,5 @@
     cdraw.lItemlParam  = 0;
 
-    cdctlres = SendMessageA(GetParent(hwnd),WM_NOTIFY,(WPARAM)cdraw.hdr.idFrom,(LPARAM)&cdraw);
+    cdctlres = sendNotify(hwnd,NM_CUSTOMDRAW,&cdraw.hdr);
 
     if (cdctlres & CDRF_SKIPDEFAULT) return;
@@ -426,5 +389,5 @@
         cdraw.rc             = infoPtr->items[x].rect;
 
-        cdres = SendMessageA(GetParent(hwnd),WM_NOTIFY,(WPARAM)cdraw.hdr.idFrom,(LPARAM)&cdraw);
+        cdres = sendNotify(hwnd,NM_CUSTOMDRAW,&cdraw.hdr);
       } else cdres = 0;
 
@@ -442,10 +405,10 @@
           cdraw.dwDrawStage    = CDDS_ITEMPOSTPAINT;
 
-          SendMessageA(GetParent(hwnd),WM_NOTIFY,(WPARAM)cdraw.hdr.idFrom,(LPARAM)&cdraw);
+          sendNotify(hwnd,NM_CUSTOMDRAW,&cdraw.hdr);
         }
       }
     }
 
-    if (x != -1 && (x <= rect.right) && (infoPtr->uNumItem > 0))
+    if ((x != -1) && (x <= rect.right) && (infoPtr->uNumItem > 0))
     {
       rect.left = x;
@@ -462,5 +425,5 @@
     if (infoPtr->bDragDrop)
     {
-      if (infoPtr->iDragItem != infoPtr->iMoveItem && infoPtr->iDragItem != infoPtr->iMoveItem+1 && infoPtr->iDragItem != -1)
+      if ((infoPtr->iDragItem != infoPtr->iMoveItem) && (infoPtr->iDragItem != infoPtr->iMoveItem+1) && (infoPtr->iDragItem != -1))
       {
         INT x,y,width;
@@ -502,5 +465,5 @@
       GetClientRect(hwnd,&cdraw.rc);
 
-      SendMessageA(GetParent(hwnd),WM_NOTIFY,(WPARAM)cdraw.hdr.idFrom,(LPARAM)&cdraw);
+      sendNotify(hwnd,NM_CUSTOMDRAW,&cdraw.hdr);
     }
 }
@@ -699,40 +662,31 @@
 }
 
-static BOOL
-HEADER_SendSimpleNotify (HWND hwnd, UINT code)
-{
-    NMHDR nmhdr;
-
-    nmhdr.hwndFrom = hwnd;
-    nmhdr.idFrom   = GetWindowLongA (hwnd, GWL_ID);
-    nmhdr.code     = code;
-
-    return (BOOL)SendMessageA (GetParent (hwnd), WM_NOTIFY,
-                                   (WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr);
-}
-
-static BOOL
-HEADER_SendHeaderNotifyA(HWND hwnd,UINT code,INT iItem,INT iButton)
+static BOOL HEADER_SendHeaderNotify(HWND hwnd,UINT code,INT iItem,INT iButton,BOOL unicode)
 {
     HEADER_INFO *infoPtr = HEADER_GetInfoPtr(hwnd);
-    NMHEADERA nmhdr;
-    HDITEMA nmitem;
-    char* text;
+    NMHEADERW nmhdr;
+    HDITEMW nmitem;
+    char* text = NULL;
     BOOL res;
 
-    if (infoPtr->items[iItem].pszText)
-    {
-      INT len = lstrlenW(infoPtr->items[iItem].pszText);
-
-      if (len > 0)
-      {
-        text = (CHAR*)COMCTL32_Alloc(len+1);
-        lstrcpyWtoA(text,infoPtr->items[iItem].pszText);
-      } else text = NULL;
-    } else text = NULL;
-
-    nmhdr.hdr.hwndFrom = hwnd;
-    nmhdr.hdr.idFrom   = GetWindowLongA(hwnd,GWL_ID);
-    nmhdr.hdr.code = code;
+
+    if (unicode)
+    {
+      nmitem.pszText = infoPtr->items[iItem].pszText;
+    } else
+    {
+      if (infoPtr->items[iItem].pszText)
+      {
+        INT len = lstrlenW(infoPtr->items[iItem].pszText);
+
+        if (len > 0)
+        {
+          text = (CHAR*)COMCTL32_Alloc(len+1);
+          lstrcpyWtoA(text,infoPtr->items[iItem].pszText);
+        }
+      }
+      nmitem.pszText = (LPWSTR)text;
+    }
+
     nmhdr.iItem   = iItem;
     nmhdr.iButton = 0;
@@ -742,5 +696,4 @@
     nmitem.cxy        = infoPtr->items[iItem].cxy;
     nmitem.hbm        = infoPtr->items[iItem].hbm;
-    nmitem.pszText    = text;
     nmitem.cchTextMax = infoPtr->items[iItem].cchTextMax;
     nmitem.fmt        = infoPtr->items[iItem].fmt;
@@ -751,5 +704,5 @@
     nmitem.pvFilter   = infoPtr->items[iItem].pvFilter;
 
-    res = (BOOL)SendMessageA(GetParent(hwnd),WM_NOTIFY,(WPARAM)nmhdr.hdr.idFrom,(LPARAM)&nmhdr);
+    res = (BOOL)sendNotify(hwnd,code,&nmhdr.hdr);
 
     if (text) COMCTL32_Free(text);
@@ -758,162 +711,90 @@
 }
 
-static BOOL
-HEADER_SendHeaderNotifyW(HWND hwnd,UINT code,INT iItem,INT iButton)
-{
-    HEADER_INFO *infoPtr = HEADER_GetInfoPtr(hwnd);
-    NMHEADERW nmhdr;
-    HDITEMW nmitem;
-
-    nmhdr.hdr.hwndFrom = hwnd;
-    nmhdr.hdr.idFrom   = GetWindowLongW(hwnd,GWL_ID);
-    nmhdr.hdr.code = code;
-    nmhdr.iItem   = iItem;
-    nmhdr.iButton = 0;
-    nmhdr.pitem   = &nmitem;
-
-    nmitem.mask       = 0;
-    nmitem.cxy        = infoPtr->items[iItem].cxy;
-    nmitem.hbm        = infoPtr->items[iItem].hbm;
-    nmitem.pszText    = infoPtr->items[iItem].pszText;
-    nmitem.cchTextMax = infoPtr->items[iItem].cchTextMax;
-    nmitem.fmt        = infoPtr->items[iItem].fmt;
-    nmitem.lParam     = infoPtr->items[iItem].lParam;
-    nmitem.iImage     = infoPtr->items[iItem].iImage;
-    nmitem.iOrder     = infoPtr->items[iItem].iOrder;
-    nmitem.type       = infoPtr->items[iItem].type;
-    nmitem.pvFilter   = infoPtr->items[iItem].pvFilter;
-
-    return (BOOL)SendMessageW(GetParent(hwnd),WM_NOTIFY,(WPARAM)nmhdr.hdr.idFrom,(LPARAM)&nmhdr);
-}
-
-static BOOL
-HEADER_SendItemChanging(HWND hwnd,INT iItem)
-{
-  if (IsWindowUnicode(GetParent(hwnd)))
-    return HEADER_SendHeaderNotifyA(hwnd,HDN_ITEMCHANGINGA,iItem,0);
-  else
-    return HEADER_SendHeaderNotifyW(hwnd,HDN_ITEMCHANGINGW,iItem,0);
-}
-
-static BOOL
-HEADER_SendItemChanged(HWND hwnd,INT iItem)
-{
-  if (IsWindowUnicode(GetParent(hwnd)))
-    return HEADER_SendHeaderNotifyA(hwnd,HDN_ITEMCHANGEDA,iItem,0);
-  else
-    return HEADER_SendHeaderNotifyW(hwnd,HDN_ITEMCHANGEDW,iItem,0);
-}
-
-static BOOL
-HEADER_SendItemDblClick(HWND hwnd,INT iItem,INT iButton)
-{
-  if (IsWindowUnicode(GetParent(hwnd)))
-    return HEADER_SendHeaderNotifyA(hwnd,HDN_ITEMDBLCLICKA,iItem,iButton);
-  else
-    return HEADER_SendHeaderNotifyW(hwnd,HDN_ITEMDBLCLICKW,iItem,iButton);
-}
-
-static BOOL
-HEADER_SendDividerDblClick(HWND hwnd,INT iItem,INT iButton)
-{
-  if (IsWindowUnicode(GetParent(hwnd)))
-    return HEADER_SendHeaderNotifyA(hwnd,HDN_DIVIDERDBLCLICKA,iItem,iButton);
-  else
-    return HEADER_SendHeaderNotifyW(hwnd,HDN_DIVIDERDBLCLICKW,iItem,iButton);
-}
-
-static BOOL
-HEADER_SendBeginTrack(HWND hwnd,INT iItem,INT iButton)
-{
-  if (IsWindowUnicode(GetParent(hwnd)))
-    return HEADER_SendHeaderNotifyA(hwnd,HDN_BEGINTRACKA,iItem,iButton);
-  else
-    return HEADER_SendHeaderNotifyW(hwnd,HDN_BEGINTRACKW,iItem,iButton);
-}
-
-static BOOL
-HEADER_SendEndTrack(HWND hwnd,INT iItem,INT iButton)
-{
-  if (IsWindowUnicode(GetParent(hwnd)))
-    return HEADER_SendHeaderNotifyA(hwnd,HDN_ENDTRACKA,iItem,iButton);
-  else
-    return HEADER_SendHeaderNotifyW(hwnd,HDN_ENDTRACKW,iItem,iButton);
-}
-
-static BOOL
-HEADER_SendTrack(HWND hwnd,INT iItem)
-{
-  if (IsWindowUnicode(GetParent(hwnd)))
-    return HEADER_SendHeaderNotifyA(hwnd,HDN_TRACKA,iItem,0);
-  else
-    return HEADER_SendHeaderNotifyW(hwnd,HDN_TRACKW,iItem,0);
-}
-
-static BOOL
-HEADER_SendClickNotifyA(HWND hwnd,UINT code,INT iItem,INT iButton)
-{
-    NMHEADERA nmhdr;
-
-    nmhdr.hdr.hwndFrom = hwnd;
-    nmhdr.hdr.idFrom   = GetWindowLongA(hwnd,GWL_ID);
-    nmhdr.hdr.code     = code;
-    nmhdr.iItem        = iItem;
-    nmhdr.iButton      = iButton;
-    nmhdr.pitem        = NULL;
-
-    return (BOOL)SendMessageA(GetParent(hwnd),WM_NOTIFY,(WPARAM)nmhdr.hdr.idFrom,(LPARAM)&nmhdr);
-}
-
-static BOOL
-HEADER_SendClickNotifyW(HWND hwnd,UINT code,INT iItem,INT iButton)
-{
-    NMHEADERW nmhdr;
-
-    nmhdr.hdr.hwndFrom = hwnd;
-    nmhdr.hdr.idFrom   = GetWindowLongW(hwnd,GWL_ID);
-    nmhdr.hdr.code     = code;
-    nmhdr.iItem        = iItem;
-    nmhdr.iButton      = iButton;
-    nmhdr.pitem        = NULL;
-
-    return (BOOL)SendMessageW(GetParent(hwnd),WM_NOTIFY,(WPARAM)nmhdr.hdr.idFrom,(LPARAM)&nmhdr);
-}
-
-static BOOL
-HEADER_SendItemClick(HWND hwnd,INT iItem,INT iButton)
-{
-  if (IsWindowUnicode(GetParent(hwnd)))
-    return HEADER_SendClickNotifyA(hwnd,HDN_ITEMCLICKA,iItem,iButton);
-  else
-    return HEADER_SendClickNotifyW(hwnd,HDN_ITEMCLICKW,iItem,iButton);
-}
-
-static BOOL
-HEADER_SendDragNotify(HWND hwnd,UINT code,INT iItem,INT iButton)
-{
-    NMHEADERA nmhdr;
-
-    nmhdr.hdr.hwndFrom = hwnd;
-    nmhdr.hdr.idFrom   = GetWindowLongA(hwnd,GWL_ID);
-    nmhdr.hdr.code     = code;
-    nmhdr.iItem        = iItem;
-    nmhdr.iButton      = iButton;
-    nmhdr.pitem        = NULL;
-
-    return (BOOL)SendMessageA(GetParent(hwnd),WM_NOTIFY,(WPARAM)nmhdr.hdr.idFrom,(LPARAM)&nmhdr);
-}
-
-static BOOL
-HEADER_SendFilterBtnClick(HWND hwnd,INT iItem,RECT iRect)
-{
-    NMHDFILTERBTNCLICK nmhdr;
-
-    nmhdr.hdr.hwndFrom = hwnd;
-    nmhdr.hdr.idFrom   = GetWindowLongA(hwnd,GWL_ID);
-    nmhdr.hdr.code = HDN_FILTERBTNCLICK;
-    nmhdr.iItem    = iItem;
-    nmhdr.rc       = iRect;
-
-    return (BOOL)SendMessageA(GetParent(hwnd),WM_NOTIFY,(WPARAM)nmhdr.hdr.idFrom,(LPARAM)&nmhdr);
+static BOOL HEADER_SendItemChanging(HWND hwnd,INT iItem)
+{
+  BOOL unicode = isUnicodeNotify(hwnd);
+
+  return HEADER_SendHeaderNotify(hwnd,unicode ? HDN_ITEMCHANGINGW:HDN_ITEMCHANGINGA,iItem,0,unicode);
+}
+
+static BOOL HEADER_SendItemChanged(HWND hwnd,INT iItem)
+{
+  BOOL unicode = isUnicodeNotify(hwnd);
+
+  return HEADER_SendHeaderNotify(hwnd,unicode ? HDN_ITEMCHANGEDW:HDN_ITEMCHANGEDA,iItem,0,unicode);
+}
+
+static BOOL HEADER_SendItemDblClick(HWND hwnd,INT iItem,INT iButton)
+{
+  BOOL unicode = isUnicodeNotify(hwnd);
+
+  return HEADER_SendHeaderNotify(hwnd,unicode ? HDN_ITEMDBLCLICKW:HDN_ITEMDBLCLICKA,iItem,iButton,unicode);
+}
+
+static BOOL HEADER_SendDividerDblClick(HWND hwnd,INT iItem,INT iButton)
+{
+  BOOL unicode = isUnicodeNotify(hwnd);
+
+  return HEADER_SendHeaderNotify(hwnd,unicode ? HDN_DIVIDERDBLCLICKW:HDN_DIVIDERDBLCLICKA,iItem,iButton,unicode);
+}
+
+static BOOL HEADER_SendBeginTrack(HWND hwnd,INT iItem,INT iButton)
+{
+  BOOL unicode = isUnicodeNotify(hwnd);
+
+  return HEADER_SendHeaderNotify(hwnd,unicode ? HDN_BEGINTRACKW:HDN_BEGINTRACKA,iItem,iButton,unicode);
+}
+
+static BOOL HEADER_SendEndTrack(HWND hwnd,INT iItem,INT iButton)
+{
+  BOOL unicode = isUnicodeNotify(hwnd);
+
+  return HEADER_SendHeaderNotify(hwnd,unicode ? HDN_ENDTRACKW:HDN_ENDTRACKA,iItem,iButton,unicode);
+}
+
+static BOOL HEADER_SendTrack(HWND hwnd,INT iItem)
+{
+  BOOL unicode = isUnicodeNotify(hwnd);
+
+  return HEADER_SendHeaderNotify(hwnd,unicode ? HDN_TRACKW:HDN_TRACKA,iItem,0,unicode);
+}
+
+static BOOL HEADER_SendClickNotify(HWND hwnd,UINT code,INT iItem,INT iButton,BOOL unicode)
+{
+  NMHEADERW nmhdr;
+
+  nmhdr.iItem   = iItem;
+  nmhdr.iButton = iButton;
+  nmhdr.pitem   = NULL;
+
+  return (BOOL)sendNotify(hwnd,code,&nmhdr.hdr);
+}
+
+static BOOL HEADER_SendItemClick(HWND hwnd,INT iItem,INT iButton)
+{
+  BOOL unicode = isUnicodeNotify(hwnd);
+
+  return HEADER_SendClickNotify(hwnd,unicode ? HDN_ITEMCLICKW:HDN_ITEMCLICKA,iItem,iButton,unicode);
+}
+
+static BOOL HEADER_SendDragNotify(HWND hwnd,UINT code,INT iItem,INT iButton)
+{
+  NMHEADERW nmhdr;
+
+  nmhdr.iItem   = iItem;
+  nmhdr.iButton = iButton;
+  nmhdr.pitem   = NULL;
+
+  return (BOOL)sendNotify(hwnd,code,&nmhdr.hdr);
+}
+
+static BOOL HEADER_SendFilterBtnClick(HWND hwnd,INT iItem,RECT iRect)
+{
+  NMHDFILTERBTNCLICK nmhdr;
+
+  nmhdr.iItem    = iItem;
+  nmhdr.rc       = iRect;
+
+  return (BOOL)sendNotify(hwnd,HDN_FILTERBTNCLICK,&nmhdr.hdr);
 }
 
@@ -921,14 +802,11 @@
 HEADER_SendFilterChange(HWND hwnd,INT iItem)
 {
-    NMHEADERA nmhdr;
-
-    nmhdr.hdr.hwndFrom = hwnd;
-    nmhdr.hdr.idFrom   = GetWindowLongA(hwnd,GWL_ID);
-    nmhdr.hdr.code     = HDN_FILTERCHANGE;
-    nmhdr.iItem        = iItem;
-    nmhdr.iButton      = 0;
-    nmhdr.pitem        = NULL;
-
-    return (BOOL)SendMessageA(GetParent(hwnd),WM_NOTIFY,(WPARAM)nmhdr.hdr.idFrom,(LPARAM)&nmhdr);
+  NMHEADERW nmhdr;
+
+  nmhdr.iItem        = iItem;
+  nmhdr.iButton      = 0;
+  nmhdr.pitem        = NULL;
+
+  return (BOOL)sendNotify(hwnd,HDN_FILTERCHANGE,&nmhdr.hdr);
 }
 
@@ -1138,10 +1016,9 @@
 
 
-static LRESULT
-HEADER_GetItemA (HWND hwnd, WPARAM wParam, LPARAM lParam)
+static LRESULT HEADER_GetItem(HWND hwnd,WPARAM wParam,LPARAM lParam,BOOL unicode)
 {
     HEADER_INFO *infoPtr = HEADER_GetInfoPtr(hwnd);
-    HDITEMA   *phdi = (HDITEMA*)lParam;
-    INT       nItem = (INT)wParam;
+    HDITEMW     *phdi = (HDITEMW*)lParam;
+    INT          nItem = (INT)wParam;
     HEADER_ITEM *lpItem;
 
@@ -1149,6 +1026,4 @@
     if ((nItem < 0) || (nItem >= (INT)infoPtr->uNumItem)) return FALSE;
 
-//    TRACE (header, "[nItem=%d]\n", nItem);
-
     if (phdi->mask == 0) return TRUE;
 
@@ -1178,62 +1053,18 @@
       {
         if (lpItem->pszText)
-          lstrcpynWtoA (phdi->pszText,lpItem->pszText,phdi->cchTextMax);
-        else
-          phdi->pszText = NULL;
-      } else phdi->pszText = LPSTR_TEXTCALLBACKA;
+        {
+          if (unicode)
+            lstrcpynW (phdi->pszText,lpItem->pszText,phdi->cchTextMax);
+          else
+            lstrcpynWtoA((LPSTR)phdi->pszText,lpItem->pszText,phdi->cchTextMax);
+        } else phdi->pszText = NULL;
+      } else
+      {
+        phdi->pszText = unicode ? LPSTR_TEXTCALLBACKW:(LPWSTR)LPSTR_TEXTCALLBACKA;
+      }
     }
 
     return TRUE;
 }
-
-static LRESULT
-HEADER_GetItemW (HWND hwnd, WPARAM wParam, LPARAM lParam)
-{
-    HEADER_INFO *infoPtr = HEADER_GetInfoPtr(hwnd);
-    HDITEMW   *phdi = (HDITEMW*)lParam;
-    INT       nItem = (INT)wParam;
-    HEADER_ITEM *lpItem;
-
-    if (!phdi) return FALSE;
-    if ((nItem < 0) || (nItem >= (INT)infoPtr->uNumItem)) return FALSE;
-
-//    TRACE (header, "[nItem=%d]\n", nItem);
-
-    if (phdi->mask == 0) return TRUE;
-
-    lpItem = (HEADER_ITEM*)&infoPtr->items[nItem];
-
-    if (phdi->mask & HDI_BITMAP) phdi->hbm = lpItem->hbm;
-
-    if (phdi->mask & HDI_FORMAT) phdi->fmt = lpItem->fmt;
-
-    if (phdi->mask & HDI_FILTER)
-    {
-      phdi->type = lpItem->type;
-      phdi->pvFilter = lpItem->pvFilter;
-    }
-
-    if (phdi->mask & (HDI_WIDTH | HDI_HEIGHT)) phdi->cxy = lpItem->cxy;
-
-    if (phdi->mask & HDI_IMAGE) phdi->iImage = lpItem->iImage;
-
-    if (phdi->mask & HDI_LPARAM) phdi->lParam = lpItem->lParam;
-
-    if (phdi->mask & HDI_ORDER) phdi->iOrder = lpItem->iOrder;
-
-    if (phdi->mask & HDI_TEXT)
-    {
-      if (lpItem->pszText != LPSTR_TEXTCALLBACKW)
-      {
-        if (lpItem->pszText)
-          lstrcpynW (phdi->pszText,lpItem->pszText,phdi->cchTextMax);
-        else
-          phdi->pszText = NULL;
-      } else phdi->pszText = LPSTR_TEXTCALLBACKW;
-    }
-
-    return TRUE;
-}
-
 
 static LRESULT
@@ -1338,13 +1169,4 @@
 
 static LRESULT
-HEADER_GetUnicodeFormat (HWND hwnd)
-{
-    HEADER_INFO *infoPtr = HEADER_GetInfoPtr(hwnd);
-
-    return infoPtr->bUnicode;
-}
-
-
-static LRESULT
 HEADER_HitTest (HWND hwnd, WPARAM wParam, LPARAM lParam)
 {
@@ -1357,10 +1179,9 @@
 
 
-static LRESULT
-HEADER_InsertItemA (HWND hwnd, WPARAM wParam, LPARAM lParam)
+static LRESULT HEADER_InsertItem(HWND hwnd,WPARAM wParam,LPARAM lParam,BOOL unicode)
 {
     HEADER_INFO *infoPtr = HEADER_GetInfoPtr (hwnd);
-    HDITEMA *phdi = (HDITEMA*)lParam;
-    INT nItem = (INT)wParam;
+    HDITEMW     *phdi = (HDITEMW*)lParam;
+    INT          nItem = (INT)wParam;
     HEADER_ITEM *lpItem;
 
@@ -1397,20 +1218,36 @@
     lpItem->bDown = FALSE;
 
-    lpItem->cxy = (phdi->mask & HDI_WIDTH || phdi->mask & HDI_HEIGHT) ? phdi->cxy:0;
+    lpItem->cxy = ((phdi->mask & HDI_WIDTH) || (phdi->mask & HDI_HEIGHT)) ? phdi->cxy:0;
 
     if (phdi->mask & HDI_TEXT)
     {
       if (!phdi->pszText) lpItem->pszText = NULL;
-      else if (phdi->pszText != LPSTR_TEXTCALLBACKA)
-      {
-        INT len;
-
-        len = lstrlenA(phdi->pszText);
-        if (len == 0) lpItem->pszText = NULL; else
-        {
-          lpItem->pszText = (WCHAR*)COMCTL32_Alloc((len+1)*sizeof(WCHAR));
-          lstrcpyAtoW(lpItem->pszText,phdi->pszText);
-        }
-      } else lpItem->pszText = LPSTR_TEXTCALLBACKW;
+      else if (unicode)
+      {
+        if (phdi->pszText != LPSTR_TEXTCALLBACKW)
+        {
+          INT len;
+
+          len = lstrlenW(phdi->pszText);
+          if (len == 0) lpItem->pszText = NULL; else
+          {
+            lpItem->pszText = (WCHAR*)COMCTL32_Alloc((len+1)*sizeof(WCHAR));
+            lstrcpyW(lpItem->pszText,phdi->pszText);
+          }
+        } else lpItem->pszText = LPSTR_TEXTCALLBACKW;
+      } else
+      {
+        if ((LPSTR)phdi->pszText != LPSTR_TEXTCALLBACKA)
+        {
+          INT len;
+
+          len = lstrlenA((LPSTR)phdi->pszText);
+          if (len == 0) lpItem->pszText = NULL; else
+          {
+            lpItem->pszText = (WCHAR*)COMCTL32_Alloc((len+1)*sizeof(WCHAR));
+            lstrcpyAtoW(lpItem->pszText,(LPSTR)phdi->pszText);
+          }
+        } else lpItem->pszText = LPSTR_TEXTCALLBACKW;
+      }
       lpItem->cchTextMax = phdi->cchTextMax;
     } else
@@ -1442,91 +1279,4 @@
     return nItem;
 }
-
-static LRESULT
-HEADER_InsertItemW (HWND hwnd, WPARAM wParam, LPARAM lParam)
-{
-    HEADER_INFO *infoPtr = HEADER_GetInfoPtr (hwnd);
-    HDITEMW *phdi = (HDITEMW*)lParam;
-    INT nItem = (INT)wParam;
-    HEADER_ITEM *lpItem;
-
-    if ((phdi == NULL) || (nItem < 0)) return -1;
-
-    if (nItem > infoPtr->uNumItem) nItem = infoPtr->uNumItem;
-
-    if (infoPtr->uNumItem == 0)
-    {
-      infoPtr->items = (HEADER_ITEM*)COMCTL32_Alloc(sizeof(HEADER_ITEM));
-      infoPtr->uNumItem++;
-    } else
-    {
-      HEADER_ITEM *oldItems = infoPtr->items;
-
-      infoPtr->uNumItem++;
-      infoPtr->items = (HEADER_ITEM*)COMCTL32_Alloc(sizeof(HEADER_ITEM)*infoPtr->uNumItem);
-      if (nItem == 0)
-        memcpy (&infoPtr->items[1],&oldItems[0],(infoPtr->uNumItem-1)*sizeof(HEADER_ITEM));
-      else
-      {
-        /* pre insert copy */
-        memcpy (&infoPtr->items[0],&oldItems[0],nItem*sizeof(HEADER_ITEM));
-
-        /* post insert copy */
-        if (nItem < infoPtr->uNumItem-1)
-          memcpy (&infoPtr->items[nItem+1],&oldItems[nItem],(infoPtr->uNumItem - nItem)*sizeof(HEADER_ITEM));
-      }
-
-      COMCTL32_Free (oldItems);
-    }
-
-    lpItem = (HEADER_ITEM*)&infoPtr->items[nItem];
-    lpItem->bDown = FALSE;
-
-    lpItem->cxy = (phdi->mask & HDI_WIDTH || phdi->mask & HDI_HEIGHT) ? phdi->cxy:0;
-
-    if (phdi->mask & HDI_TEXT)
-    {
-      if (!phdi->pszText) lpItem->pszText = NULL;
-      else if (phdi->pszText != LPSTR_TEXTCALLBACKW)
-      {
-        INT len;
-
-        len = lstrlenW(phdi->pszText);
-        if (len == 0) lpItem->pszText = NULL; else
-        {
-          lpItem->pszText = (WCHAR*)COMCTL32_Alloc((len+1)*sizeof(WCHAR));
-          lstrcpyW(lpItem->pszText,phdi->pszText);
-        }
-      } else lpItem->pszText = LPSTR_TEXTCALLBACKW;
-      lpItem->cchTextMax = phdi->cchTextMax;
-    } else
-    {
-      lpItem->pszText = NULL;
-      lpItem->cchTextMax = 0;
-    }
-
-    lpItem->fmt = (phdi->mask & HDI_FORMAT) ? phdi->fmt:HDF_LEFT;
-    if (lpItem->fmt == 0) lpItem->fmt = HDF_LEFT;
-
-    lpItem->lParam = (phdi->mask & HDI_LPARAM) ? phdi->lParam:0;
-
-    lpItem->iImage = (phdi->mask & HDI_IMAGE) ? phdi->iImage:0;
-
-    lpItem->iOrder = (phdi->mask & HDI_ORDER) ? phdi->iOrder:-1;
-
-    lpItem->hbm = (phdi->mask & HDI_BITMAP) ? phdi->hbm:0;
-
-    if (phdi->mask & HDI_FILTER)
-    {
-      lpItem->type = phdi->type;
-      lpItem->pvFilter = phdi->pvFilter;
-    }
-
-    HEADER_SetItemBounds (hwnd,nItem);
-    HEADER_Refresh(hwnd);
-
-    return nItem;
-}
-
 
 static LRESULT
@@ -1572,10 +1322,9 @@
 
 
-static LRESULT
-HEADER_SetItemA (HWND hwnd, WPARAM wParam, LPARAM lParam)
+static LRESULT HEADER_SetItem(HWND hwnd,WPARAM wParam,LPARAM lParam,BOOL unicode)
 {
     HEADER_INFO *infoPtr = HEADER_GetInfoPtr (hwnd);
-    HDITEMA *phdi = (HDITEMA*)lParam;
-    INT nItem = (INT)wParam;
+    HDITEMW     *phdi = (HDITEMW*)lParam;
+    INT          nItem = (INT)wParam;
     HEADER_ITEM *lpItem;
     HDC hdc;
@@ -1585,5 +1334,4 @@
     if (phdi->mask == 0) return TRUE;
 
-//    TRACE (header, "[nItem=%d]\n", nItem);
     if (HEADER_SendItemChanging(hwnd,nItem)) return FALSE;
 
@@ -1610,25 +1358,52 @@
     if (phdi->mask & HDI_TEXT)
     {
-      if (phdi->pszText != LPSTR_TEXTCALLBACKA)
-      {
-        if (lpItem->pszText)
-        {
-          COMCTL32_Free (lpItem->pszText);
-          lpItem->pszText = NULL;
-        }
-        if (phdi->pszText)
-        {
-          INT len = lstrlenA (phdi->pszText);
-
-          if (len)
+      if (unicode)
+      {
+        if (phdi->pszText != LPSTR_TEXTCALLBACKW)
+        {
+          if (lpItem->pszText)
           {
-            lpItem->pszText = (WCHAR*)COMCTL32_Alloc((len+1)*sizeof(WCHAR));
-            lstrcpyAtoW(lpItem->pszText,phdi->pszText);
+            COMCTL32_Free(lpItem->pszText);
+            lpItem->pszText = NULL;
           }
+          if (phdi->pszText)
+          {
+            INT len = lstrlenW(phdi->pszText);
+
+            if (len)
+            {
+              lpItem->pszText = (WCHAR*)COMCTL32_Alloc((len+1)*sizeof(WCHAR));
+              lstrcpyW(lpItem->pszText,phdi->pszText);
+            }
+          }
+        } else
+        {
+          if (lpItem->pszText != LPSTR_TEXTCALLBACKW) COMCTL32_Free(lpItem->pszText);
+          lpItem->pszText = LPSTR_TEXTCALLBACKW;
         }
       } else
       {
-        if (lpItem->pszText != LPSTR_TEXTCALLBACKW) COMCTL32_Free(lpItem->pszText);
-        lpItem->pszText = LPSTR_TEXTCALLBACKW;
+        if ((LPSTR)phdi->pszText != LPSTR_TEXTCALLBACKA)
+        {
+          if (lpItem->pszText)
+          {
+            COMCTL32_Free (lpItem->pszText);
+            lpItem->pszText = NULL;
+          }
+          if (phdi->pszText)
+          {
+            INT len = lstrlenA((LPSTR)phdi->pszText);
+
+            if (len)
+            {
+              lpItem->pszText = (WCHAR*)COMCTL32_Alloc((len+1)*sizeof(WCHAR));
+              lstrcpyAtoW(lpItem->pszText,(LPSTR)phdi->pszText);
+            }
+          }
+        } else
+        {
+          if (lpItem->pszText != LPSTR_TEXTCALLBACKW) COMCTL32_Free(lpItem->pszText);
+          lpItem->pszText = LPSTR_TEXTCALLBACKW;
+        }
       }
     }
@@ -1641,88 +1416,4 @@
     return TRUE;
 }
-
-
-static LRESULT
-HEADER_SetItemW (HWND hwnd, WPARAM wParam, LPARAM lParam)
-{
-    HEADER_INFO *infoPtr = HEADER_GetInfoPtr (hwnd);
-    HDITEMW *phdi = (HDITEMW*)lParam;
-    INT nItem = (INT)wParam;
-    HEADER_ITEM *lpItem;
-    HDC hdc;
-
-    if (phdi == NULL) return FALSE;
-    if ((nItem < 0) || (nItem >= (INT)infoPtr->uNumItem)) return FALSE;
-    if (phdi->mask == 0) return TRUE;
-
-//    TRACE (header, "[nItem=%d]\n", nItem);
-
-    if (HEADER_SendItemChanging(hwnd,nItem)) return FALSE;
-
-    lpItem = (HEADER_ITEM*)&infoPtr->items[nItem];
-
-    if (phdi->mask & HDI_BITMAP) lpItem->hbm = phdi->hbm;
-
-    if (phdi->mask & HDI_FORMAT) lpItem->fmt = phdi->fmt;
-
-    if (phdi->mask & HDI_FILTER)
-    {
-      lpItem->type = lpItem->type;
-      lpItem->pvFilter = lpItem->pvFilter;
-    }
-
-    if (phdi->mask & (HDI_WIDTH | HDI_WIDTH)) lpItem->cxy = phdi->cxy;
-
-    if (phdi->mask & HDI_IMAGE) lpItem->iImage = phdi->iImage;
-
-    if (phdi->mask & HDI_LPARAM) lpItem->lParam = phdi->lParam;
-
-    if (phdi->mask & HDI_ORDER) lpItem->iOrder = phdi->iOrder;
-
-    if (phdi->mask & HDI_TEXT)
-    {
-      if (phdi->pszText != LPSTR_TEXTCALLBACKW)
-      {
-        if (lpItem->pszText)
-        {
-          COMCTL32_Free(lpItem->pszText);
-          lpItem->pszText = NULL;
-        }
-        if (phdi->pszText)
-        {
-          INT len = lstrlenW(phdi->pszText);
-
-          if (len)
-          {
-            lpItem->pszText = (WCHAR*)COMCTL32_Alloc((len+1)*sizeof(WCHAR));
-            lstrcpyW(lpItem->pszText,phdi->pszText);
-          }
-        }
-      } else
-      {
-        if (lpItem->pszText != LPSTR_TEXTCALLBACKW) COMCTL32_Free(lpItem->pszText);
-        lpItem->pszText = LPSTR_TEXTCALLBACKW;
-      }
-    }
-
-    HEADER_SendItemChanged(hwnd,nItem);
-
-    HEADER_SetItemBounds(hwnd,0);
-    HEADER_Refresh(hwnd);
-
-    return TRUE;
-}
-
-static LRESULT
-HEADER_SetUnicodeFormat (HWND hwnd, WPARAM wParam)
-{
-    HEADER_INFO *infoPtr = HEADER_GetInfoPtr(hwnd);
-    BOOL bTemp = infoPtr->bUnicode;
-
-    infoPtr->bUnicode = (BOOL)wParam;
-
-    return bTemp;
-}
-
 
 static LRESULT
@@ -1734,6 +1425,5 @@
     HDC   hdc;
 
-    infoPtr = (HEADER_INFO *)COMCTL32_Alloc (sizeof(HEADER_INFO));
-    SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
+    infoPtr = (HEADER_INFO*)initControl(hwnd,sizeof(HEADER_INFO));
 
     infoPtr->uNumItem = 0;
@@ -1753,12 +1443,11 @@
     infoPtr->iHotItem  = -1;
     infoPtr->xBmpMargin = 3*GetSystemMetrics(SM_CXEDGE);
-    infoPtr->bUnicode = IsWindowUnicode(hwnd);
-
-    hdc = GetDC (0);
+
+    hdc = GetDC (hwnd);
     hOldFont = SelectObject (hdc, GetStockObject (SYSTEM_FONT));
     GetTextMetricsA (hdc, &tm);
     infoPtr->nHeight = tm.tmHeight + VERT_BORDER;
     SelectObject (hdc, hOldFont);
-    ReleaseDC (0, hdc);
+    ReleaseDC (hwnd, hdc);
 
     return 0;
@@ -1785,5 +1474,5 @@
         ImageList_Destroy (infoPtr->himl);
 
-    COMCTL32_Free (infoPtr);
+    doneControl(hwnd);
 
     return 0;
@@ -1913,5 +1602,5 @@
         infoPtr->dragImage = NULL;
 
-        if (!HEADER_SendDragNotify(hwnd,HDN_ENDDRAG,infoPtr->iMoveItem,0) && infoPtr->iDragItem != infoPtr->iMoveItem && infoPtr->iDragItem != infoPtr->iMoveItem+1 && infoPtr->iDragItem != -1)
+        if (!HEADER_SendDragNotify(hwnd,HDN_ENDDRAG,infoPtr->iMoveItem,0) && (infoPtr->iDragItem != infoPtr->iMoveItem) && (infoPtr->iDragItem != infoPtr->iMoveItem+1) && (infoPtr->iDragItem != -1))
         {
           HEADER_ITEM tmpItem = infoPtr->items[infoPtr->iMoveItem];;
@@ -1987,5 +1676,5 @@
       infoPtr->bCaptured = FALSE;
       ReleaseCapture();
-      HEADER_SendSimpleNotify(hwnd,NM_RELEASEDCAPTURE);
+      sendNotify(hwnd,NM_RELEASEDCAPTURE);
     }
 
@@ -2008,5 +1697,5 @@
   for (x = 0;x < infoPtr->uNumItem;x++)
   {
-    if (xDrag >= infoPtr->items[x].rect.left && xDrag <= infoPtr->items[x].rect.right) return x;
+    if ((xDrag >= infoPtr->items[x].rect.left) && (xDrag <= infoPtr->items[x].rect.right)) return x;
   }
 
@@ -2028,5 +1717,5 @@
     HEADER_InternalHitTest (hwnd, &pt, &flags, &nItem);
 
-    if (dwStyle & HDS_BUTTONS && dwStyle & HDS_HOTTRACK)
+    if ((dwStyle & HDS_BUTTONS) && (dwStyle & HDS_HOTTRACK))
     {
         INT newItem;
@@ -2046,9 +1735,9 @@
           HEADER_Refresh(hwnd);
         }
-        if (!infoPtr->bTimer && infoPtr->iHotItem != -1)
+        if (!infoPtr->bTimer && (infoPtr->iHotItem != -1))
         {
           infoPtr->bTimer = TRUE;
           SetTimer(hwnd,TIMER_ID,TIMER_MS,NULL);
-        } else if (infoPtr->bTimer && infoPtr->iHotItem == -1)
+        } else if (infoPtr->bTimer && (infoPtr->iHotItem == -1))
         {
           KillTimer(hwnd,TIMER_ID);
@@ -2061,5 +1750,5 @@
       if (infoPtr->bPressed)
       {
-        if (dwStyle & HDS_DRAGDROP && infoPtr->uNumItem > 1 && (infoPtr->bDragDrop || !HEADER_SendDragNotify(hwnd,HDN_BEGINDRAG,infoPtr->iMoveItem,0)))
+        if ((dwStyle & HDS_DRAGDROP) && (infoPtr->uNumItem > 1) && (infoPtr->bDragDrop || !HEADER_SendDragNotify(hwnd,HDN_BEGINDRAG,infoPtr->iMoveItem,0)))
         {
           if (!infoPtr->bDragDrop)
@@ -2168,5 +1857,5 @@
   HDC hdc;
 
-  if (wParam == VK_ESCAPE && infoPtr->bCaptured)
+  if ((wParam == VK_ESCAPE) && infoPtr->bCaptured)
   {
     if (infoPtr->bPressed && infoPtr->bDragDrop)
@@ -2201,5 +1890,5 @@
     infoPtr->bCaptured = FALSE;
     ReleaseCapture();
-    HEADER_SendSimpleNotify(hwnd,NM_RELEASEDCAPTURE);
+    sendNotify(hwnd,NM_RELEASEDCAPTURE);
 
     return TRUE;
@@ -2275,5 +1964,5 @@
 HEADER_RButtonUp (HWND hwnd, WPARAM wParam, LPARAM lParam)
 {
-  HEADER_SendSimpleNotify(hwnd,NM_RCLICK);
+  sendNotify(hwnd,NM_RCLICK);
 
   return DefWindowProcA(hwnd,WM_RBUTTONUP,wParam,lParam);
@@ -2330,10 +2019,10 @@
     hFont = infoPtr->hFont ? infoPtr->hFont : GetStockObject (SYSTEM_FONT);
 
-    hdc = GetDC (0);
+    hdc = GetDC (hwnd);
     hOldFont = SelectObject (hdc, hFont);
     GetTextMetricsA (hdc, &tm);
     infoPtr->nHeight = tm.tmHeight + VERT_BORDER;
     SelectObject (hdc, hOldFont);
-    ReleaseDC (0, hdc);
+    ReleaseDC (hwnd, hdc);
 
     if (lParam) HEADER_Refresh(hwnd);
@@ -2367,8 +2056,8 @@
 
         case HDM_GETITEMA:
-            return HEADER_GetItemA (hwnd, wParam, lParam);
+            return HEADER_GetItem(hwnd,wParam,lParam,FALSE);
 
         case HDM_GETITEMW:
-            return HEADER_GetItemW (hwnd, wParam, lParam);
+            return HEADER_GetItem(hwnd,wParam,lParam,TRUE);
 
         case HDM_GETITEMCOUNT:
@@ -2381,15 +2070,12 @@
             return HEADER_GetOrderArray(hwnd,wParam,lParam);
 
-        case HDM_GETUNICODEFORMAT:
-            return HEADER_GetUnicodeFormat (hwnd);
-
         case HDM_HITTEST:
             return HEADER_HitTest (hwnd, wParam, lParam);
 
         case HDM_INSERTITEMA:
-            return HEADER_InsertItemA (hwnd, wParam, lParam);
+            return HEADER_InsertItem(hwnd,wParam,lParam,FALSE);
 
         case HDM_INSERTITEMW:
-            return HEADER_InsertItemW (hwnd, wParam, lParam);
+            return HEADER_InsertItem(hwnd,wParam,lParam,TRUE);
 
         case HDM_LAYOUT:
@@ -2412,15 +2098,12 @@
 
         case HDM_SETITEMA:
-            return HEADER_SetItemA (hwnd, wParam, lParam);
+            return HEADER_SetItem(hwnd,wParam,lParam,FALSE);
 
         case HDM_SETITEMW:
-            return HEADER_SetItemW (hwnd, wParam, lParam);
+            return HEADER_SetItem(hwnd,wParam,lParam,TRUE);
 
         case HDM_SETORDERARRAY:
             return HEADER_SetOrderArray(hwnd,wParam,lParam);
 
-        case HDM_SETUNICODEFORMAT:
-            return HEADER_SetUnicodeFormat (hwnd, wParam);
-
         case WM_CAPTURECHANGED:
             return HEADER_CaptureChanged(hwnd,wParam,lParam);
@@ -2455,6 +2138,4 @@
         case WM_MOUSEMOVE:
             return HEADER_MouseMove (hwnd, wParam, lParam);
-
-/*      case WM_NOTIFYFORMAT: */
 
         case WM_PAINT:
@@ -2480,5 +2161,5 @@
 //              ERR (header, "unknown msg %04x wp=%04x lp=%08lx\n",
 //                   msg, wParam, lParam );
-            return DefWindowProcA (hwnd, msg, wParam, lParam);
+            return defComCtl32ProcA (hwnd, msg, wParam, lParam);
     }
     return 0;
@@ -2490,7 +2171,4 @@
 {
     WNDCLASSA wndClass;
-
-//SvL: Don't check this now
-//    if (GlobalFindAtomA (WC_HEADERA)) return;
 
     ZeroMemory (&wndClass, sizeof(WNDCLASSA));
@@ -2509,6 +2187,5 @@
 HEADER_Unregister (VOID)
 {
-    if (GlobalFindAtomA (WC_HEADERA))
-        UnregisterClassA (WC_HEADERA, (HINSTANCE)NULL);
-}
-
+    UnregisterClassA (WC_HEADERA, (HINSTANCE)NULL);
+}
+
Index: trunk/src/comctl32/hotkey.cpp
===================================================================
--- trunk/src/comctl32/hotkey.cpp	(revision 2893)
+++ trunk/src/comctl32/hotkey.cpp	(revision 2895)
@@ -1,3 +1,3 @@
-/* $Id: hotkey.cpp,v 1.1 2000-02-23 17:09:42 cbratschi Exp $ */
+/* $Id: hotkey.cpp,v 1.2 2000-02-25 17:00:15 cbratschi Exp $ */
 /*
  * Hotkey control
@@ -7,5 +7,5 @@
  * Copyright 1999 Christoph Bratschi
  *
- * Status: Complete (perhaps some bugs)
+ * Status: Complete
  * Version: 5.00
  */
@@ -13,8 +13,9 @@
 #include "winbase.h"
 #include "commctrl.h"
+#include "ccbase.h"
 #include "hotkey.h"
 #include <string.h>
 
-#define HOTKEY_GetInfoPtr(hwnd) ((HOTKEY_INFO*)GetWindowLongA(hwnd,0))
+#define HOTKEY_GetInfoPtr(hwnd) ((HOTKEY_INFO*)getInfoPtr(hwnd))
 
 static VOID
@@ -23,5 +24,5 @@
   InvalidateRect(hwnd,NULL,FALSE);
 
-  if (notify) SendMessageA(GetParent(hwnd),WM_COMMAND,MAKEWPARAM(GetWindowLongA(hwnd,GWL_ID),EN_CHANGE),hwnd);
+  if (notify) sendCommand(hwnd,EN_CHANGE);
 }
 
@@ -299,12 +300,12 @@
   BYTE mods = bfMods & ~HOTKEYF_EXT;
 
-  if ((infoPtr->fwCombInv & HKCOMB_A && mods == HOTKEYF_ALT) ||
-      (infoPtr->fwCombInv & HKCOMB_C && mods == HOTKEYF_CONTROL) ||
-      (infoPtr->fwCombInv & HKCOMB_CA && mods == HOTKEYF_CONTROL | HOTKEYF_ALT) ||
-      (infoPtr->fwCombInv & HKCOMB_NONE && mods == 0) ||
-      (infoPtr->fwCombInv & HKCOMB_S && mods == HOTKEYF_SHIFT) ||
-      (infoPtr->fwCombInv & HKCOMB_SA && mods == HOTKEYF_SHIFT | HOTKEYF_ALT) ||
-      (infoPtr->fwCombInv & HKCOMB_SC && mods == HOTKEYF_SHIFT | HOTKEYF_CONTROL) ||
-      (infoPtr->fwCombInv & HKCOMB_SCA && mods == HOTKEYF_SHIFT | HOTKEYF_CONTROL | HOTKEYF_ALT))
+  if (((infoPtr->fwCombInv & HKCOMB_A) && (mods == HOTKEYF_ALT)) ||
+      ((infoPtr->fwCombInv & HKCOMB_C) && (mods == HOTKEYF_CONTROL)) ||
+      ((infoPtr->fwCombInv & HKCOMB_CA) && (mods == HOTKEYF_CONTROL | HOTKEYF_ALT)) ||
+      ((infoPtr->fwCombInv & HKCOMB_NONE) && (mods == 0)) ||
+      ((infoPtr->fwCombInv & HKCOMB_S) && (mods == HOTKEYF_SHIFT)) ||
+      ((infoPtr->fwCombInv & HKCOMB_SA) && (mods == HOTKEYF_SHIFT | HOTKEYF_ALT)) ||
+      ((infoPtr->fwCombInv & HKCOMB_SC) && (mods == HOTKEYF_SHIFT | HOTKEYF_CONTROL)) ||
+      ((infoPtr->fwCombInv & HKCOMB_SCA) && (mods == HOTKEYF_SHIFT | HOTKEYF_CONTROL | HOTKEYF_ALT)))
     return infoPtr->fwModInv | bfMods;
   else
@@ -378,6 +379,6 @@
 
     /* allocate memory for info structure */
-    infoPtr = (HOTKEY_INFO *)COMCTL32_Alloc (sizeof(HOTKEY_INFO));
-    SetWindowLongA(hwnd,0,(DWORD)infoPtr);
+    infoPtr = (HOTKEY_INFO*)initControl(hwnd,sizeof(HOTKEY_INFO));
+    if (!infoPtr) return (LRESULT)-1;
 
     /* initialize info structure */
@@ -408,8 +409,6 @@
 HOTKEY_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
 {
-    HOTKEY_INFO *infoPtr = HOTKEY_GetInfoPtr (hwnd);
-
     /* free hotkey info data */
-    COMCTL32_Free (infoPtr);
+    doneControl(hwnd);
 
     return 0;
@@ -472,5 +471,5 @@
 
     default:
-         if (newKey != wParam && HOTKEY_ExtKey2Name(wParam))
+         if ((newKey != wParam) && HOTKEY_ExtKey2Name(wParam))
          {
            infoPtr ->bVKHotKey = wParam & 0xFF;
@@ -763,5 +762,5 @@
 //              ERR (hotkey, "unknown msg %04x wp=%08x lp=%08lx\n",
 //                   uMsg, wParam, lParam);
-            return DefWindowProcA (hwnd, uMsg, wParam, lParam);
+            return defComCtl32ProcA (hwnd, uMsg, wParam, lParam);
     }
     return 0;
@@ -773,7 +772,4 @@
 {
     WNDCLASSA wndClass;
-
-//SvL: Don't check this now
-//    if (GlobalFindAtomA (HOTKEY_CLASSA)) return;
 
     ZeroMemory (&wndClass, sizeof(WNDCLASSA));
@@ -793,6 +789,5 @@
 HOTKEY_Unregister (VOID)
 {
-    if (GlobalFindAtomA (HOTKEY_CLASSA))
-        UnregisterClassA (HOTKEY_CLASSA, (HINSTANCE)NULL);
-}
-
+    UnregisterClassA (HOTKEY_CLASSA, (HINSTANCE)NULL);
+}
+
Index: trunk/src/comctl32/ipaddress.cpp
===================================================================
--- trunk/src/comctl32/ipaddress.cpp	(revision 2893)
+++ trunk/src/comctl32/ipaddress.cpp	(revision 2895)
@@ -1,3 +1,3 @@
-/* $Id: ipaddress.cpp,v 1.1 2000-02-23 17:09:43 cbratschi Exp $ */
+/* $Id: ipaddress.cpp,v 1.2 2000-02-25 17:00:16 cbratschi Exp $ */
 /*
  * IP Address control
@@ -30,13 +30,12 @@
 #include "winbase.h"
 #include "commctrl.h"
+#include "ccbase.h"
 #include "ipaddress.h"
 //#include "heap.h"
 
 
-#define IPADDRESS_GetInfoPtr(hwnd) ((IPADDRESS_INFO *)GetWindowLongA (hwnd, 0))
-
-
-static BOOL
-IPADDRESS_SendNotify (HWND hwnd, UINT command);
+#define IPADDRESS_GetInfoPtr(hwnd) ((IPADDRESS_INFO*)getInfoPtr(hwnd))
+
+
 static BOOL
 IPADDRESS_SendIPAddressNotify (HWND hwnd, UINT field, BYTE newValue);
@@ -89,6 +88,6 @@
 
 
-    infoPtr = (IPADDRESS_INFO *)COMCTL32_Alloc (sizeof(IPADDRESS_INFO));
-    SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
+    infoPtr = (IPADDRESS_INFO*)initControl(hwnd,sizeof(IPADDRESS_INFO));
+    if (!infoPtr) return (LRESULT)-1;
 
     GetClientRect (hwnd, &rcClient);
@@ -135,7 +134,8 @@
 IPADDRESS_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
 {
-        int i;
+    int i;
     IPADDRESS_INFO *infoPtr = IPADDRESS_GetInfoPtr (hwnd);
-        LPIP_SUBCLASS_INFO lpipsi=(LPIP_SUBCLASS_INFO)
+    LPIP_SUBCLASS_INFO lpipsi=(LPIP_SUBCLASS_INFO)
+
             GetPropA ((HWND)hwnd, IP_SUBCLASS_PROP);
 
@@ -145,5 +145,5 @@
         }
 
-    COMCTL32_Free (infoPtr);
+    doneControl(hwnd);
     return 0;
 }
@@ -161,5 +161,5 @@
 
     IPADDRESS_SendIPAddressNotify (hwnd, 0, 0);  /* FIXME: should use -1 */
-    IPADDRESS_SendNotify (hwnd, EN_KILLFOCUS);
+    sendCommand(hwnd,EN_KILLFOCUS);
     InvalidateRect (hwnd, NULL, TRUE);
 
@@ -207,28 +207,12 @@
 
 static BOOL
-IPADDRESS_SendNotify (HWND hwnd, UINT command)
-
-{
-//    TRACE (ipaddress, "%x\n",command);
-    return (BOOL)SendMessageA (GetParent (hwnd), WM_COMMAND,
-              MAKEWPARAM (GetWindowLongA (hwnd, GWL_ID),command), (LPARAM)hwnd);
-}
-
-
-static BOOL
 IPADDRESS_SendIPAddressNotify (HWND hwnd, UINT field, BYTE newValue)
 {
-        NMIPADDRESS nmip;
-
-//    TRACE (ipaddress, "%x %x\n",field,newValue);
-    nmip.hdr.hwndFrom = hwnd;
-    nmip.hdr.idFrom   = GetWindowLongA (hwnd, GWL_ID);
-    nmip.hdr.code     = IPN_FIELDCHANGED;
-
-        nmip.iField=field;
-        nmip.iValue=newValue;
-
-    return (BOOL)SendMessageA (GetParent (hwnd), WM_NOTIFY,
-                               (WPARAM)nmip.hdr.idFrom, (LPARAM)&nmip);
+  NMIPADDRESS nmip;
+
+  nmip.iField=field;
+  nmip.iValue=newValue;
+
+  return (BOOL)sendNotify(hwnd,IPN_FIELDCHANGED,&nmip.hdr);
 }
 
@@ -347,5 +331,5 @@
                          sprintf (buf,"%d",value);
                          SetWindowTextA (lpipsi->hwndIP[i],buf);
-                         IPADDRESS_SendNotify (hwnd, EN_CHANGE);
+                         sendCommand(hwnd,EN_CHANGE);
                 }
                 ip_address/=256;
@@ -386,5 +370,5 @@
 
         SetFocus (hwnd);
-        IPADDRESS_SendNotify (hwnd, EN_SETFOCUS);
+        sendCommand(hwnd,EN_SETFOCUS);
         IPADDRESS_SetFocusToField (hwnd, 0, 0);
 
@@ -648,5 +632,5 @@
 //              ERR (ipaddress, "unknown msg %04x wp=%08x lp=%08lx\n",
 //                   uMsg, wParam, lParam);
-            return DefWindowProcA (hwnd, uMsg, wParam, lParam);
+            return defComCtl32ProcA (hwnd, uMsg, wParam, lParam);
     }
     return 0;
@@ -658,7 +642,4 @@
 {
     WNDCLASSA wndClass;
-
-//SvL: Don't check this now
-//    if (GlobalFindAtomA (WC_IPADDRESSA)) return;
 
     ZeroMemory (&wndClass, sizeof(WNDCLASSA));
@@ -677,5 +658,4 @@
 IPADDRESS_Unregister (VOID)
 {
-    if (GlobalFindAtomA (WC_IPADDRESSA))
     UnregisterClassA (WC_IPADDRESSA, (HINSTANCE)NULL);
 }
Index: trunk/src/comctl32/listview.cpp
===================================================================
--- trunk/src/comctl32/listview.cpp	(revision 2893)
+++ trunk/src/comctl32/listview.cpp	(revision 2895)
@@ -1,3 +1,3 @@
-/*$Id: listview.cpp,v 1.1 2000-02-23 17:09:43 cbratschi Exp $*/
+/*$Id: listview.cpp,v 1.2 2000-02-25 17:00:16 cbratschi Exp $*/
 /*
  * Listview control
@@ -21,11 +21,4 @@
  * Data structure:
  *   LISTVIEW_SetItemCount : not completed
- *
- * Unicode:
- *   LISTVIEW_SetItemW : no unicode support
- *   LISTVIEW_InsertItemW : no unicode support
- *   LISTVIEW_InsertColumnW : no unicode support
- *   LISTVIEW_GetColumnW : no unicode support
- *   LISTVIEW_SetColumnW : no unicode support
  *
  * Advanced functionality:
@@ -51,8 +44,9 @@
 
 #include <string.h>
+#include <wcstr.h>
 #include "winbase.h"
 #include "commctrl.h"
+#include "ccbase.h"
 #include "listview.h"
-//#include "debugtools.h"
 #include "comctl32.h"
 
@@ -93,8 +87,4 @@
  */
 #define GETITEMCOUNT(infoPtr) ((infoPtr)->hdpaItems->nItemCount)
-#define ListView_LVNotify(hwnd,lCtrlId,plvnm) \
-    (BOOL)SendMessageA((hwnd),WM_NOTIFY,(WPARAM)(INT)lCtrlId,(LPARAM)(LPNMLISTVIEW)(plvnm))
-#define ListView_Notify(hwnd,lCtrlId,pnmh) \
-    (BOOL)SendMessageA((hwnd),WM_NOTIFY,(WPARAM)(INT)lCtrlId,(LPARAM)(LPNMHDR)(pnmh))
 /* retrieve the number of items in the listview */
 #define GETITEMCOUNT(infoPtr) ((infoPtr)->hdpaItems->nItemCount)
@@ -104,4 +94,6 @@
         INT width, INT height, HWND parent, HINSTANCE hinst,
         EditlblCallback EditLblCb, DWORD param);
+
+#define LISTVIEW_GetInfoPtr(hwnd) ((LISTVIEW_INFO*)getInfoPtr(hwnd))
 
 /*
@@ -116,5 +108,5 @@
 static VOID LISTVIEW_AddGroupSelection(HWND, INT);
 static VOID LISTVIEW_AddSelection(HWND, INT);
-static BOOL LISTVIEW_AddSubItem(HWND, LPLVITEMA);
+static BOOL LISTVIEW_AddSubItem(HWND, LPLVITEMW,BOOL);
 static INT LISTVIEW_FindInsertPosition(HDPA, INT);
 static INT LISTVIEW_GetItemHeight(HWND);
@@ -127,6 +119,6 @@
 static LISTVIEW_SUBITEM* LISTVIEW_GetSubItem(HDPA, INT);
 static LRESULT LISTVIEW_GetViewRect(HWND, LPRECT);
-static BOOL LISTVIEW_InitItem(HWND, LISTVIEW_ITEM *, LPLVITEMA);
-static BOOL LISTVIEW_InitSubItem(HWND, LISTVIEW_SUBITEM *, LPLVITEMA);
+static BOOL LISTVIEW_InitItem(HWND, LISTVIEW_ITEM *, LPLVITEMW,BOOL);
+static BOOL LISTVIEW_InitSubItem(HWND,LISTVIEW_SUBITEM*,LPLVITEMW,BOOL);
 static LRESULT LISTVIEW_MouseSelection(HWND, POINT);
 static BOOL LISTVIEW_RemoveColumn(HDPA, INT);
@@ -134,5 +126,5 @@
 static BOOL LISTVIEW_RemoveSubItem(HDPA, INT);
 static VOID LISTVIEW_SetGroupSelection(HWND, INT);
-static BOOL LISTVIEW_SetItem(HWND, LPLVITEMA);
+static BOOL LISTVIEW_SetItem(HWND, LPLVITEMW,BOOL);
 static BOOL LISTVIEW_SetItemFocus(HWND, INT);
 static BOOL LISTVIEW_SetItemPosition(HWND, INT, INT, INT);
@@ -140,10 +132,10 @@
 static VOID LISTVIEW_SetSelection(HWND, INT);
 static VOID LISTVIEW_UpdateSize(HWND);
-static BOOL LISTVIEW_SetSubItem(HWND, LPLVITEMA);
+static BOOL LISTVIEW_SetSubItem(HWND, LPLVITEMW,BOOL);
 static LRESULT LISTVIEW_SetViewRect(HWND, LPRECT);
 static BOOL LISTVIEW_ToggleSelection(HWND, INT);
 static VOID LISTVIEW_UnsupportedStyles(LONG lStyle);
-static HWND LISTVIEW_EditLabelA(HWND hwnd, INT nItem);
-static BOOL LISTVIEW_EndEditLabel(HWND hwnd, LPSTR pszText, DWORD nItem);
+static HWND LISTVIEW_EditLabel(HWND hwnd,INT nItem,BOOL unicode);
+static BOOL LISTVIEW_EndEditLabel(HWND hwnd,LPSTR pszText,DWORD nItem);
 static LRESULT LISTVIEW_Command(HWND hwnd, WPARAM wParam, LPARAM lParam);
 static LRESULT LISTVIEW_SortItems(HWND hwnd, WPARAM wParam, LPARAM lParam);
@@ -165,5 +157,5 @@
 static VOID LISTVIEW_UpdateHeaderSize(HWND hwnd, INT nNewScrollPos)
 {
-    LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+    LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
     RECT winRect;
     POINT point[2];
@@ -197,5 +189,5 @@
 static VOID LISTVIEW_UpdateScroll(HWND hwnd)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
   LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE);
   UINT uView =  lStyle & LVS_TYPEMASK;
@@ -354,5 +346,5 @@
 static VOID LISTVIEW_AlignTop(HWND hwnd)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
   UINT uView = GetWindowLongA(hwnd, GWL_STYLE) & LVS_TYPEMASK;
   INT nListWidth = infoPtr->rcList.right - infoPtr->rcList.left;
@@ -411,5 +403,5 @@
 static VOID LISTVIEW_AlignLeft(HWND hwnd)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
   UINT uView = GetWindowLongA(hwnd, GWL_STYLE) & LVS_TYPEMASK;
   INT nListHeight = infoPtr->rcList.bottom - infoPtr->rcList.top;
@@ -470,5 +462,5 @@
 static LRESULT LISTVIEW_SetViewRect(HWND hwnd, LPRECT lprcView)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO*)GetWindowLongA(hwnd, 0);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO*)LISTVIEW_GetInfoPtr(hwnd);
   BOOL bResult = FALSE;
 
@@ -502,5 +494,5 @@
 static LRESULT LISTVIEW_GetViewRect(HWND hwnd, LPRECT lprcView)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO*)GetWindowLongA(hwnd, 0);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO*)LISTVIEW_GetInfoPtr(hwnd);
   BOOL bResult = FALSE;
   POINT ptOrigin;
@@ -572,5 +564,5 @@
 static INT LISTVIEW_GetItemWidth(HWND hwnd)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
   UINT uView = GetWindowLongA(hwnd, GWL_STYLE) & LVS_TYPEMASK;
   INT nHeaderItemCount;
@@ -657,5 +649,5 @@
 static INT LISTVIEW_CalculateWidth(HWND hwnd, INT nItem)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
   UINT uView = GetWindowLongA(hwnd, GWL_STYLE) & LVS_TYPEMASK;
   INT nHeaderItemCount;
@@ -732,5 +724,5 @@
 static INT LISTVIEW_GetItemHeight(HWND hwnd)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
   UINT uView = GetWindowLongA(hwnd, GWL_STYLE) & LVS_TYPEMASK;
   INT nItemHeight = 0;
@@ -767,16 +759,12 @@
 static VOID LISTVIEW_AddGroupSelection(HWND hwnd, INT nItem)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
   INT nFirst = min(infoPtr->nSelectionMark, nItem);
   INT nLast = max(infoPtr->nSelectionMark, nItem);
-  LVITEMA lvItem;
   INT i;
 
-  lvItem.state = LVIS_SELECTED;
-  lvItem.stateMask= LVIS_SELECTED;
-
   for (i = nFirst; i <= nLast; i++)
   {
-    ListView_SetItemState(hwnd, i, &lvItem);
+    ListView_SetItemState(hwnd,i,LVIS_SELECTED,LVIS_SELECTED);
   }
 
@@ -798,11 +786,7 @@
 static VOID LISTVIEW_AddSelection(HWND hwnd, INT nItem)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
-  LVITEMA lvItem;
-
-  lvItem.state = LVIS_SELECTED;
-  lvItem.stateMask= LVIS_SELECTED;
-
-  ListView_SetItemState(hwnd, nItem, &lvItem);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
+
+  ListView_SetItemState(hwnd,nItem,LVIS_SELECTED,LVIS_SELECTED);
 
   LISTVIEW_SetItemFocus(hwnd, nItem);
@@ -824,20 +808,15 @@
 static BOOL LISTVIEW_ToggleSelection(HWND hwnd, INT nItem)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
   BOOL bResult;
-  LVITEMA lvItem;
-
-  lvItem.stateMask= LVIS_SELECTED;
 
   if (ListView_GetItemState(hwnd, nItem, LVIS_SELECTED) & LVIS_SELECTED)
   {
-    lvItem.state = 0;
-    ListView_SetItemState(hwnd, nItem, &lvItem);
+    ListView_SetItemState(hwnd,nItem,0,LVIS_SELECTED);
     bResult = FALSE;
   }
   else
   {
-    lvItem.state = LVIS_SELECTED;
-    ListView_SetItemState(hwnd, nItem, &lvItem);
+    ListView_SetItemState(hwnd,nItem,LVIS_SELECTED,LVIS_SELECTED);
     bResult = TRUE;
   }
@@ -862,11 +841,8 @@
 static VOID LISTVIEW_SetSelectionRect(HWND hwnd, RECT rcSelRect)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
-  LVITEMA lvItem;
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
   POINT ptItem;
   INT i;
 
-  lvItem.stateMask = LVIS_SELECTED;
-
   for (i = 0; i < GETITEMCOUNT(infoPtr); i++)
   {
@@ -874,12 +850,10 @@
     if (PtInRect(&rcSelRect, ptItem) != FALSE)
     {
-      lvItem.state = LVIS_SELECTED;
+      ListView_SetItemState(hwnd,i,LVIS_SELECTED,LVIS_SELECTED);
     }
     else
     {
-      lvItem.state = 0;
-    }
-
-    ListView_SetItemState(hwnd, i, &lvItem);
+      ListView_SetItemState(hwnd,i,0,LVIS_SELECTED);
+    }
   }
 }
@@ -898,7 +872,6 @@
 static VOID LISTVIEW_SetGroupSelection(HWND hwnd, INT nItem)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
   UINT uView = GetWindowLongA(hwnd, GWL_STYLE) & LVS_TYPEMASK;
-  LVITEMA lvItem;
 
   if ((uView == LVS_LIST) || (uView == LVS_REPORT))
@@ -907,5 +880,4 @@
     INT nFirst = min(infoPtr->nSelectionMark, nItem);
     INT nLast = max(infoPtr->nSelectionMark, nItem);
-    lvItem.stateMask = LVIS_SELECTED;
 
     for (i = 0; i <= GETITEMCOUNT(infoPtr); i++)
@@ -913,12 +885,10 @@
       if ((i < nFirst) || (i > nLast))
       {
-        lvItem.state = 0;
+        ListView_SetItemState(hwnd,i,0,LVIS_SELECTED);
       }
       else
       {
-        lvItem.state = LVIS_SELECTED;
-      }
-
-      ListView_SetItemState(hwnd, i, &lvItem);
+        ListView_SetItemState(hwnd,i,LVIS_SELECTED,LVIS_SELECTED);
+      }
     }
   }
@@ -954,18 +924,13 @@
 static BOOL LISTVIEW_SetItemFocus(HWND hwnd, INT nItem)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
   BOOL bResult = FALSE;
-  LVITEMA lvItem;
 
   if (infoPtr->nFocusedItem != nItem)
   {
     bResult = TRUE;
-    ZeroMemory(&lvItem, sizeof(LVITEMA));
-    lvItem.stateMask = LVIS_FOCUSED;
-    ListView_SetItemState(hwnd, infoPtr->nFocusedItem, &lvItem);
-
-    lvItem.state =  LVIS_FOCUSED;
-    lvItem.stateMask = LVIS_FOCUSED;
-    ListView_SetItemState(hwnd, nItem, &lvItem);
+
+    ListView_SetItemState(hwnd,infoPtr->nFocusedItem,0,LVIS_FOCUSED);
+    ListView_SetItemState(hwnd,nItem,LVIS_FOCUSED,LVIS_FOCUSED);
 
     infoPtr->nFocusedItem = nItem;
@@ -989,6 +954,5 @@
 static VOID LISTVIEW_SetSelection(HWND hwnd, INT nItem)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
-  LVITEMA lvItem;
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
 
   if (nItem > 0)
@@ -1002,11 +966,6 @@
   }
 
-  ZeroMemory(&lvItem, sizeof(LVITEMA));
-  lvItem.stateMask = LVIS_FOCUSED;
-  ListView_SetItemState(hwnd, infoPtr->nFocusedItem, &lvItem);
-
-  lvItem.state =  LVIS_SELECTED | LVIS_FOCUSED;
-  lvItem.stateMask = LVIS_SELECTED | LVIS_FOCUSED;
-  ListView_SetItemState(hwnd, nItem, &lvItem);
+  ListView_SetItemState(hwnd,infoPtr->nFocusedItem,0,LVIS_FOCUSED);
+  ListView_SetItemState(hwnd,nItem,LVIS_SELECTED | LVIS_FOCUSED,LVIS_SELECTED | LVIS_FOCUSED);
 
   infoPtr->nFocusedItem = nItem;
@@ -1028,5 +987,5 @@
 static BOOL LISTVIEW_KeySelection(HWND hwnd, INT nItem)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
   LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE);
   WORD wShift = HIWORD(GetKeyState(VK_SHIFT));
@@ -1079,5 +1038,5 @@
 static LRESULT LISTVIEW_MouseSelection(HWND hwnd, POINT pt)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
   RECT rcItem;
   INT i;
@@ -1112,13 +1071,9 @@
 static VOID LISTVIEW_RemoveSelections(HWND hwnd, INT nFirst, INT nLast)
 {
-  LVITEMA lvItem;
   INT i;
 
-  lvItem.state = 0;
-  lvItem.stateMask = LVIS_SELECTED;
-
   for (i = nFirst; i <= nLast; i++)
   {
-    ListView_SetItemState(hwnd, i, &lvItem);
+    ListView_SetItemState(hwnd,i,0,LVIS_SELECTED);
   }
 }
@@ -1183,5 +1138,5 @@
         /* free string */
         if ((lpSubItem->pszText != NULL) &&
-            (lpSubItem->pszText != LPSTR_TEXTCALLBACKA))
+            (lpSubItem->pszText != LPSTR_TEXTCALLBACKW))
         {
           COMCTL32_Free(lpSubItem->pszText);
@@ -1219,5 +1174,5 @@
  *   FAILURE : FALSE (NOT EQUAL)
  */
-static UINT LISTVIEW_GetItemChanges(LISTVIEW_ITEM *lpItem, LPLVITEMA lpLVItem)
+static UINT LISTVIEW_GetItemChanges(LISTVIEW_ITEM *lpItem,LPLVITEMW lpLVItem,BOOL unicode)
 {
   UINT uChanged = 0;
@@ -1260,24 +1215,32 @@
     if (lpLVItem->mask & LVIF_TEXT)
     {
-      if (lpLVItem->pszText == LPSTR_TEXTCALLBACKA)
-      {
-        if (lpItem->pszText != LPSTR_TEXTCALLBACKA)
-        {
-          uChanged |= LVIF_TEXT;
-        }
-      }
-      else
-      {
-        if (lpItem->pszText == LPSTR_TEXTCALLBACKA)
-        {
-          uChanged |= LVIF_TEXT;
+      if (unicode)
+      {
+        if (lpLVItem->pszText == LPSTR_TEXTCALLBACKW)
+        {
+          if (lpItem->pszText != LPSTR_TEXTCALLBACKW)
+          {
+            uChanged |= LVIF_TEXT;
+          }
+
         }
         else
         {
-          if (lpLVItem->pszText)
+          if (lpItem->pszText == LPSTR_TEXTCALLBACKW)
           {
-            if (lpItem->pszText)
+            uChanged |= LVIF_TEXT;
+          }
+          else
+          {
+            if (lpLVItem->pszText)
             {
-              if (strcmp(lpLVItem->pszText, lpItem->pszText) != 0)
+              if (lpItem->pszText)
+              {
+                if (lstrcmpW(lpLVItem->pszText, lpItem->pszText) != 0)
+                {
+                  uChanged |= LVIF_TEXT;
+                }
+              }
+              else
               {
                 uChanged |= LVIF_TEXT;
@@ -1286,12 +1249,53 @@
             else
             {
-              uChanged |= LVIF_TEXT;
+              if (lpItem->pszText)
+              {
+                uChanged |= LVIF_TEXT;
+              }
             }
+          }
+        }
+      } else //!unicode
+      {
+        if ((LPSTR)lpLVItem->pszText == LPSTR_TEXTCALLBACKA)
+        {
+          if (lpItem->pszText != LPSTR_TEXTCALLBACKW)
+          {
+            uChanged |= LVIF_TEXT;
+          }
+
+        }
+        else
+        {
+          if (lpItem->pszText == LPSTR_TEXTCALLBACKW)
+          {
+            uChanged |= LVIF_TEXT;
           }
           else
           {
-            if (lpItem->pszText)
+            if (lpLVItem->pszText)
             {
-              uChanged |= LVIF_TEXT;
+              if (lpItem->pszText)
+              {
+                LPWSTR textW = HEAP_strdupAtoW(GetProcessHeap(),0,(LPSTR)lpLVItem->pszText);
+
+                //CB: need a lstrcmpAtoW
+                if (lstrcmpW(textW,lpItem->pszText) != 0)
+                {
+                  uChanged |= LVIF_TEXT;
+                }
+                FreeAsciiString((LPSTR)textW);
+              }
+              else
+              {
+                uChanged |= LVIF_TEXT;
+              }
+            }
+            else
+            {
+              if (lpItem->pszText)
+              {
+                uChanged |= LVIF_TEXT;
+              }
             }
           }
@@ -1316,6 +1320,5 @@
  *   FAILURE : FALSE
  */
-static BOOL LISTVIEW_InitItem(HWND hwnd, LISTVIEW_ITEM *lpItem,
-                              LPLVITEMA lpLVItem)
+static BOOL LISTVIEW_InitItem(HWND hwnd,LISTVIEW_ITEM *lpItem,LPLVITEMW lpLVItem,BOOL unicode)
 {
   LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE);
@@ -1349,73 +1352,7 @@
     if (lpLVItem->mask & LVIF_TEXT)
     {
-      if (lpLVItem->pszText == LPSTR_TEXTCALLBACKA)
-      {
-        if ((lStyle & LVS_SORTASCENDING) || (lStyle & LVS_SORTDESCENDING))
-        {
-          return FALSE;
-        }
-
-        if ((lpItem->pszText != NULL) &&
-            (lpItem->pszText != LPSTR_TEXTCALLBACKA))
-        {
-          COMCTL32_Free(lpItem->pszText);
-        }
-
-        lpItem->pszText = LPSTR_TEXTCALLBACKA;
-      }
-      else
-      {
-        if (lpItem->pszText == LPSTR_TEXTCALLBACKA)
-        {
-          lpItem->pszText = NULL;
-        }
-
-        bResult = Str_SetPtrA(&lpItem->pszText, lpLVItem->pszText);
-      }
-    }
-  }
-
-  return bResult;
-}
-
-/***
- * DESCRIPTION:
- * Initializes subitem attributes.
- *
- * NOTE: The documentation specifies that the operation fails if the user
- * tries to set the indent of a subitem.
- *
- * PARAMETER(S):
- * [I] HWND : window handle
- * [O] LISTVIEW_SUBITEM *: destination subitem
- * [I] LPLVITEM : source subitem
- *
- * RETURN:
- *   SUCCCESS : TRUE
- *   FAILURE : FALSE
- */
-static BOOL LISTVIEW_InitSubItem(HWND hwnd, LISTVIEW_SUBITEM *lpSubItem,
-                                   LPLVITEMA lpLVItem)
-{
-  LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE);
-  BOOL bResult = FALSE;
-
-  if ((lpSubItem != NULL) && (lpLVItem != NULL))
-  {
-    if (!(lpLVItem->mask & LVIF_INDENT))
-    {
-      bResult = TRUE;
-      ZeroMemory(lpSubItem, sizeof(LISTVIEW_SUBITEM));
-
-      lpSubItem->iSubItem = lpLVItem->iSubItem;
-
-      if (lpLVItem->mask & LVIF_IMAGE)
-      {
-        lpSubItem->iImage = lpLVItem->iImage;
-      }
-
-      if (lpLVItem->mask & LVIF_TEXT)
-      {
-        if (lpLVItem->pszText == LPSTR_TEXTCALLBACKA)
+      if (unicode)
+      {
+        if (lpLVItem->pszText == LPSTR_TEXTCALLBACKW)
         {
           if ((lStyle & LVS_SORTASCENDING) || (lStyle & LVS_SORTDESCENDING))
@@ -1424,20 +1361,157 @@
           }
 
-          if ((lpSubItem->pszText != NULL) &&
-              (lpSubItem->pszText != LPSTR_TEXTCALLBACKA))
+          if ((lpItem->pszText != NULL) &&
+              (lpItem->pszText != LPSTR_TEXTCALLBACKW))
           {
-            COMCTL32_Free(lpSubItem->pszText);
+            COMCTL32_Free(lpItem->pszText);
           }
 
-          lpSubItem->pszText = LPSTR_TEXTCALLBACKA;
+          lpItem->pszText = LPSTR_TEXTCALLBACKW;
         }
         else
         {
-          if (lpSubItem->pszText == LPSTR_TEXTCALLBACKA)
+          if (lpItem->pszText == LPSTR_TEXTCALLBACKW)
           {
-            lpSubItem->pszText = NULL;
+            lpItem->pszText = NULL;
           }
 
-          bResult = Str_SetPtrA(&lpSubItem->pszText, lpLVItem->pszText);
+          bResult = Str_SetPtrW(&lpItem->pszText, lpLVItem->pszText);
+        }
+      } else //!unicode
+      {
+        if ((LPSTR)lpLVItem->pszText == LPSTR_TEXTCALLBACKA)
+        {
+          if ((lStyle & LVS_SORTASCENDING) || (lStyle & LVS_SORTDESCENDING))
+          {
+            return FALSE;
+          }
+
+          if ((lpItem->pszText != NULL) &&
+              (lpItem->pszText != LPSTR_TEXTCALLBACKW))
+          {
+            COMCTL32_Free(lpItem->pszText);
+          }
+
+          lpItem->pszText = LPSTR_TEXTCALLBACKW;
+        }
+        else
+        {
+          INT len;
+
+          if (lpItem->pszText != LPSTR_TEXTCALLBACKW) COMCTL32_Free(lpItem->pszText);
+          len = (lpLVItem->pszText != NULL) ? lstrlenA((LPSTR)lpLVItem->pszText):0;
+
+          if (len > 0)
+          {
+            len++;
+            lpItem->pszText = (LPWSTR)COMCTL32_Alloc(len*sizeof(WCHAR));
+            lstrcpyAtoW(lpItem->pszText,(LPSTR)lpLVItem->pszText);
+          } else lpItem->pszText = NULL;
+
+          bResult = TRUE;
+        }
+      }
+    }
+  }
+
+  return bResult;
+}
+
+/***
+ * DESCRIPTION:
+ * Initializes subitem attributes.
+ *
+ * NOTE: The documentation specifies that the operation fails if the user
+ * tries to set the indent of a subitem.
+ *
+ * PARAMETER(S):
+ * [I] HWND : window handle
+ * [O] LISTVIEW_SUBITEM *: destination subitem
+ * [I] LPLVITEM : source subitem
+ *
+ * RETURN:
+ *   SUCCCESS : TRUE
+ *   FAILURE : FALSE
+ */
+static BOOL LISTVIEW_InitSubItem(HWND hwnd,LISTVIEW_SUBITEM *lpSubItem,LPLVITEMW lpLVItem,BOOL unicode)
+{
+  LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE);
+  BOOL bResult = FALSE;
+
+  if ((lpSubItem != NULL) && (lpLVItem != NULL))
+  {
+    if (!(lpLVItem->mask & LVIF_INDENT))
+    {
+      bResult = TRUE;
+      ZeroMemory(lpSubItem, sizeof(LISTVIEW_SUBITEM));
+
+      lpSubItem->iSubItem = lpLVItem->iSubItem;
+
+      if (lpLVItem->mask & LVIF_IMAGE)
+      {
+        lpSubItem->iImage = lpLVItem->iImage;
+      }
+
+      if (lpLVItem->mask & LVIF_TEXT)
+      {
+        if (unicode)
+        {
+          if (lpLVItem->pszText == LPSTR_TEXTCALLBACKW)
+          {
+            if ((lStyle & LVS_SORTASCENDING) || (lStyle & LVS_SORTDESCENDING))
+            {
+              return FALSE;
+            }
+
+            if ((lpSubItem->pszText != NULL) &&
+                (lpSubItem->pszText != LPSTR_TEXTCALLBACKW))
+            {
+              COMCTL32_Free(lpSubItem->pszText);
+            }
+
+            lpSubItem->pszText = LPSTR_TEXTCALLBACKW;
+          }
+          else
+          {
+            if (lpSubItem->pszText == LPSTR_TEXTCALLBACKW)
+            {
+              lpSubItem->pszText = NULL;
+            }
+
+            bResult = Str_SetPtrW(&lpSubItem->pszText, lpLVItem->pszText);
+          }
+        } else //!unicode
+        {
+          if ((LPSTR)lpLVItem->pszText == LPSTR_TEXTCALLBACKA)
+          {
+            if ((lStyle & LVS_SORTASCENDING) || (lStyle & LVS_SORTDESCENDING))
+            {
+              return FALSE;
+            }
+
+            if ((lpSubItem->pszText != NULL) &&
+                (lpSubItem->pszText != LPSTR_TEXTCALLBACKW))
+            {
+              COMCTL32_Free(lpSubItem->pszText);
+            }
+
+            lpSubItem->pszText = LPSTR_TEXTCALLBACKW;
+          }
+          else
+          {
+            INT len;
+
+            if (lpSubItem->pszText != LPSTR_TEXTCALLBACKW) COMCTL32_Free(lpSubItem->pszText);
+            len = (lpLVItem->pszText != NULL) ? lstrlenA((LPSTR)lpLVItem->pszText):0;
+
+            if (len > 0)
+            {
+              len++;
+              lpSubItem->pszText = (LPWSTR)COMCTL32_Alloc(len*sizeof(WCHAR));
+              lstrcpyAtoW(lpSubItem->pszText,(LPSTR)lpLVItem->pszText);
+            } else lpSubItem->pszText = NULL;
+
+            bResult = TRUE;
+          }
         }
       }
@@ -1460,7 +1534,7 @@
  *   FAILURE : FALSE
  */
-static BOOL LISTVIEW_AddSubItem(HWND hwnd, LPLVITEMA lpLVItem)
-{
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+static BOOL LISTVIEW_AddSubItem(HWND hwnd, LPLVITEMW lpLVItem,BOOL unicode)
+{
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
   LISTVIEW_SUBITEM *lpSubItem = NULL;
   BOOL bResult = FALSE;
@@ -1476,5 +1550,5 @@
       if (lpSubItem != NULL)
       {
-        if (LISTVIEW_InitSubItem(hwnd, lpSubItem, lpLVItem) != FALSE)
+        if (LISTVIEW_InitSubItem(hwnd, lpSubItem, lpLVItem,unicode) != FALSE)
         {
           nPosition = LISTVIEW_FindInsertPosition(hdpaSubItems,
@@ -1579,7 +1653,7 @@
  *   FAILURE : FALSE
  */
-static BOOL LISTVIEW_SetItem(HWND hwnd, LPLVITEMA lpLVItem)
-{
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+static BOOL LISTVIEW_SetItem(HWND hwnd, LPLVITEMW lpLVItem,BOOL unicode)
+{
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
   BOOL bResult = FALSE;
   HDPA hdpaSubItems;
@@ -1600,9 +1674,6 @@
         {
           ZeroMemory(&nmlv, sizeof(NMLISTVIEW));
-          nmlv.hdr.hwndFrom = hwnd;
-          nmlv.hdr.idFrom = lCtrlId;
-          nmlv.hdr.code = LVN_ITEMCHANGING;
           nmlv.lParam = lpItem->lParam;
-          uChanged = LISTVIEW_GetItemChanges(lpItem, lpLVItem);
+          uChanged = LISTVIEW_GetItemChanges(lpItem, lpLVItem,unicode);
           if (uChanged != 0)
           {
@@ -1617,12 +1688,11 @@
             nmlv.lParam = lpItem->lParam;
             /* send LVN_ITEMCHANGING notification */
-            ListView_LVNotify(GetParent(hwnd), lCtrlId, &nmlv);
+            sendNotify(hwnd,LVN_ITEMCHANGING,&nmlv.hdr);
 
             /* copy information */
-            bResult = LISTVIEW_InitItem(hwnd, lpItem, lpLVItem);
+            bResult = LISTVIEW_InitItem(hwnd, lpItem, lpLVItem,unicode);
 
             /* send LVN_ITEMCHANGED notification */
-            nmlv.hdr.code = LVN_ITEMCHANGED;
-            ListView_LVNotify(GetParent(hwnd), lCtrlId, &nmlv);
+            sendNotify(hwnd,LVN_ITEMCHANGED,&nmlv.hdr);
           }
           else
@@ -1652,7 +1722,7 @@
  *   FAILURE : FALSE
  */
-static BOOL LISTVIEW_SetSubItem(HWND hwnd, LPLVITEMA lpLVItem)
-{
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+static BOOL LISTVIEW_SetSubItem(HWND hwnd, LPLVITEMW lpLVItem,BOOL unicode)
+{
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
   BOOL bResult = FALSE;
   HDPA hdpaSubItems;
@@ -1672,9 +1742,9 @@
           if (lpSubItem != NULL)
           {
-            bResult = LISTVIEW_InitSubItem(hwnd, lpSubItem, lpLVItem);
+            bResult = LISTVIEW_InitSubItem(hwnd, lpSubItem, lpLVItem,unicode);
           }
           else
           {
-            bResult = LISTVIEW_AddSubItem(hwnd, lpLVItem);
+            bResult = LISTVIEW_AddSubItem(hwnd, lpLVItem,unicode);
           }
 
@@ -1750,7 +1820,7 @@
                                  RECT rcItem)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
-  CHAR szDispText[DISP_TEXT_SIZE];
-  LVITEMA lvItem;
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
+  WCHAR szDispText[DISP_TEXT_SIZE];
+  LVITEMW lvItem;
 
 //  TRACE("(hwnd=%x, hdc=%x, nItem=%d, nSubItem=%d\n", hwnd, hdc,
@@ -1758,5 +1828,5 @@
 
   /* get information needed for drawing the item */
-  ZeroMemory(&lvItem, sizeof(LVITEMA));
+  ZeroMemory(&lvItem, sizeof(LVITEMW));
   lvItem.mask = LVIF_TEXT;
   lvItem.iItem = nItem;
@@ -1764,5 +1834,5 @@
   lvItem.cchTextMax = DISP_TEXT_SIZE;
   lvItem.pszText = szDispText;
-  ListView_GetItemA(hwnd,&lvItem);
+  ListView_GetItemW(hwnd,&lvItem);
 
   /* set item colors */
@@ -1770,6 +1840,6 @@
   SetTextColor(hdc, infoPtr->clrText);
 
-  ExtTextOutA(hdc, rcItem.left, rcItem.top, ETO_OPAQUE | ETO_CLIPPED,
-              &rcItem, lvItem.pszText, lstrlenA(lvItem.pszText), NULL);
+  ExtTextOutW(hdc, rcItem.left, rcItem.top, ETO_OPAQUE | ETO_CLIPPED,
+              &rcItem, lvItem.pszText, lstrlenW(lvItem.pszText), NULL);
 }
 
@@ -1790,8 +1860,8 @@
 static VOID LISTVIEW_DrawItem(HWND hwnd, HDC hdc, INT nItem, RECT rcItem)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
-  CHAR szDispText[DISP_TEXT_SIZE];
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
+  WCHAR szDispText[DISP_TEXT_SIZE];
   INT nLabelWidth;
-  LVITEMA lvItem;
+  LVITEMW lvItem;
   INT nMixMode;
   DWORD dwBkColor;
@@ -1801,5 +1871,5 @@
 
   /* get information needed for drawing the item */
-  ZeroMemory(&lvItem, sizeof(LVITEMA));
+  ZeroMemory(&lvItem, sizeof(LVITEMW));
   lvItem.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_STATE | LVIF_INDENT;
   lvItem.stateMask = LVIS_SELECTED | LVIS_FOCUSED | LVIS_STATEIMAGEMASK;
@@ -1808,5 +1878,5 @@
   lvItem.cchTextMax = DISP_TEXT_SIZE;
   lvItem.pszText = szDispText;
-  ListView_GetItemA(hwnd,&lvItem);
+  ListView_GetItemW(hwnd,&lvItem);
 
   /* state icons */
@@ -1871,11 +1941,11 @@
   }
 
-  nLabelWidth = ListView_GetStringWidthA(hwnd, lvItem.pszText);
+  nLabelWidth = ListView_GetStringWidthW(hwnd, lvItem.pszText);
   if (rcItem.left + nLabelWidth < rcItem.right)
     rcItem.right = rcItem.left + nLabelWidth;
 
   /* draw label */
-  ExtTextOutA(hdc, rcItem.left, rcItem.top, ETO_OPAQUE | ETO_CLIPPED,
-              &rcItem, lvItem.pszText, lstrlenA(lvItem.pszText), NULL);
+  ExtTextOutW(hdc, rcItem.left, rcItem.top, ETO_OPAQUE | ETO_CLIPPED,
+              &rcItem, lvItem.pszText, lstrlenW(lvItem.pszText), NULL);
 
   if ((lvItem.state & LVIS_FOCUSED) && (infoPtr->bFocus == TRUE))
@@ -1908,10 +1978,10 @@
 static VOID LISTVIEW_DrawLargeItem(HWND hwnd, HDC hdc, INT nItem, RECT rcItem)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
-  CHAR szDispText[DISP_TEXT_SIZE];
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
+  WCHAR szDispText[DISP_TEXT_SIZE];
   INT nDrawPosX = rcItem.left;
   INT nLabelWidth;
   TEXTMETRICA tm;
-  LVITEMA lvItem;
+  LVITEMW lvItem;
 
 //  TRACE("(hwnd=%x, hdc=%x, nItem=%d, left=%d, top=%d, right=%d, \
@@ -1920,5 +1990,5 @@
 
   /* get information needed for drawing the item */
-  ZeroMemory(&lvItem, sizeof(LVITEMA));
+  ZeroMemory(&lvItem, sizeof(LVITEMW));
   lvItem.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_STATE;
   lvItem.stateMask = LVIS_SELECTED | LVIS_FOCUSED;
@@ -1927,5 +1997,5 @@
   lvItem.cchTextMax = DISP_TEXT_SIZE;
   lvItem.pszText = szDispText;
-  ListView_GetItemA(hwnd, &lvItem);
+  ListView_GetItemW(hwnd, &lvItem);
 
   if (lvItem.state & LVIS_SELECTED)
@@ -1963,5 +2033,5 @@
 
   rcItem.top += infoPtr->iconSize.cy + ICON_BOTTOM_PADDING;
-  nLabelWidth = ListView_GetStringWidthA(hwnd, lvItem.pszText);
+  nLabelWidth = ListView_GetStringWidthW(hwnd, lvItem.pszText);
   nDrawPosX = infoPtr->iconSpacing.cx - nLabelWidth;
   if (nDrawPosX > 1)
@@ -1979,6 +2049,6 @@
   GetTextMetricsA(hdc, &tm);
   rcItem.bottom = rcItem.top + tm.tmHeight + HEIGHT_PADDING;
-  ExtTextOutA(hdc, rcItem.left, rcItem.top, ETO_OPAQUE | ETO_CLIPPED,
-              &rcItem, lvItem.pszText, lstrlenA(lvItem.pszText), NULL);
+  ExtTextOutW(hdc, rcItem.left, rcItem.top, ETO_OPAQUE | ETO_CLIPPED,
+              &rcItem, lvItem.pszText, lstrlenW(lvItem.pszText), NULL);
 
   if (lvItem.state & LVIS_FOCUSED)
@@ -2001,5 +2071,5 @@
 static VOID LISTVIEW_RefreshReport(HWND hwnd, HDC hdc)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd,0);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
   SCROLLINFO scrollInfo;
   INT nDrawPosY = infoPtr->rcList.top;
@@ -2020,6 +2090,4 @@
   nLast = min(nLast, GETITEMCOUNT(infoPtr));
 
-//AH required for Odin?
-#if 0
   /* send cache hint notification */
   if (GetWindowLongA(hwnd,GWL_STYLE) & LVS_OWNERDATA)
@@ -2027,14 +2095,9 @@
     NMLVCACHEHINT nmlv;
 
-    nmlv.hdr.hwndFrom = hwnd;
-    nmlv.hdr.idFrom = GetWindowLongA(hwnd,GWL_ID);
-    nmlv.hdr.code = LVN_ODCACHEHINT;
     nmlv.iFrom = nItem;
     nmlv.iTo   = nLast;
 
-    SendMessageA(GetParent(hwnd), WM_NOTIFY, (WPARAM)nmlv.hdr.idFrom,
-                 (LPARAM)&nmlv);
-  }
-#endif
+    sendNotify(hwnd,LVN_ODCACHEHINT,&nmlv.hdr);
+  }
 
   for (; nItem < nLast; nItem++)
@@ -2082,5 +2145,5 @@
 static INT LISTVIEW_GetCountPerRow(HWND hwnd)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd,0);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
   UINT uView = GetWindowLongA(hwnd, GWL_STYLE) & LVS_TYPEMASK;
   INT nListWidth = infoPtr->rcList.right - infoPtr->rcList.left;
@@ -2119,5 +2182,5 @@
 static INT LISTVIEW_GetCountPerColumn(HWND hwnd)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd,0);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
   INT nListHeight = infoPtr->rcList.bottom - infoPtr->rcList.top;
   INT nCountPerColumn = 1;
@@ -2148,5 +2211,5 @@
 static INT LISTVIEW_GetColumnCount(HWND hwnd)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
   LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE);
   INT nColumnCount = 0;
@@ -2181,5 +2244,5 @@
 static VOID LISTVIEW_RefreshList(HWND hwnd, HDC hdc)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
   RECT rcItem;
   INT i, j;
@@ -2224,5 +2287,5 @@
 static VOID LISTVIEW_RefreshIcon(HWND hwnd, HDC hdc, BOOL bSmall)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
   POINT ptPosition;
   POINT ptOrigin;
@@ -2277,5 +2340,5 @@
 static VOID LISTVIEW_Refresh(HWND hwnd, HDC hdc)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
   UINT uView = GetWindowLongA(hwnd, GWL_STYLE) & LVS_TYPEMASK;
   HFONT hOldFont;
@@ -2334,5 +2397,5 @@
                                             WORD wWidth, WORD wHeight)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
   UINT uView = GetWindowLongA(hwnd, GWL_STYLE) & LVS_TYPEMASK;
   INT nItemCountPerColumn = 1;
@@ -2455,5 +2518,5 @@
 static LRESULT LISTVIEW_DeleteAllItems(HWND hwnd)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
   LONG lCtrlId = GetWindowLongA(hwnd, GWL_ID);
   LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE);
@@ -2476,12 +2539,9 @@
 
     /* send LVN_DELETEALLITEMS notification */
-    nmlv.hdr.hwndFrom = hwnd;
-    nmlv.hdr.idFrom = lCtrlId;
-    nmlv.hdr.code = LVN_DELETEALLITEMS;
     nmlv.iItem = -1;
 
     /* verify if subsequent LVN_DELETEITEM notifications should be
        suppressed */
-    bSuppress = ListView_LVNotify(GetParent(hwnd), lCtrlId, &nmlv);
+    bSuppress = sendNotify(hwnd,LVN_DELETEALLITEMS,&nmlv.hdr);
 
     for (i = 0; i < GETITEMCOUNT(infoPtr); i++)
@@ -2497,5 +2557,5 @@
             /* free subitem string */
             if ((lpSubItem->pszText != NULL) &&
-                (lpSubItem->pszText != LPSTR_TEXTCALLBACKA))
+                (lpSubItem->pszText != LPSTR_TEXTCALLBACKW))
             {
               COMCTL32_Free(lpSubItem->pszText);
@@ -2513,13 +2573,12 @@
           {
             /* send LVN_DELETEITEM notification */
-            nmlv.hdr.code = LVN_DELETEITEM;
             nmlv.iItem = i;
             nmlv.lParam = lpItem->lParam;
-            ListView_LVNotify(GetParent(hwnd), lCtrlId, &nmlv);
+            sendNotify(hwnd,LVN_DELETEITEM,&nmlv.hdr);
           }
 
           /* free item string */
           if ((lpItem->pszText != NULL) &&
-              (lpItem->pszText != LPSTR_TEXTCALLBACKA))
+              (lpItem->pszText != LPSTR_TEXTCALLBACKW))
           {
             COMCTL32_Free(lpItem->pszText);
@@ -2573,5 +2632,5 @@
 static LRESULT LISTVIEW_DeleteColumn(HWND hwnd, INT nColumn)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
   UINT uView = GetWindowLongA(hwnd, GWL_STYLE) & LVS_TYPEMASK;
   BOOL bResult = FALSE;
@@ -2612,8 +2671,7 @@
 static LRESULT LISTVIEW_DeleteItem(HWND hwnd, INT nItem)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
   LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE);
   UINT uView = lStyle & LVS_TYPEMASK;
-  LONG lCtrlId = GetWindowLongA(hwnd, GWL_ID);
   NMLISTVIEW nmlv;
   BOOL bResult = FALSE;
@@ -2640,5 +2698,5 @@
           /* free item string */
           if ((lpSubItem->pszText != NULL) &&
-              (lpSubItem->pszText != LPSTR_TEXTCALLBACKA))
+              (lpSubItem->pszText != LPSTR_TEXTCALLBACKW))
           {
             COMCTL32_Free(lpSubItem->pszText);
@@ -2654,15 +2712,11 @@
       {
         /* send LVN_DELETEITEM notification */
-        nmlv.hdr.hwndFrom = hwnd;
-        nmlv.hdr.idFrom = lCtrlId;
-        nmlv.hdr.code = LVN_DELETEITEM;
         nmlv.iItem = nItem;
         nmlv.lParam = lpItem->lParam;
-        SendMessageA(GetParent(hwnd), WM_NOTIFY, (WPARAM)lCtrlId,
-                     (LPARAM)&nmlv);
+        sendNotify(hwnd,LVN_DELETEITEM,&nmlv.hdr);
 
         /* free item string */
         if ((lpItem->pszText != NULL) &&
-            (lpItem->pszText != LPSTR_TEXTCALLBACKA))
+            (lpItem->pszText != LPSTR_TEXTCALLBACKW))
         {
           COMCTL32_Free(lpItem->pszText);
@@ -2721,5 +2775,5 @@
 static LRESULT LISTVIEW_GetEditControl(HWND hwnd)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
   return infoPtr->hwndEdit;
 }
@@ -2742,12 +2796,12 @@
 static BOOL LISTVIEW_EndEditLabel(HWND hwnd, LPSTR pszText, DWORD nItem)
 {
-  NMLVDISPINFOA dispInfo;
+  NMLVDISPINFOW dispInfo;
   LISTVIEW_ITEM *lpItem;
-  INT nCtrlId = GetWindowLongA(hwnd, GWL_ID);
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
   HDPA hdpaSubItems;
   BOOL bUpdateItemText;
-
-  ZeroMemory(&dispInfo, sizeof(NMLVDISPINFOA));
+  WCHAR* textW = NULL;
+
+  ZeroMemory(&dispInfo, sizeof(NMLVDISPINFOW));
 
   if (NULL == (hdpaSubItems = (HDPA)DPA_GetPtr(infoPtr->hdpaItems, nItem)))
@@ -2757,27 +2811,42 @@
           return FALSE;
 
-  dispInfo.hdr.hwndFrom = hwnd;
-  dispInfo.hdr.idFrom = nCtrlId;
-  dispInfo.hdr.code = LVN_ENDLABELEDITA;
   dispInfo.item.mask = 0;
   dispInfo.item.iItem = nItem;
   dispInfo.item.state = lpItem->state;
   dispInfo.item.stateMask = 0;
-  dispInfo.item.pszText = pszText;
-  dispInfo.item.cchTextMax = pszText ? strlen(pszText) : 0;
+  if (isUnicodeNotify(&infoPtr->header))
+  {
+    textW = HEAP_strdupAtoW(GetProcessHeap(),0,pszText);
+
+    dispInfo.item.pszText = textW;
+    dispInfo.item.cchTextMax = textW ? lstrlenW(textW):0;
+  } else
+  {
+    dispInfo.item.pszText = (LPWSTR)pszText;
+    dispInfo.item.cchTextMax = pszText ? lstrlenA(pszText):0;
+  }
   dispInfo.item.iImage = lpItem->iImage;
   dispInfo.item.lParam = lpItem->lParam;
   infoPtr->hwndEdit = 0;
 
-  bUpdateItemText = ListView_Notify(GetParent(hwnd), nCtrlId, &dispInfo);
+  bUpdateItemText = sendNotify(hwnd,isUnicodeNotify(&infoPtr->header) ? LVN_ENDLABELEDITW:LVN_ENDLABELEDITA,&dispInfo.hdr);
 
   /* Do we need to update the Item Text */
   if(bUpdateItemText)
   {
-    if(lpItem->pszText != LPSTR_TEXTCALLBACKA)
-    {
-        Str_SetPtrA(&lpItem->pszText, pszText);
-    }
-  }
+    if(lpItem->pszText != LPSTR_TEXTCALLBACKW)
+    {
+      if (isUnicodeNotify(&infoPtr->header))
+        Str_SetPtrW(&lpItem->pszText,textW);
+      else
+      {
+        COMCTL32_Free(lpItem->pszText);
+        lpItem->pszText = HEAP_strdupAtoW(GetProcessHeap(),0,pszText);
+      }
+
+    }
+  }
+
+  if (textW) COMCTL32_Free(textW);
 
   return TRUE;
@@ -2796,17 +2865,17 @@
  *   FAILURE : FALSE
  */
-
-static HWND LISTVIEW_EditLabelA(HWND hwnd, INT nItem)
-{
-  NMLVDISPINFOA dispInfo;
+//CB: unicode parameter not used, edit doesn't use unicode chars
+static HWND LISTVIEW_EditLabel(HWND hwnd, INT nItem,BOOL unicode)
+{
+  NMLVDISPINFOW dispInfo;
   RECT rect;
   LISTVIEW_ITEM *lpItem;
   HWND hedit;
   HINSTANCE hinst = GetWindowLongA(hwnd, GWL_HINSTANCE);
-  INT nCtrlId = GetWindowLongA(hwnd, GWL_ID);
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
   HDPA hdpaSubItems;
-  CHAR szDispText[DISP_TEXT_SIZE];
-  LVITEMA lvItem;
+  LVITEMW lvItem;
+  CHAR* textA = NULL;
+  WCHAR* textW = NULL;
 
 
@@ -2831,15 +2900,23 @@
 
   /* get information needed for drawing the item */
-  ZeroMemory(&lvItem, sizeof(LVITEMA));
+  ZeroMemory(&lvItem, sizeof(LVITEMW));
   lvItem.mask = LVIF_TEXT;
   lvItem.iItem = nItem;
   lvItem.iSubItem = 0;
   lvItem.cchTextMax = DISP_TEXT_SIZE;
-  lvItem.pszText = szDispText;
-  ListView_GetItemA(hwnd, &lvItem);
-
-  dispInfo.hdr.hwndFrom = hwnd;
-  dispInfo.hdr.idFrom = nCtrlId;
-  dispInfo.hdr.code = LVN_BEGINLABELEDITA;
+  if (isUnicodeNotify(&infoPtr->header))
+  {
+    textW = (WCHAR*)COMCTL32_Alloc(DISP_TEXT_SIZE*sizeof(WCHAR));
+    lvItem.pszText = textW;
+    ListView_GetItemW(hwnd,&lvItem);
+    dispInfo.item.cchTextMax = lstrlenW(lvItem.pszText);
+  } else
+  {
+    textA = (CHAR*)COMCTL32_Alloc(DISP_TEXT_SIZE*sizeof(CHAR));
+    lvItem.pszText = (LPWSTR)textA;
+    ListView_GetItemA(hwnd, &lvItem);
+    dispInfo.item.cchTextMax = lstrlenA((LPSTR)lvItem.pszText);
+  }
+
   dispInfo.item.mask = 0;
   dispInfo.item.iItem = nItem;
@@ -2847,9 +2924,8 @@
   dispInfo.item.stateMask = 0;
   dispInfo.item.pszText = lvItem.pszText;
-  dispInfo.item.cchTextMax = strlen(lvItem.pszText);
   dispInfo.item.iImage = lpItem->iImage;
   dispInfo.item.lParam = lpItem->lParam;
 
-  if (ListView_LVNotify(GetParent(hwnd), nCtrlId, &dispInfo))
+  if (sendNotify(hwnd,isUnicodeNotify(&infoPtr->header) ? LVN_BEGINLABELEDITW:LVN_BEGINLABELEDITA,&dispInfo.hdr))
           return 0;
 
@@ -2858,5 +2934,11 @@
           return 0;
 
-  if (!(hedit = CreateEditLabel(szDispText , WS_VISIBLE,
+  //Edit uses ANSI by default -> convert
+  if (isUnicodeNotify(&infoPtr->header))
+  {
+    textA = UnicodeToAsciiString(textW);
+  }
+
+  if (!(hedit = CreateEditLabel(textA , WS_VISIBLE,
                  rect.left-2, rect.top-1, 0,
                  rect.bottom - rect.top+2,
@@ -2868,4 +2950,7 @@
   SendMessageA(hedit, EM_SETSEL, 0, -1);
 
+  if (textA) COMCTL32_Free(textA);
+  if (textW) COMCTL32_Free(textW);
+
   return hedit;
 }
@@ -2886,5 +2971,5 @@
 static BOOL LISTVIEW_EnsureVisible(HWND hwnd, INT nItem, BOOL bPartial)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
   UINT uView = GetWindowLongA(hwnd, GWL_STYLE) & LVS_TYPEMASK;
   INT nScrollPosHeight = 0;
@@ -3044,5 +3129,5 @@
 static INT LISTVIEW_GetNearestItem(HWND hwnd, POINT pt, UINT vkDirection)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
   LVHITTESTINFO lvHitTestInfo;
   INT nItem = -1;
@@ -3104,18 +3189,18 @@
  *   FAILURE : -1
  */
-static LRESULT LISTVIEW_FindItem(HWND hwnd, INT nStart,
-                                 LPLVFINDINFO lpFindInfo)
-{
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+static LRESULT LISTVIEW_FindItem(HWND hwnd,INT nStart,LPLVFINDINFOW lpFindInfo,BOOL unicode)
+{
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
   POINT ptItem;
-  CHAR szDispText[DISP_TEXT_SIZE];
-  LVITEMA lvItem;
-  BOOL bWrap = FALSE;
+  LVITEMW lvItem;
+  BOOL bWrap = FALSE,rc;
   INT nItem = nStart;
   INT nLast = GETITEMCOUNT(infoPtr);
+  CHAR* textA = NULL;
+  WCHAR* textW = NULL;
 
   if ((nItem >= -1) && (lpFindInfo != NULL))
   {
-    ZeroMemory(&lvItem, sizeof(LVITEMA));
+    ZeroMemory(&lvItem, sizeof(LVITEMW));
 
     if (lpFindInfo->flags & LVFI_PARAM)
@@ -3127,5 +3212,13 @@
     {
       lvItem.mask |= LVIF_TEXT;
-      lvItem.pszText = szDispText;
+      if (unicode)
+      {
+        textW = (WCHAR*)COMCTL32_Alloc(DISP_TEXT_SIZE*sizeof(WCHAR));
+        lvItem.pszText = textW;
+      } else
+      {
+        textA = (CHAR*)COMCTL32_Alloc(DISP_TEXT_SIZE*sizeof(CHAR));
+        lvItem.pszText = (LPWSTR)textA;
+      }
       lvItem.cchTextMax = DISP_TEXT_SIZE;
     }
@@ -3134,5 +3227,19 @@
     {
       lvItem.mask |= LVIF_TEXT;
-      lvItem.pszText = szDispText;
+      if (unicode)
+      {
+        if (!textW)
+        {
+          textW = (WCHAR*)COMCTL32_Alloc(DISP_TEXT_SIZE*sizeof(WCHAR));
+          lvItem.pszText = textW;
+        }
+      } else
+      {
+        if (!textA)
+        {
+          textA = (CHAR*)COMCTL32_Alloc(DISP_TEXT_SIZE*sizeof(CHAR));
+          lvItem.pszText = (LPWSTR)textA;
+        }
+      }
       lvItem.cchTextMax = DISP_TEXT_SIZE;
     }
@@ -3173,5 +3280,9 @@
         lvItem.iItem = nItem;
         lvItem.iSubItem = 0;
-        if (ListView_GetItemA(hwnd, &lvItem) != FALSE)
+        if (unicode)
+          ListView_GetItemW(hwnd, &lvItem);
+        else
+          ListView_GetItemA(hwnd,(LVITEMA*)&lvItem);
+        if (rc != FALSE)
         {
           if (lvItem.mask & LVIF_TEXT)
@@ -3179,11 +3290,26 @@
             if (lpFindInfo->flags & LVFI_PARTIAL)
             {
-              if (strstr(lvItem.pszText, lpFindInfo->psz) == NULL)
+              if (unicode)
+              {
+                if (wcswcs((const wchar_t*)lvItem.pszText,(wchar_t*)lpFindInfo->psz) == NULL)
                 continue;
+              } else
+              {
+                if (strstr((LPSTR)lvItem.pszText,(LPSTR)lpFindInfo->psz) == NULL)
+                  continue;
+              }
             }
             else
             {
-              if (strcmp(lvItem.pszText, lpFindInfo->psz) != 0)
-                continue;
+              if (unicode)
+              {
+                if (lstrcmpW(lvItem.pszText,lpFindInfo->psz) != 0)
+                  continue;
+
+              } else
+              {
+                if (lstrcmpA((LPSTR)lvItem.pszText,(LPSTR)lpFindInfo->psz) != 0)
+                  continue;
+              }
             }
           }
@@ -3227,5 +3353,5 @@
 static LRESULT LISTVIEW_GetBkColor(HWND hwnd)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
 
   return infoPtr->clrBk;
@@ -3262,5 +3388,5 @@
 static UINT LISTVIEW_GetCallbackMask(HWND hwnd)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
 
   return infoPtr->uCallbackMask;
@@ -3280,8 +3406,8 @@
  *   FAILURE : FALSE
  */
-static LRESULT LISTVIEW_GetColumnA(HWND hwnd, INT nItem, LPLVCOLUMNA lpColumn)
-{
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
-  HDITEMA hdi;
+static LRESULT LISTVIEW_GetColumn(HWND hwnd,INT nItem,LPLVCOLUMNW lpColumn,BOOL unicode)
+{
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
+  HDITEMW hdi;
   BOOL bResult = FALSE;
 
@@ -3289,5 +3415,5 @@
   {
     /* initialize memory */
-    ZeroMemory(&hdi, sizeof(HDITEMA));
+    ZeroMemory(&hdi, sizeof(HDITEMW));
 
     if (lpColumn->mask & LVCF_FMT)
@@ -3318,5 +3444,8 @@
     }
 
-    bResult = Header_GetItemA(infoPtr->hwndHeader, nItem, &hdi);
+    if (unicode)
+      bResult = Header_GetItemW(infoPtr->hwndHeader,nItem,&hdi);
+    else
+      bResult = Header_GetItemA(infoPtr->hwndHeader,nItem,(HDITEMW*)&hdi);
     if (bResult != FALSE)
     {
@@ -3364,9 +3493,7 @@
 }
 
-/* LISTVIEW_GetColumnW */
-
 static LRESULT LISTVIEW_GetColumnOrderArray(HWND hwnd, INT iCount, LPINT lpiArray)
 {
-/*  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); */
+/*  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd); */
     INT i;
 
@@ -3395,5 +3522,5 @@
 static LRESULT LISTVIEW_GetColumnWidth(HWND hwnd, INT nColumn)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
   UINT uView = GetWindowLongA(hwnd, GWL_STYLE) & LVS_TYPEMASK;
   INT nColumnWidth = 0;
@@ -3409,5 +3536,5 @@
     ZeroMemory(&hdi, sizeof(HDITEMA));
     hdi.mask = HDI_WIDTH;
-    if (Header_GetItemA(infoPtr->hwndHeader, nColumn, &hdi) != FALSE)
+    if (Header_GetItemW(infoPtr->hwndHeader, nColumn, &hdi) != FALSE)
     {
       nColumnWidth = hdi.cxy;
@@ -3432,5 +3559,5 @@
 static LRESULT LISTVIEW_GetCountPerPage(HWND hwnd)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
   UINT uView = GetWindowLongA(hwnd, GWL_STYLE) & LVS_TYPEMASK;
   INT nItemCount = 0;
@@ -3473,5 +3600,5 @@
     LISTVIEW_INFO *infoPtr;
     /* make sure we can get the listview info */
-    if (!(infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0)))
+    if (!(infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd)))
         return (0);
     return (infoPtr->dwExStyle);
@@ -3490,5 +3617,5 @@
 static LRESULT LISTVIEW_GetHeader(HWND hwnd)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
 
   return infoPtr->hwndHeader;
@@ -3513,5 +3640,5 @@
 static LRESULT LISTVIEW_GetImageList(HWND hwnd, INT nImageList)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
   HIMAGELIST himl = NULL;
 
@@ -3540,5 +3667,5 @@
  * PARAMETER(S):
  * [I] HWND : window handle
- * [IO] LPLVITEMA : item info
+ * [IO] LPLVITEMW : item info
  * [I] internal : if true then we will use tricks that avoid copies
  *               but are not compatible with the regular interface
@@ -3548,10 +3675,9 @@
  *   FAILURE : FALSE
  */
-static LRESULT LISTVIEW_GetItemA(HWND hwnd, LPLVITEMA lpLVItem)
-{
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
-  LONG lCtrlId = GetWindowLongA(hwnd, GWL_ID);
+static LRESULT LISTVIEW_GetItem(HWND hwnd, LPLVITEMW lpLVItem,BOOL unicode)
+{
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
   BOOL bResult = FALSE;
-  NMLVDISPINFOA dispInfo;
+  NMLVDISPINFOW dispInfo;
   LISTVIEW_SUBITEM *lpSubItem;
   LISTVIEW_ITEM *lpItem;
@@ -3564,5 +3690,5 @@
     if ((lpLVItem->iItem >= 0) && (lpLVItem->iItem < GETITEMCOUNT(infoPtr)))
     {
-      ZeroMemory(&dispInfo, sizeof(NMLVDISPINFOA));
+      ZeroMemory(&dispInfo, sizeof(NMLVDISPINFOW));
       hdpaSubItems = (HDPA)DPA_GetPtr(infoPtr->hdpaItems, lpLVItem->iItem);
       if (hdpaSubItems != NULL)
@@ -3574,4 +3700,7 @@
           if (lpLVItem->iSubItem == 0)
           {
+            LPSTR textA = NULL;
+            LPWSTR textW = NULL;
+
             if ((lpItem->iImage == I_IMAGECALLBACK) &&
                 (lpLVItem->mask & LVIF_IMAGE))
@@ -3580,11 +3709,20 @@
             }
 
-            if ((lpItem->pszText == LPSTR_TEXTCALLBACKA) &&
+            if ((lpItem->pszText == LPSTR_TEXTCALLBACKW) &&
                 (lpLVItem->mask & LVIF_TEXT))
             {
               dispInfo.item.mask |= LVIF_TEXT;
-              ZeroMemory(lpLVItem->pszText, sizeof(CHAR)*lpLVItem->cchTextMax);
-              dispInfo.item.pszText = lpLVItem->pszText;
               dispInfo.item.cchTextMax = lpLVItem->cchTextMax;
+              if (isUnicodeNotify(&infoPtr->header))
+              {
+                textW = (WCHAR*)COMCTL32_Alloc(dispInfo.item.cchTextMax*sizeof(WCHAR));
+                if (textW) textW[0] = 0;
+                dispInfo.item.pszText = textW;
+              } else
+              {
+                textA = (CHAR*)COMCTL32_Alloc(dispInfo.item.cchTextMax*sizeof(CHAR));
+                if (textA) textA[0] = 0;
+                dispInfo.item.pszText = (LPWSTR)textA;
+              }
             }
 
@@ -3597,11 +3735,8 @@
             if (dispInfo.item.mask != 0)
             {
-              dispInfo.hdr.hwndFrom = hwnd;
-              dispInfo.hdr.idFrom = lCtrlId;
-              dispInfo.hdr.code = LVN_GETDISPINFOA;
               dispInfo.item.iItem = lpLVItem->iItem;
               dispInfo.item.iSubItem = 0;
               dispInfo.item.lParam = lpItem->lParam;
-              ListView_Notify(GetParent(hwnd), lCtrlId, &dispInfo);
+              sendNotify(hwnd,isUnicodeNotify(&infoPtr->header) ? LVN_GETDISPINFOW:LVN_GETDISPINFOA,&dispInfo.hdr);
             }
 
@@ -3619,13 +3754,44 @@
               if (dispInfo.item.mask & LVIF_DI_SETITEM)
               {
-                Str_SetPtrA(&lpItem->pszText, dispInfo.item.pszText);
+                if (isUnicodeNotify(&infoPtr->header))
+                {
+                  Str_SetPtrW(&lpItem->pszText,dispInfo.item.pszText);
+                } else
+                {
+                  INT len = dispInfo.item.pszText ? lstrlenA((LPSTR)dispInfo.item.pszText):0;
+
+                  COMCTL32_Free(lpItem->pszText);
+                  if (len > 0)
+                  {
+                    len++;
+                    lpItem->pszText = (WCHAR*)COMCTL32_Alloc(len*sizeof(WCHAR));
+                    lstrcpyAtoW(lpItem->pszText,(LPSTR)dispInfo.item.pszText);
+                  } else lpItem->pszText = NULL;
+                }
               }
               /* Make sure the source string is valid */
               if (dispInfo.item.pszText == NULL)
-                lpLVItem->pszText[0] = '\0';
-              else
               {
-                strncpy(lpLVItem->pszText, dispInfo.item.pszText, lpLVItem->cchTextMax);
-                lpLVItem->pszText[lpLVItem->cchTextMax-1]='\0';
+                if (unicode)
+                  lpLVItem->pszText[0] = L'\0';
+                else
+                  ((LPSTR)lpLVItem->pszText)[0] = '\0';
+              } else
+              {
+                if (unicode)
+                {
+                  if (isUnicodeNotify(&infoPtr->header))
+                    lstrcpynW(lpLVItem->pszText, dispInfo.item.pszText, lpLVItem->cchTextMax);
+                  else
+                    lstrcpynAtoW(lpLVItem->pszText,(LPSTR)dispInfo.item.pszText,lpLVItem->cchTextMax);
+                  lpLVItem->pszText[lpLVItem->cchTextMax-1] = L'\0';
+                } else
+                {
+                  if (isUnicodeNotify(&infoPtr->header))
+                    lstrcpynWtoA((LPSTR)lpLVItem->pszText, dispInfo.item.pszText, lpLVItem->cchTextMax);
+                  else
+                    lstrcpynA((LPSTR)lpLVItem->pszText,(LPSTR)dispInfo.item.pszText,lpLVItem->cchTextMax);
+                  ((LPSTR)lpLVItem->pszText)[lpLVItem->cchTextMax-1] = '\0';
+                }
               }
             }
@@ -3634,12 +3800,20 @@
               if (lpItem->pszText != NULL)
               {
-                strncpy(lpLVItem->pszText, lpItem->pszText,
-                        lpLVItem->cchTextMax);
-                lpLVItem->pszText[lpLVItem->cchTextMax-1]='\0';
+                if (unicode)
+                {
+                  lstrcpynW(lpLVItem->pszText,lpItem->pszText,lpLVItem->cchTextMax);
+                  lpLVItem->pszText[lpLVItem->cchTextMax-1] = L'\0';
+                } else
+                {
+                  lstrcpynWtoA((LPSTR)lpLVItem->pszText,lpItem->pszText,lpLVItem->cchTextMax);
+                  ((LPSTR)lpLVItem->pszText)[lpLVItem->cchTextMax-1] = '\0';
+                }
               }
               else
               {
-                ZeroMemory(lpLVItem->pszText, sizeof(char)*
-                           lpLVItem->cchTextMax);
+                if (unicode)
+                  ZeroMemory(lpLVItem->pszText,sizeof(WCHAR)*lpLVItem->cchTextMax);
+                else
+                  ZeroMemory(lpLVItem->pszText,sizeof(CHAR)*lpLVItem->cchTextMax);
               }
             }
@@ -3666,7 +3840,11 @@
               lpLVItem->iIndent = lpItem->iIndent;
             }
+            if (textA) COMCTL32_Free(textA);
+            if (textW) COMCTL32_Free(textW);
           }
           else
           {
+            CHAR* textA = NULL;
+            WCHAR* textW = NULL;
             lpSubItem = LISTVIEW_GetSubItemPtr(hdpaSubItems,
                                                lpLVItem->iSubItem);
@@ -3679,12 +3857,20 @@
               }
 
-              if ((lpSubItem->pszText == LPSTR_TEXTCALLBACKA) &&
+              if ((lpSubItem->pszText == LPSTR_TEXTCALLBACKW) &&
                   (lpLVItem->mask & LVIF_TEXT))
               {
                 dispInfo.item.mask |= LVIF_TEXT;
-                ZeroMemory(lpLVItem->pszText,
-                           sizeof(CHAR)*lpLVItem->cchTextMax);
-                dispInfo.item.pszText = lpLVItem->pszText;
                 dispInfo.item.cchTextMax = lpLVItem->cchTextMax;
+                if (isUnicodeNotify(&infoPtr->header))
+                {
+                  textW = (WCHAR*)COMCTL32_Alloc(dispInfo.item.cchTextMax*sizeof(WCHAR));
+                  if (textW) textW[0] = 0;
+                  dispInfo.item.pszText = textW;
+                } else
+                {
+                  textA = (CHAR*)COMCTL32_Alloc(dispInfo.item.cchTextMax*sizeof(CHAR));
+                  if (textA) textA[0] = 0;
+                  dispInfo.item.pszText = (LPWSTR)textA;
+                }
               }
             }
@@ -3699,8 +3885,16 @@
               {
                 dispInfo.item.mask |= LVIF_TEXT;
-                ZeroMemory(lpLVItem->pszText,
-                           sizeof(CHAR)*lpLVItem->cchTextMax);
-                dispInfo.item.pszText = lpLVItem->pszText;
                 dispInfo.item.cchTextMax = lpLVItem->cchTextMax;
+                if (isUnicodeNotify(&infoPtr->header))
+                {
+                  textW = (WCHAR*)COMCTL32_Alloc(dispInfo.item.cchTextMax*sizeof(WCHAR));
+                  if (textW) textW[0] = 0;
+                  dispInfo.item.pszText = textW;
+                } else
+                {
+                  textA = (CHAR*)COMCTL32_Alloc(dispInfo.item.cchTextMax*sizeof(CHAR));
+                  if (textA) textA[0] = 0;
+                  dispInfo.item.pszText = (LPWSTR)textA;
+                }
               }
             }
@@ -3708,11 +3902,8 @@
             if (dispInfo.item.mask != 0)
             {
-              dispInfo.hdr.hwndFrom = hwnd;
-              dispInfo.hdr.idFrom = lCtrlId;
-              dispInfo.hdr.code = LVN_GETDISPINFOA;
               dispInfo.item.iItem = lpLVItem->iItem;
               dispInfo.item.iSubItem = lpLVItem->iSubItem;
               dispInfo.item.lParam = lpItem->lParam;
-              ListView_Notify(GetParent(hwnd), lCtrlId, &dispInfo);
+              sendNotify(hwnd,isUnicodeNotify(&infoPtr->header) ? LVN_GETDISPINFOW:LVN_GETDISPINFOW,&dispInfo.hdr);
             }
 
@@ -3740,27 +3931,69 @@
               {
                 if (lpSubItem)
-                  Str_SetPtrA(&lpSubItem->pszText, dispInfo.item.pszText);
+                {
+                  if (isUnicodeNotify(&infoPtr->header))
+                  {
+                    Str_SetPtrW(&lpSubItem->pszText,dispInfo.item.pszText);
+                  } else
+                  {
+                    INT len = dispInfo.item.pszText ? lstrlenA((LPSTR)dispInfo.item.pszText):0;
+
+                    COMCTL32_Free(lpSubItem->pszText);
+                    if (len > 0)
+                    {
+                      len++;
+                      lpSubItem->pszText = (WCHAR*)COMCTL32_Alloc(len*sizeof(WCHAR));
+                      lstrcpyAtoW(lpSubItem->pszText,(LPSTR)dispInfo.item.pszText);
+                    } else lpSubItem->pszText = NULL;
+                  }
+                }
               }
               /* Make sure the source string is valid */
+
               if (dispInfo.item.pszText == NULL)
-                lpLVItem->pszText[0] = '\0';
-              else
               {
-                strncpy(lpLVItem->pszText, dispInfo.item.pszText, lpLVItem->cchTextMax);
-                lpLVItem->pszText[lpLVItem->cchTextMax-1]='\0';
+                if (unicode)
+                  lpLVItem->pszText[0] = L'\0';
+                else
+                  ((LPSTR)lpLVItem->pszText)[0] = '\0';
+              } else
+              {
+                if (unicode)
+                {
+                  if (isUnicodeNotify(&infoPtr->header))
+                    lstrcpynW(lpLVItem->pszText, dispInfo.item.pszText, lpLVItem->cchTextMax);
+                  else
+                    lstrcpynAtoW(lpLVItem->pszText,(LPSTR)dispInfo.item.pszText,lpLVItem->cchTextMax);
+                  lpLVItem->pszText[lpLVItem->cchTextMax-1] = L'\0';
+                } else
+                {
+                  if (isUnicodeNotify(&infoPtr->header))
+                    lstrcpynWtoA((LPSTR)lpLVItem->pszText, dispInfo.item.pszText, lpLVItem->cchTextMax);
+                  else
+                    lstrcpynA((LPSTR)lpLVItem->pszText,(LPSTR)dispInfo.item.pszText,lpLVItem->cchTextMax);
+                  ((LPSTR)lpLVItem->pszText)[lpLVItem->cchTextMax-1] = '\0';
+                }
               }
             }
             else if (lpLVItem->mask & LVIF_TEXT)
             {
-              if (lpItem->pszText != NULL)
+              if (lpSubItem->pszText != NULL)
               {
-                strncpy(lpLVItem->pszText, lpSubItem->pszText,
-                        lpLVItem->cchTextMax);
-                lpLVItem->pszText[lpLVItem->cchTextMax-1]='\0';
+                if (unicode)
+                {
+                  lstrcpynW(lpLVItem->pszText,lpSubItem->pszText,lpLVItem->cchTextMax);
+                  lpLVItem->pszText[lpLVItem->cchTextMax-1] = L'\0';
+                } else
+                {
+                  lstrcpynWtoA((LPSTR)lpLVItem->pszText,lpSubItem->pszText,lpLVItem->cchTextMax);
+                  ((LPSTR)lpLVItem->pszText)[lpLVItem->cchTextMax-1] = '\0';
+                }
               }
               else
               {
-                ZeroMemory(lpLVItem->pszText, sizeof(char)*
-                           lpLVItem->cchTextMax);
+                if (unicode)
+                  ZeroMemory(lpLVItem->pszText,sizeof(WCHAR)*lpLVItem->cchTextMax);
+                else
+                  ZeroMemory(lpLVItem->pszText,sizeof(CHAR)*lpLVItem->cchTextMax);
               }
             }
@@ -3774,5 +4007,4 @@
 }
 
-/* LISTVIEW_GetItemW */
 /* LISTVIEW_GetHotCursor */
 
@@ -3792,5 +4024,5 @@
     LISTVIEW_INFO *infoPtr;
     /* make sure we can get the listview info */
-    if (!(infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0)))
+    if (!(infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd)))
         return (-1);
     return (infoPtr->nHotItem);
@@ -3811,5 +4043,5 @@
 static LRESULT LISTVIEW_GetItemCount(HWND hwnd)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
 
   return GETITEMCOUNT(infoPtr);
@@ -3832,5 +4064,5 @@
                                      LPPOINT lpptPosition)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
   UINT uView = GetWindowLongA(hwnd, GWL_STYLE) & LVS_TYPEMASK;
   BOOL bResult = FALSE;
@@ -3912,5 +4144,5 @@
 static LRESULT LISTVIEW_GetItemRect(HWND hwnd, INT nItem, LPRECT lprc)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
   UINT uView = GetWindowLongA(hwnd, GWL_STYLE) & LVS_TYPEMASK;
   BOOL bResult = FALSE;
@@ -4237,18 +4469,18 @@
 INT LISTVIEW_GetLabelWidth(HWND hwnd, INT nItem)
 {
-  CHAR szDispText[DISP_TEXT_SIZE];
+  WCHAR szDispText[DISP_TEXT_SIZE];
   INT nLabelWidth = 0;
-  LVITEMA lvItem;
+  LVITEMW lvItem;
 
 //  TRACE("(hwnd=%x, nItem=%d)\n", hwnd, nItem);
 
-  ZeroMemory(&lvItem, sizeof(LVITEMA));
+  ZeroMemory(&lvItem, sizeof(LVITEMW));
   lvItem.mask = LVIF_TEXT;
   lvItem.iItem = nItem;
   lvItem.cchTextMax = DISP_TEXT_SIZE;
   lvItem.pszText = szDispText;
-  if (LISTVIEW_GetItemA(hwnd, &lvItem) != FALSE)
-  {
-    nLabelWidth = ListView_GetStringWidthA(hwnd, lvItem.pszText);
+  if (LISTVIEW_GetItem(hwnd,&lvItem,TRUE) != FALSE)
+  {
+    nLabelWidth = ListView_GetStringWidthW(hwnd,lvItem.pszText);
   }
 
@@ -4269,5 +4501,5 @@
 LRESULT LISTVIEW_GetItemSpacing(HWND hwnd, BOOL bSmall)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
   LONG lResult;
 
@@ -4299,15 +4531,15 @@
 LRESULT LISTVIEW_GetItemState(HWND hwnd, INT nItem, UINT uMask)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
-  LVITEMA lvItem;
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
+  LVITEMW lvItem;
   UINT uState = 0;
 
   if ((nItem >= 0) && (nItem < GETITEMCOUNT(infoPtr)))
   {
-    ZeroMemory(&lvItem, sizeof(LVITEMA));
+    ZeroMemory(&lvItem, sizeof(LVITEMW));
     lvItem.iItem = nItem;
     lvItem.stateMask = uMask;
     lvItem.mask = LVIF_STATE;
-    if (LISTVIEW_GetItemA(hwnd, &lvItem) != FALSE)
+    if (LISTVIEW_GetItem(hwnd,&lvItem,TRUE) != FALSE)
     {
       uState = lvItem.state;
@@ -4325,5 +4557,5 @@
  * [I] HWND : window handle
  * [I] INT : item index
- * [IO] LPLVITEMA : item information
+ * [IO] LPLVITEMW : item information
  *
  * RETURN:
@@ -4331,7 +4563,7 @@
  *   FAILURE : 0
  */
-LRESULT LISTVIEW_GetItemTextA(HWND hwnd, INT nItem, LPLVITEMA lpLVItem)
-{
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+LRESULT LISTVIEW_GetItemText(HWND hwnd,INT nItem,LPLVITEMW lpLVItem,BOOL unicode)
+{
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
   INT nLength = 0;
 
@@ -4342,7 +4574,7 @@
       lpLVItem->mask = LVIF_TEXT;
       lpLVItem->iItem = nItem;
-      if (LISTVIEW_GetItemA(hwnd, lpLVItem) != FALSE)
-      {
-        nLength = lstrlenA(lpLVItem->pszText);
+      if (LISTVIEW_GetItem(hwnd,lpLVItem,unicode) != FALSE)
+      {
+        nLength = unicode ? lstrlenW(lpLVItem->pszText):lstrlenA((LPSTR)lpLVItem->pszText);
       }
     }
@@ -4367,8 +4599,8 @@
 static LRESULT LISTVIEW_GetNextItem(HWND hwnd, INT nItem, UINT uFlags)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
   UINT uView = GetWindowLongA(hwnd, GWL_STYLE) & LVS_TYPEMASK;
   UINT uMask = 0;
-  LVFINDINFO lvFindInfo;
+  LVFINDINFOW lvFindInfo;
   INT nCountPerColumn;
   INT i;
@@ -4376,5 +4608,5 @@
   if ((nItem >= -1) && (nItem < GETITEMCOUNT(infoPtr)))
   {
-    ZeroMemory(&lvFindInfo, sizeof(LVFINDINFO));
+    ZeroMemory(&lvFindInfo, sizeof(LVFINDINFOW));
 
     if (uFlags & LVNI_CUT)
@@ -4406,5 +4638,5 @@
         lvFindInfo.vkDirection = VK_UP;
         ListView_GetItemPosition(hwnd, nItem, &lvFindInfo.pt);
-        while ((nItem = ListView_FindItem(hwnd, nItem, &lvFindInfo)) != -1)
+        while ((nItem = ListView_FindItemW(hwnd, nItem, &lvFindInfo)) != -1)
         {
           if ((ListView_GetItemState(hwnd, nItem, uMask) & uMask) == uMask)
@@ -4429,5 +4661,5 @@
         lvFindInfo.vkDirection = VK_DOWN;
         ListView_GetItemPosition(hwnd, nItem, &lvFindInfo.pt);
-        while ((nItem = ListView_FindItem(hwnd, nItem, &lvFindInfo)) != -1)
+        while ((nItem = ListView_FindItemW(hwnd, nItem, &lvFindInfo)) != -1)
         {
           if ((ListView_GetItemState(hwnd, nItem, uMask) & uMask) == uMask)
@@ -4453,5 +4685,5 @@
         lvFindInfo.vkDirection = VK_LEFT;
         ListView_GetItemPosition(hwnd, nItem, &lvFindInfo.pt);
-        while ((nItem = ListView_FindItem(hwnd, nItem, &lvFindInfo)) != -1)
+        while ((nItem = ListView_FindItemW(hwnd, nItem, &lvFindInfo)) != -1)
         {
           if ((ListView_GetItemState(hwnd, nItem, uMask) & uMask) == uMask)
@@ -4477,5 +4709,5 @@
         lvFindInfo.vkDirection = VK_RIGHT;
         ListView_GetItemPosition(hwnd, nItem, &lvFindInfo.pt);
-        while ((nItem = ListView_FindItem(hwnd, nItem, &lvFindInfo)) != -1)
+        while ((nItem = ListView_FindItemW(hwnd, nItem, &lvFindInfo)) != -1)
         {
           if ((ListView_GetItemState(hwnd, nItem, uMask) & uMask) == uMask)
@@ -4565,5 +4797,5 @@
 static LRESULT LISTVIEW_GetSelectedCount(HWND hwnd)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
   INT nSelectedCount = 0;
   INT i;
@@ -4592,5 +4824,5 @@
 static LRESULT LISTVIEW_GetSelectionMark(HWND hwnd)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
 
   return infoPtr->nSelectionMark;
@@ -4608,7 +4840,7 @@
  *   FAILURE : zero
  */
-static LRESULT LISTVIEW_GetStringWidthA(HWND hwnd, LPCSTR lpszText)
-{
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+static LRESULT LISTVIEW_GetStringWidth(HWND hwnd,LPWSTR lpszText,BOOL unicode)
+{
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
   HFONT hFont, hOldFont;
   SIZE stringSize;
@@ -4621,5 +4853,8 @@
     hdc = GetDC(hwnd);
     hOldFont = SelectObject(hdc, hFont);
-    GetTextExtentPointA(hdc, lpszText, lstrlenA(lpszText), &stringSize);
+    if (unicode)
+      GetTextExtentPointW(hdc,lpszText,lstrlenW(lpszText),&stringSize);
+    else
+      GetTextExtentPointA(hdc,(LPSTR)lpszText,lstrlenA((LPSTR)lpszText),&stringSize);
     SelectObject(hdc, hOldFont);
     ReleaseDC(hwnd, hdc);
@@ -4641,5 +4876,5 @@
 static LRESULT LISTVIEW_GetTextBkColor(HWND hwnd)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO*)GetWindowLongA(hwnd, 0);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO*)LISTVIEW_GetInfoPtr(hwnd);
 
   return infoPtr->clrTextBk;
@@ -4658,5 +4893,5 @@
 static LRESULT LISTVIEW_GetTextColor(HWND hwnd)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO*)GetWindowLongA(hwnd, 0);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO*)LISTVIEW_GetInfoPtr(hwnd);
 
   return infoPtr->clrText;
@@ -4677,5 +4912,5 @@
 static INT LISTVIEW_HitTestItem(HWND hwnd, LPLVHITTESTINFO lpHitTestInfo)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
   RECT rcItem;
   INT i;
@@ -4742,5 +4977,5 @@
 static LRESULT LISTVIEW_HitTest(HWND hwnd, LPLVHITTESTINFO lpHitTestInfo)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
   INT nItem = -1;
 
@@ -4785,9 +5020,8 @@
  *   FAILURE : -1
  */
-static LRESULT LISTVIEW_InsertColumnA(HWND hwnd, INT nColumn,
-                                      LPLVCOLUMNA lpColumn)
-{
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
-  HDITEMA hdi;
+static LRESULT LISTVIEW_InsertColumn(HWND hwnd,INT nColumn,LPLVCOLUMNW lpColumn,BOOL unicode)
+{
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
+  HDITEMW hdi;
   INT nNewColumn = -1;
 
@@ -4798,5 +5032,5 @@
   {
     /* initialize memory */
-    ZeroMemory(&hdi, sizeof(HDITEMA));
+    ZeroMemory(&hdi, sizeof(HDITEMW));
 
     if (lpColumn->mask & LVCF_FMT)
@@ -4854,5 +5088,5 @@
       hdi.mask |= HDI_TEXT | HDI_FORMAT;
       hdi.pszText = lpColumn->pszText;
-      hdi.cchTextMax = lstrlenA(lpColumn->pszText);
+      hdi.cchTextMax = unicode ? lstrlenW(lpColumn->pszText):lstrlenA((LPSTR)lpColumn->pszText);
       hdi.fmt |= HDF_STRING;
     }
@@ -4871,6 +5105,8 @@
 
     /* insert item in header control */
-    nNewColumn = SendMessageA(infoPtr->hwndHeader, HDM_INSERTITEMA,
-                             (WPARAM)nColumn, (LPARAM)&hdi);
+    if (unicode)
+      nNewColumn = SendMessageA(infoPtr->hwndHeader,HDM_INSERTITEMW,(WPARAM)nColumn,(LPARAM)&hdi);
+    else
+      nNewColumn = SendMessageA(infoPtr->hwndHeader,HDM_INSERTITEMA,(WPARAM)nColumn,(LPARAM)&hdi);
 
     /* Need to reset the item width when inserting a new column */
@@ -4882,19 +5118,4 @@
 
   return nNewColumn;
-}
-
-static LRESULT LISTVIEW_InsertColumnW(HWND hwnd, INT nColumn,
-                                      LPLVCOLUMNW lpColumn)
-{
-  LVCOLUMNA     lvca;
-  LRESULT               lres;
-
-  memcpy(&lvca,lpColumn,sizeof(lvca));
-  if (lpColumn->mask & LVCF_TEXT)
-    lvca.pszText = HEAP_strdupWtoA(GetProcessHeap(),0,lpColumn->pszText);
-  lres = LISTVIEW_InsertColumnA(hwnd,nColumn,&lvca);
-  if (lpColumn->mask & LVCF_TEXT)
-    HeapFree(GetProcessHeap(),0,lvca.pszText);
-  return lres;
 }
 
@@ -4922,5 +5143,5 @@
   LISTVIEW_ITEM* lv_second = (LISTVIEW_ITEM*) DPA_GetPtr( hdpa_second, 0 );
   LONG lStyle = GetWindowLongA((HWND) lParam, GWL_STYLE);
-  INT  cmpv = lstrcmpA( lv_first->pszText, lv_second->pszText );
+  INT  cmpv = lstrcmpW( lv_first->pszText, lv_second->pszText );
   /* if we're sorting descending, negate the return value */
   return (lStyle & LVS_SORTDESCENDING) ? -cmpv : cmpv;
@@ -4933,5 +5154,5 @@
  * PARAMETER(S):
  * [I] HWND : window handle
- * [I] LPLVITEMA : item information
+ * [I] LPLVITEMW : item information
  *
  * RETURN:
@@ -4939,7 +5160,7 @@
  *   FAILURE : -1
  */
-static LRESULT LISTVIEW_InsertItemA(HWND hwnd, LPLVITEMA lpLVItem)
-{
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+static LRESULT LISTVIEW_InsertItem(HWND hwnd, LPLVITEMW lpLVItem,BOOL unicode)
+{
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
   LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE);
   UINT uView = lStyle & LVS_TYPEMASK;
@@ -4962,5 +5183,5 @@
       {
         ZeroMemory(lpItem, sizeof(LISTVIEW_ITEM));
-        if (LISTVIEW_InitItem(hwnd, lpItem, lpLVItem) != FALSE)
+        if (LISTVIEW_InitItem(hwnd, lpItem, lpLVItem,unicode) != FALSE)
         {
           /* insert item in listview control data structure */
@@ -4973,5 +5194,5 @@
               if ( ((lStyle & LVS_SORTASCENDING) || (lStyle & LVS_SORTDESCENDING))
                       && !(lStyle & LVS_OWNERDRAWFIXED)
-                      && (LPSTR_TEXTCALLBACKA != lpLVItem->pszText) )
+                      && (LPSTR_TEXTCALLBACKW != lpLVItem->pszText) )
               {
                 /* Insert the item in the proper sort order based on the pszText
@@ -5001,10 +5222,7 @@
                 /* send LVN_INSERTITEM notification */
                 ZeroMemory(&nmlv, sizeof(NMLISTVIEW));
-                nmlv.hdr.hwndFrom = hwnd;
-                nmlv.hdr.idFrom = lCtrlId;
-                nmlv.hdr.code = LVN_INSERTITEM;
                 nmlv.iItem = nItem;
                 nmlv.lParam = lpItem->lParam;;
-                ListView_LVNotify(GetParent(hwnd), lCtrlId, &nmlv);
+                sendNotify(hwnd,LVN_INSERTITEM,&nmlv.hdr);
 
                 if ((uView == LVS_SMALLICON) || (uView == LVS_LIST))
@@ -5050,23 +5268,4 @@
 }
 
-static LRESULT LISTVIEW_InsertItemW(HWND hwnd, LPLVITEMW lpLVItem) {
-  LVITEMA lvia;
-  LRESULT lres;
-
-  memcpy(&lvia,lpLVItem,sizeof(LVITEMA));
-  if (lvia.mask & LVIF_TEXT) {
-    if (lpLVItem->pszText == LPSTR_TEXTCALLBACKW)
-      lvia.pszText = LPSTR_TEXTCALLBACKA;
-    else
-      lvia.pszText = HEAP_strdupWtoA(GetProcessHeap(),0,lpLVItem->pszText);
-  }
-  lres = LISTVIEW_InsertItemA(hwnd, &lvia);
-  if (lvia.mask & LVIF_TEXT) {
-    if (lpLVItem->pszText != LPSTR_TEXTCALLBACKW)
-      HeapFree(GetProcessHeap(),0,lvia.pszText);
-  }
-  return lres;
-}
-
 /***
  * DESCRIPTION:
@@ -5084,5 +5283,5 @@
 static LRESULT LISTVIEW_RedrawItems(HWND hwnd, INT nFirst, INT nLast)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
   BOOL bResult = FALSE;
   RECT rc;
@@ -5119,5 +5318,5 @@
 static LRESULT LISTVIEW_SetBkColor(HWND hwnd, COLORREF clrBk)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
 
   infoPtr->clrBk = clrBk;
@@ -5144,5 +5343,5 @@
 static BOOL LISTVIEW_SetCallbackMask(HWND hwnd, UINT uMask)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
 
   infoPtr->uCallbackMask = uMask;
@@ -5164,10 +5363,9 @@
  *   FAILURE : FALSE
  */
-static LRESULT LISTVIEW_SetColumnA(HWND hwnd, INT nColumn,
-                                   LPLVCOLUMNA lpColumn)
-{
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+static LRESULT LISTVIEW_SetColumn(HWND hwnd,INT nColumn,LPLVCOLUMNW lpColumn,BOOL unicode)
+{
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
   BOOL bResult = FALSE;
-  HDITEMA hdi, hdiget;
+  HDITEMW hdi, hdiget;
 
   if ((lpColumn != NULL) && (nColumn >= 0) &&
@@ -5184,5 +5382,5 @@
       /* get current format first */
       hdiget.mask = HDI_FORMAT;
-      if (Header_GetItemA(infoPtr->hwndHeader, nColumn, &hdiget))
+      if (Header_GetItemW(infoPtr->hwndHeader, nColumn, &hdiget))
               /* preserve HDF_STRING if present */
               hdi.fmt = hdiget.fmt & HDF_STRING;
@@ -5236,5 +5434,5 @@
       hdi.mask |= HDI_TEXT | HDI_FORMAT;
       hdi.pszText = lpColumn->pszText;
-      hdi.cchTextMax = lstrlenA(lpColumn->pszText);
+      hdi.cchTextMax = unicode ? lstrlenW(lpColumn->pszText):lstrlenA((LPSTR)lpColumn->pszText);
       hdi.fmt |= HDF_STRING;
     }
@@ -5253,5 +5451,8 @@
 
     /* set header item attributes */
-    bResult = Header_SetItemA(infoPtr->hwndHeader, nColumn, &hdi);
+    if (unicode)
+      bResult = Header_SetItemW(infoPtr->hwndHeader,nColumn,&hdi);
+    else
+      bResult = Header_SetItemA(infoPtr->hwndHeader,nColumn,(HDITEMA*)&hdi);
   }
 
@@ -5276,5 +5477,5 @@
 static LRESULT LISTVIEW_SetColumnOrderArray(HWND hwnd, INT iCount, LPINT lpiArray)
 {
-/*  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); */
+/*  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd); */
 
 //    FIXME("iCount %d lpiArray %p\n", iCount, lpiArray);
@@ -5312,5 +5513,5 @@
 
     // make sure we can get the listview info
-    if (!(infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0)))
+    if (!(infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd)))
         return (FALSE);
     if (!infoPtr->hwndHeader) // make sure we have a header
@@ -5326,5 +5527,5 @@
 
     // call header to update the column change
-    lret = Header_SetItemA(infoPtr->hwndHeader, (WPARAM)iCol, (LPARAM)&hdi);
+    lret = Header_SetItemW(infoPtr->hwndHeader, (WPARAM)iCol, (LPARAM)&hdi);
 
     infoPtr->nItemWidth = LISTVIEW_GetItemWidth(hwnd);
@@ -5353,5 +5554,5 @@
     DWORD dwOldStyle;
     /* make sure we can get the listview info */
-    if (!(infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0)))
+    if (!(infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd)))
         return (0);
     /* store previous style */
@@ -5381,5 +5582,5 @@
     INT iOldIndex;
     /* make sure we can get the listview info */
-    if (!(infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0)))
+    if (!(infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd)))
         return (-1);
     /* store previous index */
@@ -5407,5 +5608,5 @@
 static LRESULT LISTVIEW_SetImageList(HWND hwnd, INT nType, HIMAGELIST himl)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
   HIMAGELIST himlTemp = 0;
 
@@ -5445,7 +5646,7 @@
  *   FAILURE : FALSE
  */
-static LRESULT LISTVIEW_SetItemA(HWND hwnd, LPLVITEMA lpLVItem)
-{
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+static LRESULT LISTVIEW_SetItemHandler(HWND hwnd,LPLVITEMW lpLVItem,BOOL unicode)
+{
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
   BOOL bResult = FALSE;
 
@@ -5456,9 +5657,9 @@
       if (lpLVItem->iSubItem == 0)
       {
-        bResult = LISTVIEW_SetItem(hwnd, lpLVItem);
+        bResult = LISTVIEW_SetItem(hwnd,lpLVItem,unicode);
       }
       else
       {
-        bResult = LISTVIEW_SetSubItem(hwnd, lpLVItem);
+        bResult = LISTVIEW_SetSubItem(hwnd,lpLVItem,unicode);
       }
     }
@@ -5468,6 +5669,4 @@
   return bResult;
 }
-
-/* LISTVIEW_SetItemW  */
 
 /***
@@ -5486,5 +5685,5 @@
 static BOOL LISTVIEW_SetItemCount(HWND hwnd, INT nItems, DWORD dwFlags)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO*)GetWindowLongA(hwnd, 0);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO*)LISTVIEW_GetInfoPtr(hwnd);
 
 //  FIXME("(%d %08lx)empty stub!\n", nItems, dwFlags);
@@ -5533,5 +5732,5 @@
                                      INT nPosX, INT nPosY)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO*)GetWindowLongA(hwnd, 0);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO*)LISTVIEW_GetInfoPtr(hwnd);
   UINT uView = GetWindowLongA(hwnd, GWL_STYLE) & LVS_TYPEMASK;
   LISTVIEW_ITEM *lpItem;
@@ -5577,9 +5776,9 @@
  *   FAILURE : FALSE
  */
-static LRESULT LISTVIEW_SetItemState(HWND hwnd, INT nItem, LPLVITEMA lpLVItem)
-{
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+static LRESULT LISTVIEW_SetItemState(HWND hwnd, INT nItem, LPLVITEMW lpLVItem)
+{
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
   BOOL bResult = FALSE;
-  LVITEMA lvItem;
+  LVITEMW lvItem;
   INT i;
 
@@ -5587,5 +5786,5 @@
   {
     bResult = TRUE;
-    ZeroMemory(&lvItem, sizeof(LVITEMA));
+    ZeroMemory(&lvItem, sizeof(LVITEMW));
     lvItem.mask = LVIF_STATE;
     lvItem.state = lpLVItem->state;
@@ -5596,5 +5795,5 @@
     {
       lvItem.iItem = i;
-      if (ListView_SetItemA(hwnd, &lvItem) == FALSE)
+      if (ListView_SetItemW(hwnd,&lvItem) == FALSE)
       {
         bResult = FALSE;
@@ -5604,10 +5803,10 @@
   else
   {
-    ZeroMemory(&lvItem, sizeof(LVITEMA));
+    ZeroMemory(&lvItem, sizeof(LVITEMW));
     lvItem.mask = LVIF_STATE;
     lvItem.state = lpLVItem->state;
     lvItem.stateMask = lpLVItem->stateMask;
     lvItem.iItem = nItem;
-    bResult = ListView_SetItemA(hwnd, &lvItem);
+    bResult = ListView_SetItemW(hwnd, &lvItem);
   }
 
@@ -5622,5 +5821,5 @@
  * [I] HWND : window handle
  * [I] INT : item index
- * [I] LPLVITEMA : item or subitem info
+ * [I] LPLVITEMW : item or subitem info
  *
  * RETURN:
@@ -5628,18 +5827,21 @@
  *   FAILURE : FALSE
  */
-static BOOL LISTVIEW_SetItemTextA(HWND hwnd, INT nItem, LPLVITEMA lpLVItem)
-{
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+static BOOL LISTVIEW_SetItemText(HWND hwnd, INT nItem, LPLVITEMW lpLVItem,BOOL unicode)
+{
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
   BOOL bResult = FALSE;
-  LVITEMA lvItem;
+  LVITEMW lvItem;
 
   if ((nItem >= 0) && (nItem < GETITEMCOUNT(infoPtr)))
   {
-    ZeroMemory(&lvItem, sizeof(LVITEMA));
+    ZeroMemory(&lvItem, sizeof(LVITEMW));
     lvItem.mask = LVIF_TEXT;
     lvItem.pszText = lpLVItem->pszText;
     lvItem.iItem = nItem;
     lvItem.iSubItem = lpLVItem->iSubItem;
-    bResult = ListView_SetItemA(hwnd, &lvItem);
+    if (unicode)
+      bResult = ListView_SetItemW(hwnd,&lvItem);
+    else
+      bResult = ListView_SetItemA(hwnd,&lvItem);
   }
 
@@ -5647,6 +5849,4 @@
 }
 
-/* LISTVIEW_SetItemTextW */
-
 /***
  * DESCRIPTION:
@@ -5662,5 +5862,5 @@
 static LRESULT LISTVIEW_SetSelectionMark(HWND hwnd, INT nIndex)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
   INT nOldIndex = infoPtr->nSelectionMark;
   infoPtr->nSelectionMark = nIndex;
@@ -5682,5 +5882,5 @@
 static LRESULT LISTVIEW_SetTextBkColor(HWND hwnd, COLORREF clrTextBk)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
 
   infoPtr->clrTextBk = clrTextBk;
@@ -5704,5 +5904,5 @@
 static LRESULT LISTVIEW_SetTextColor (HWND hwnd, COLORREF clrText)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
 
   infoPtr->clrText = clrText;
@@ -5738,5 +5938,5 @@
   INT rv;
   HWND hwnd = (HWND)lParam;
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
 
   rv = (infoPtr->pfnCompare)( ((LISTVIEW_ITEM*) first)->lParam,
@@ -5761,5 +5961,5 @@
 static LRESULT LISTVIEW_SortItems(HWND hwnd, WPARAM wParam, LPARAM lParam)
 {
-    LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+    LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
     HDPA hdpaSubItems;
     LISTVIEW_ITEM *lpItem;
@@ -5828,5 +6028,5 @@
 static LRESULT LISTVIEW_Update(HWND hwnd, INT nItem)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
   LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE);
   BOOL bResult = FALSE;
@@ -5846,6 +6046,5 @@
     {
       /* get item bounding rectangle */
-      rc.left = LVIR_BOUNDS;
-      ListView_GetItemRect(hwnd, nItem, &rc);
+      ListView_GetItemRect(hwnd,nItem,&rc,LVIR_BOUNDS);
       InvalidateRect(hwnd, &rc, TRUE);
     }
@@ -5867,20 +6066,9 @@
 static LRESULT LISTVIEW_Create(HWND hwnd, WPARAM wParam, LPARAM lParam)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
   LPCREATESTRUCTA lpcs = (LPCREATESTRUCTA)lParam;
   UINT uView = lpcs->style & LVS_TYPEMASK;
   LOGFONTA logFont;
   DWORD headerStyle = WS_CHILD | HDS_HORZ;
-
-  /* initialize info pointer */
-  ZeroMemory(infoPtr, sizeof(LISTVIEW_INFO));
-
-  /* determine the type of structures to use */
-  infoPtr->notifyFormat = SendMessageA(GetParent(hwnd), WM_NOTIFYFORMAT,
-                                       (WPARAM)hwnd, (LPARAM)NF_QUERY);
-  if (infoPtr->notifyFormat != NFR_ANSI)
-  {
-    //FIXME("ANSI notify format is NOT used\n");
-  }
 
   /* initialize color information  */
@@ -5967,5 +6155,5 @@
                                         LPARAM lParam)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
   BOOL bResult;
 
@@ -5999,5 +6187,5 @@
 static LRESULT LISTVIEW_GetFont(HWND hwnd)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
 
   return infoPtr->hFont;
@@ -6258,9 +6446,6 @@
 static LRESULT LISTVIEW_KeyDown(HWND hwnd, INT nVirtualKey, LONG lKeyData)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
-  INT nCtrlId = GetWindowLongA(hwnd, GWL_ID);
-  HWND hwndParent = GetParent(hwnd);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
   NMLVKEYDOWN nmKeyDown;
-  NMHDR nmh;
   INT nItem = -1;
   BOOL bRedraw = FALSE;
@@ -6268,14 +6453,7 @@
   /* send LVN_KEYDOWN notification */
   ZeroMemory(&nmKeyDown, sizeof(NMLVKEYDOWN));
-  nmKeyDown.hdr.hwndFrom = hwnd;
-  nmKeyDown.hdr.idFrom = nCtrlId;
-  nmKeyDown.hdr.code = LVN_KEYDOWN;
   nmKeyDown.wVKey = nVirtualKey;
   nmKeyDown.flags = 0;
-  SendMessageA(hwndParent, WM_NOTIFY, (WPARAM)nCtrlId, (LPARAM)&nmKeyDown);
-
-  /* initialize */
-  nmh.hwndFrom = hwnd;
-  nmh.idFrom = nCtrlId;
+  sendNotify(hwnd,LVN_KEYDOWN,&nmKeyDown.hdr);
 
   switch (nVirtualKey)
@@ -6285,10 +6463,8 @@
     {
       /* send NM_RETURN notification */
-      nmh.code = NM_RETURN;
-      ListView_Notify(hwndParent, nCtrlId, &nmh);
+      sendNotify(hwnd,NM_RETURN);
 
       /* send LVN_ITEMACTIVATE notification */
-      nmh.code = LVN_ITEMACTIVATE;
-      ListView_Notify(hwndParent, nCtrlId, &nmh);
+      sendNotify(hwnd,LVN_ITEMACTIVATE);
     }
     break;
@@ -6359,13 +6535,8 @@
 static LRESULT LISTVIEW_KillFocus(HWND hwnd)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO*)GetWindowLongA(hwnd, 0);
-  INT nCtrlId = GetWindowLongA(hwnd, GWL_ID);
-  NMHDR nmh;
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO*)LISTVIEW_GetInfoPtr(hwnd);
 
   /* send NM_KILLFOCUS notification */
-  nmh.hwndFrom = hwnd;
-  nmh.idFrom = nCtrlId;
-  nmh.code = NM_KILLFOCUS;
-  ListView_Notify(GetParent(hwnd), nCtrlId, &nmh);
+  sendNotify(hwnd,NM_KILLFOCUS);
 
   /* set window focus flag */
@@ -6394,6 +6565,4 @@
                                       WORD wPosY)
 {
-  LONG nCtrlId = GetWindowLongA(hwnd, GWL_ID);
-  NMHDR nmh;
   LVHITTESTINFO htInfo;
 
@@ -6401,8 +6570,5 @@
 
   /* send NM_DBLCLK notification */
-  nmh.hwndFrom = hwnd;
-  nmh.idFrom = nCtrlId;
-  nmh.code = NM_DBLCLK;
-  ListView_Notify(GetParent(hwnd), nCtrlId, &nmh);
+  sendNotify(hwnd,NM_DBLCLK);
 
   /* To send the LVN_ITEMACTIVATE, it must be on an Item */
@@ -6413,6 +6579,5 @@
   {
     /* send LVN_ITEMACTIVATE notification */
-    nmh.code = LVN_ITEMACTIVATE;
-    ListView_Notify(GetParent(hwnd), nCtrlId, &nmh);
+    sendNotify(hwnd,LVN_ITEMACTIVATE);
   }
 
@@ -6436,10 +6601,8 @@
                                     WORD wPosY)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
   LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE);
-  INT nCtrlId = GetWindowLongA(hwnd, GWL_ID);
   static BOOL bGroupSelect = TRUE;
   POINT ptPosition;
-  NMHDR nmh;
   INT nItem;
 
@@ -6448,8 +6611,5 @@
 
   /* send NM_RELEASEDCAPTURE notification */
-  nmh.hwndFrom = hwnd;
-  nmh.idFrom = nCtrlId;
-  nmh.code = NM_RELEASEDCAPTURE;
-  ListView_Notify(GetParent(hwnd), nCtrlId, &nmh);
+  sendNotify(hwnd,NM_RELEASEDCAPTURE);
 
   if (infoPtr->bFocus == FALSE)
@@ -6540,5 +6700,5 @@
                                   WORD wPosY)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
 
 //  TRACE("(hwnd=%x,key=%hu,X=%hu,Y=%hu)\n", hwnd, wKey, wPosX, wPosY);
@@ -6546,12 +6706,6 @@
   if (infoPtr->bLButtonDown != FALSE)
   {
-    INT nCtrlId = GetWindowLongA(hwnd, GWL_ID);
-    NMHDR nmh;
-
     /* send NM_CLICK notification */
-    nmh.hwndFrom = hwnd;
-    nmh.idFrom = nCtrlId;
-    nmh.code = NM_CLICK;
-    ListView_Notify(GetParent(hwnd), nCtrlId, &nmh);
+    sendNotify(hwnd,NM_CLICK);
 
     /* set left button flag */
@@ -6568,5 +6722,5 @@
       if(nItem != -1 && htInfo.flags == LVHT_ONITEMLABEL)
       {
-        LISTVIEW_EditLabelA(hwnd, nItem);
+        LISTVIEW_EditLabel(hwnd,nItem,TRUE);
       }
       infoPtr->bDoEditLabel = FALSE;
@@ -6596,17 +6750,6 @@
 
   /* allocate memory for info structure */
-  infoPtr = (LISTVIEW_INFO *)COMCTL32_Alloc(sizeof(LISTVIEW_INFO));
-  SetWindowLongA(hwnd,0,(DWORD)infoPtr);
-  if (infoPtr == NULL)
-  {
-    //ERR("could not allocate info memory!\n");
-    return 0;
-  }
-
-  if ((LISTVIEW_INFO *)GetWindowLongA(hwnd, 0) != infoPtr)
-  {
-    //ERR("pointer assignment error!\n");
-    return 0;
-  }
+  infoPtr = (LISTVIEW_INFO*)initControl(hwnd,sizeof(LISTVIEW_INFO));
+  if (!infoPtr) return 0;
 
   return DefWindowProcA(hwnd,WM_NCCREATE,wParam,lParam);
@@ -6625,5 +6768,5 @@
 static LRESULT LISTVIEW_NCDestroy(HWND hwnd)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
 
   //TRACE("(hwnd=%x)\n", hwnd);
@@ -6643,5 +6786,5 @@
 
   /* free listview info pointer*/
-  COMCTL32_Free(infoPtr);
+  doneControl(hwnd);
 
   return 0;
@@ -6662,29 +6805,25 @@
 static LRESULT LISTVIEW_Notify(HWND hwnd, INT nCtrlId, LPNMHDR lpnmh)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
 
   if (lpnmh->hwndFrom == infoPtr->hwndHeader)
   {
     /* handle notification from header control */
-    if (lpnmh->code == HDN_ENDTRACKA)
+    if ((lpnmh->code == HDN_ENDTRACKA) || (lpnmh->code == HDN_ENDTRACKW))
     {
       infoPtr->nItemWidth = LISTVIEW_GetItemWidth(hwnd);
       InvalidateRect(hwnd, NULL, TRUE);
     }
-    else if(lpnmh->code ==  HDN_ITEMCLICKA)
+    else if((lpnmh->code ==  HDN_ITEMCLICKA) || (lpnmh->code ==  HDN_ITEMCLICKW))
     {
         /* Handle sorting by Header Column */
         NMLISTVIEW nmlv;
         LPNMHEADERA pnmHeader = (LPNMHEADERA) lpnmh;
-        LONG lCtrlId = GetWindowLongA(hwnd, GWL_ID);
 
         ZeroMemory(&nmlv, sizeof(NMLISTVIEW));
-        nmlv.hdr.hwndFrom = hwnd;
-        nmlv.hdr.idFrom = lCtrlId;
-        nmlv.hdr.code = LVN_COLUMNCLICK;
         nmlv.iItem = -1;
         nmlv.iSubItem = pnmHeader->iItem;
 
-        ListView_LVNotify(GetParent(hwnd),lCtrlId, &nmlv);
+        sendNotify(hwnd,LVN_COLUMNCLICK,&nmlv.hdr);
 
     }
@@ -6709,34 +6848,4 @@
 /***
  * DESCRIPTION:
- * Determines the type of structure to use.
- *
- * PARAMETER(S):
- * [I] HWND : window handle of the sender
- * [I] HWND : listview window handle
- * [I] INT : command specifying the nature of the WM_NOTIFYFORMAT
- *
- * RETURN:
- * Zero
- */
-static LRESULT LISTVIEW_NotifyFormat(HWND hwndFrom, HWND hwnd, INT nCommand)
-{
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
-
-  if (nCommand == NF_REQUERY)
-  {
-    /* determine the type of structure to use */
-    infoPtr->notifyFormat = SendMessageA(hwndFrom, WM_NOTIFYFORMAT,
-                                         (WPARAM)hwnd, (LPARAM)NF_QUERY);
-    if (infoPtr->notifyFormat == NFR_UNICODE)
-    {
-      //FIXME("NO support for unicode structures");
-    }
-  }
-
-  return 0;
-}
-
-/***
- * DESCRIPTION:
  * Paints/Repaints the listview control.
  *
@@ -6784,18 +6893,11 @@
                                       WORD wPosY)
 {
-  INT nCtrlId = GetWindowLongA(hwnd, GWL_ID);
-  NMHDR nmh;
-
 //  TRACE("(hwnd=%x,key=%hu,X=%hu,Y=%hu)\n", hwnd, wKey, wPosX, wPosY);
 
   /* send NM_RELEASEDCAPTURE notification */
-  nmh.hwndFrom = hwnd;
-  nmh.idFrom = nCtrlId;
-  nmh.code = NM_RELEASEDCAPTURE;
-  ListView_Notify(GetParent(hwnd), nCtrlId, &nmh);
+  sendNotify(hwnd,NM_RELEASEDCAPTURE);
 
   /* send NM_RDBLCLK notification */
-  nmh.code = NM_RDBLCLK;
-  ListView_Notify(GetParent(hwnd), nCtrlId, &nmh);
+  sendNotify(hwnd,NM_RDBLCLK);
 
   return 0;
@@ -6818,8 +6920,6 @@
                                     WORD wPosY)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
-  INT nCtrlId = GetWindowLongA(hwnd, GWL_ID);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
   POINT ptPosition;
-  NMHDR nmh;
   INT nItem;
 
@@ -6827,8 +6927,5 @@
 
   /* send NM_RELEASEDCAPTURE notification */
-  nmh.hwndFrom = hwnd;
-  nmh.idFrom = nCtrlId;
-  nmh.code = NM_RELEASEDCAPTURE;
-  ListView_Notify(GetParent(hwnd), nCtrlId, &nmh);
+  sendNotify(hwnd,NM_RELEASEDCAPTURE);
 
   /* make sure the listview control window has the focus */
@@ -6876,7 +6973,6 @@
                                   WORD wPosY)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
   INT nCtrlId = GetWindowLongA(hwnd, GWL_ID);
-  NMHDR nmh;
 
 //  TRACE("(hwnd=%x,key=%hu,X=%hu,Y=%hu)\n", hwnd, wKey, wPosX, wPosY);
@@ -6887,9 +6983,5 @@
 
     /* send NM_RClICK notification */
-    ZeroMemory(&nmh, sizeof(NMHDR));
-    nmh.hwndFrom = hwnd;
-    nmh.idFrom = nCtrlId;
-    nmh.code = NM_RCLICK;
-    ListView_Notify(GetParent(hwnd), nCtrlId, &nmh);
+    sendNotify(hwnd,NM_RCLICK);
 
     /* set button flag */
@@ -6918,13 +7010,8 @@
 static LRESULT LISTVIEW_SetFocus(HWND hwnd, HWND hwndLoseFocus)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
-  INT nCtrlId = GetWindowLongA(hwnd, GWL_ID);
-  NMHDR nmh;
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
 
   /* send NM_SETFOCUS notification */
-  nmh.hwndFrom = hwnd;
-  nmh.idFrom = nCtrlId;
-  nmh.code = NM_SETFOCUS;
-  ListView_Notify(GetParent(hwnd), nCtrlId, &nmh);
+  sendNotify(hwnd,NM_SETFOCUS);
 
   /* set window focus flag */
@@ -6951,5 +7038,5 @@
 static LRESULT LISTVIEW_SetFont(HWND hwnd, HFONT hFont, WORD fRedraw)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
   UINT uView = GetWindowLongA(hwnd, GWL_STYLE) & LVS_TYPEMASK;
 
@@ -7061,5 +7148,5 @@
 static VOID LISTVIEW_UpdateSize(HWND hwnd)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
   LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE);
   UINT uView = lStyle & LVS_TYPEMASK;
@@ -7114,5 +7201,5 @@
                                  LPSTYLESTRUCT lpss)
 {
-  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
   UINT uNewView = lpss->styleNew & LVS_TYPEMASK;
   UINT uOldView = lpss->styleOld & LVS_TYPEMASK;
@@ -7250,7 +7337,9 @@
     return LISTVIEW_DeleteItem(hwnd, (INT)wParam);
 
+  case LVM_EDITLABELA:
+    return LISTVIEW_EditLabel(hwnd,(INT)wParam,FALSE);
+
   case LVM_EDITLABELW:
-  case LVM_EDITLABELA:
-    return LISTVIEW_EditLabelA(hwnd, (INT)wParam);
+    return LISTVIEW_EditLabel(hwnd,(INT)wParam,TRUE);
 
   case LVM_ENSUREVISIBLE:
@@ -7258,5 +7347,8 @@
 
   case LVM_FINDITEMA:
-    return LISTVIEW_FindItem(hwnd, (INT)wParam, (LPLVFINDINFO)lParam);
+    return LISTVIEW_FindItem(hwnd,(INT)wParam,(LPLVFINDINFOW)lParam,FALSE);
+
+  case LVM_FINDITEMW:
+    return LISTVIEW_FindItem(hwnd,(INT)wParam,(LPLVFINDINFOW)lParam,TRUE);
 
   case LVM_GETBKCOLOR:
@@ -7269,7 +7361,9 @@
 
   case LVM_GETCOLUMNA:
-    return LISTVIEW_GetColumnA(hwnd, (INT)wParam, (LPLVCOLUMNA)lParam);
-
-/*      case LVM_GETCOLUMNW: */
+    return LISTVIEW_GetColumn(hwnd,(INT)wParam,(LPLVCOLUMNW)lParam,FALSE);
+
+  case LVM_GETCOLUMNW:
+    return LISTVIEW_GetColumn(hwnd,(INT)wParam,(LPLVCOLUMNW)lParam,TRUE);
+
 
   case LVM_GETCOLUMNORDERARRAY:
@@ -7304,7 +7398,9 @@
 
   case LVM_GETITEMA:
-    return LISTVIEW_GetItemA(hwnd, (LPLVITEMA)lParam);
-
-/*      case LVM_GETITEMW: */
+    return LISTVIEW_GetItem(hwnd,(LPLVITEMW)lParam,FALSE);
+
+  case LVM_GETITEMW:
+    return LISTVIEW_GetItem(hwnd,(LPLVITEMW)lParam,TRUE);
+
 
   case LVM_GETITEMCOUNT:
@@ -7324,8 +7420,11 @@
 
   case LVM_GETITEMTEXTA:
-    LISTVIEW_GetItemTextA(hwnd, (INT)wParam, (LPLVITEMA)lParam);
+    LISTVIEW_GetItemText(hwnd,(INT)wParam,(LPLVITEMW)lParam,FALSE);
     break;
 
-/*      case LVM_GETITEMTEXTW: */
+  case LVM_GETITEMTEXTW:
+    LISTVIEW_GetItemText(hwnd,(INT)wParam,(LPLVITEMW)lParam,TRUE);
+    break;
+
 
   case LVM_GETNEXTITEM:
@@ -7344,7 +7443,9 @@
 
   case LVM_GETSTRINGWIDTHA:
-    return LISTVIEW_GetStringWidthA (hwnd, (LPCSTR)lParam);
-
-/*      case LVM_GETSTRINGWIDTHW: */
+    return LISTVIEW_GetStringWidth(hwnd,(LPWSTR)lParam,FALSE);
+
+  case LVM_GETSTRINGWIDTHW:
+    return LISTVIEW_GetStringWidth(hwnd,(LPWSTR)lParam,TRUE);
+
 /*      case LVM_GETSUBITEMRECT: */
 
@@ -7371,14 +7472,14 @@
 
   case LVM_INSERTCOLUMNA:
-    return LISTVIEW_InsertColumnA(hwnd, (INT)wParam, (LPLVCOLUMNA)lParam);
+    return LISTVIEW_InsertColumn(hwnd,(INT)wParam,(LPLVCOLUMNW)lParam,FALSE);
 
   case LVM_INSERTCOLUMNW:
-    return LISTVIEW_InsertColumnW(hwnd, (INT)wParam, (LPLVCOLUMNW)lParam);
+    return LISTVIEW_InsertColumn(hwnd,(INT)wParam,(LPLVCOLUMNW)lParam,TRUE);
 
   case LVM_INSERTITEMA:
-    return LISTVIEW_InsertItemA(hwnd, (LPLVITEMA)lParam);
+    return LISTVIEW_InsertItem(hwnd,(LPLVITEMW)lParam,FALSE);
 
   case LVM_INSERTITEMW:
-    return LISTVIEW_InsertItemW(hwnd, (LPLVITEMW)lParam);
+    return LISTVIEW_InsertItem(hwnd,(LPLVITEMW)lParam,TRUE);
 
   case LVM_REDRAWITEMS:
@@ -7397,9 +7498,8 @@
 
   case LVM_SETCOLUMNA:
-    return LISTVIEW_SetColumnA(hwnd, (INT)wParam, (LPLVCOLUMNA)lParam);
+    return LISTVIEW_SetColumn(hwnd,(INT)wParam,(LPLVCOLUMNW)lParam,FALSE);
 
   case LVM_SETCOLUMNW:
-    //FIXME("Unimplemented msg LVM_SETCOLUMNW\n");
-    return 0;
+    return LISTVIEW_SetColumn(hwnd,(INT)wParam,(LPLVCOLUMNW)lParam,TRUE);
 
   case LVM_SETCOLUMNORDERARRAY:
@@ -7424,7 +7524,8 @@
 
   case LVM_SETITEMA:
-    return LISTVIEW_SetItemA(hwnd, (LPLVITEMA)lParam);
-
-/*      case LVM_SETITEMW: */
+    return LISTVIEW_SetItemHandler(hwnd,(LPLVITEMW)lParam,FALSE);
+
+  case LVM_SETITEMW:
+    return LISTVIEW_SetItemHandler(hwnd,(LPLVITEMW)lParam,TRUE);
 
   case LVM_SETITEMCOUNT:
@@ -7438,10 +7539,11 @@
 
   case LVM_SETITEMSTATE:
-    return LISTVIEW_SetItemState(hwnd, (INT)wParam, (LPLVITEMA)lParam);
+    return LISTVIEW_SetItemState(hwnd, (INT)wParam, (LPLVITEMW)lParam);
 
   case LVM_SETITEMTEXTA:
-    return LISTVIEW_SetItemTextA(hwnd, (INT)wParam, (LPLVITEMA)lParam);
-
-/*      case LVM_SETITEMTEXTW: */
+    return LISTVIEW_SetItemText(hwnd,(INT)wParam,(LPLVITEMW)lParam,FALSE);
+
+  case LVM_SETITEMTEXTW:
+    return LISTVIEW_SetItemText(hwnd,(INT)wParam,(LPLVITEMW)lParam,TRUE);
 
   case LVM_SETSELECTIONMARK:
@@ -7515,7 +7617,4 @@
     return LISTVIEW_Notify(hwnd, (INT)wParam, (LPNMHDR)lParam);
 
-  case WM_NOTIFYFORMAT:
-    return LISTVIEW_NotifyFormat(hwnd, (HWND)wParam, (INT)lParam);
-
   case WM_PAINT:
     return LISTVIEW_Paint(hwnd, (HDC)wParam);
@@ -7570,5 +7669,5 @@
 
     /* call default window procedure */
-    return DefWindowProcA(hwnd, uMsg, wParam, lParam);
+    return defComCtl32ProcA(hwnd, uMsg, wParam, lParam);
   }
 
@@ -7634,5 +7733,5 @@
              */
             char buffer[1024];
-            LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
+            LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
             HDC           hdc      = GetDC(infoPtr->hwndEdit);
             HFONT         hFont, hOldFont = 0;
@@ -7697,5 +7796,5 @@
 {
     BOOL cancel = FALSE;
-    LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(GetParent(hwnd), 0);
+    LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(GetParent(hwnd));
     EDITLABEL_ITEM *einfo = infoPtr->pedititem;
     static BOOL bIgnoreKillFocus = FALSE;
@@ -7785,5 +7884,5 @@
     HDC hOldFont=0;
     TEXTMETRICA textMetric;
-    LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(parent, 0);
+    LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(parent);
 
     if (NULL == (infoPtr->pedititem = (EDITLABEL_ITEM*)COMCTL32_Alloc(sizeof(EDITLABEL_ITEM))))
Index: trunk/src/comctl32/treeview.cpp
===================================================================
--- trunk/src/comctl32/treeview.cpp	(revision 2893)
+++ trunk/src/comctl32/treeview.cpp	(revision 2895)
@@ -1,3 +1,3 @@
-/* $Id: treeview.cpp,v 1.1 2000-02-23 17:09:50 cbratschi Exp $ */
+/* $Id: treeview.cpp,v 1.2 2000-02-25 17:00:18 cbratschi Exp $ */
 /* Treeview control
  *
@@ -32,4 +32,5 @@
 /* CB: todo
  - bug in SetScrollInfo/ShowScrollBar: WM_SIZE and WM_NCPAINT problems (i.e. RegEdit)
+ - VK_LEFT in WinHlp32 displays expanded icon
  - tooltips not finished
  - expand not finished
@@ -325,4 +326,5 @@
     if (killItem->pszText != LPSTR_TEXTCALLBACKW)
       COMCTL32_Free (killItem->pszText);
+    killItem->pszText = NULL;
     TREEVIEW_SendTreeviewNotify (hwnd, TVN_DELETEITEM, 0, (HTREEITEM)kill, 0);
     if (killItem->firstChild)
@@ -351,4 +353,5 @@
  if (wineItem->pszText != LPSTR_TEXTCALLBACKW)
    COMCTL32_Free (wineItem->pszText);
+ wineItem->pszText = NULL;
 
  TREEVIEW_SendTreeviewNotify (hwnd, TVN_DELETEITEM, 0, (HTREEITEM)iItem, 0);
@@ -397,4 +400,6 @@
                 if (killItem->pszText != LPSTR_TEXTCALLBACKW)
                   COMCTL32_Free (killItem->pszText);
+                killItem->pszText = NULL;
+
                 TREEVIEW_SendTreeviewNotify
                                         (hwnd, TVN_DELETEITEM, 0, killItem->hItem, 0);
@@ -2847,5 +2852,4 @@
   NMTREEVIEWW nmhdr;
   TREEVIEW_ITEM  *wineItem;
-  HWND parent = GetParent(hwnd);
   CHAR *oldText = NULL,*newText = NULL;
   BOOL rc;
@@ -2853,17 +2857,14 @@
   ZeroMemory(&nmhdr,sizeof(NMTREEVIEWW));
 
-  nmhdr.hdr.hwndFrom = hwnd;
-  nmhdr.hdr.idFrom =  GetWindowLongW( hwnd, GWL_ID);
-  nmhdr.hdr.code = code;
   nmhdr.action = action;
   if (oldItem)
   {
-    wineItem=& infoPtr->items[(INT)oldItem];
-    nmhdr.itemOld.mask              = wineItem->mask;
-    nmhdr.itemOld.hItem             = wineItem->hItem;
-    nmhdr.itemOld.state             = wineItem->state;
+    wineItem = &infoPtr->items[(INT)oldItem];
+    nmhdr.itemOld.mask      = wineItem->mask;
+    nmhdr.itemOld.hItem     = wineItem->hItem;
+    nmhdr.itemOld.state     = wineItem->state;
     nmhdr.itemOld.stateMask = wineItem->stateMask;
     nmhdr.itemOld.iImage    = wineItem->iImage;
-    if (infoPtr->header.uNotifyFormat == NFR_ANSI)
+    if (!isUnicodeNotify(&infoPtr->header))
     {
       if (!wineItem->pszText) nmhdr.itemOld.pszText = NULL; else
@@ -2885,5 +2886,5 @@
   if (newItem)
   {
-    wineItem=& infoPtr->items[(INT)newItem];
+    wineItem = &infoPtr->items[(INT)newItem];
     nmhdr.itemNew.mask              = wineItem->mask;
     nmhdr.itemNew.hItem             = wineItem->hItem;
@@ -2891,7 +2892,7 @@
     nmhdr.itemNew.stateMask = wineItem->stateMask;
     nmhdr.itemNew.iImage    = wineItem->iImage;
-    if (infoPtr->header.uNotifyFormat == NFR_ANSI)
-    {
-      if (!wineItem->pszText) nmhdr.itemOld.pszText = NULL; else
+    if (!isUnicodeNotify(&infoPtr->header))
+    {
+      if (!wineItem->pszText) nmhdr.itemNew.pszText = NULL; else
       {
         INT len = lstrlenW(wineItem->pszText)+1;
@@ -2899,5 +2900,5 @@
         newText = (CHAR*)COMCTL32_Alloc(len);
         lstrcpyWtoA(newText,wineItem->pszText);
-        nmhdr.itemOld.pszText = (WCHAR*)newText;
+        nmhdr.itemNew.pszText = (WCHAR*)newText;
       }
     } else nmhdr.itemNew.pszText   = wineItem->pszText;
@@ -2912,5 +2913,5 @@
   nmhdr.ptDrag.y = 0;
 
-  rc = (BOOL)SendMessageA(parent,WM_NOTIFY,(WPARAM)nmhdr.hdr.idFrom,(LPARAM)&nmhdr);
+  rc = (BOOL)sendNotify(hwnd,code,&nmhdr.hdr);
 
   if (oldText) COMCTL32_Free(oldText);
@@ -2928,7 +2929,4 @@
   TREEVIEW_ITEM  *wineItem;
 
-  nmhdr.hdr.hwndFrom = hwnd;
-  nmhdr.hdr.idFrom =  GetWindowLongA( hwnd, GWL_ID);
-  nmhdr.hdr.code = code;
   nmhdr.action = 0;
   wineItem=& infoPtr->items[(INT)dragItem];
@@ -2941,6 +2939,5 @@
   nmhdr.ptDrag.y = pt.y;
 
-  return (BOOL)SendMessageA (GetParent (hwnd), WM_NOTIFY,
-                                   (WPARAM) GetWindowLongA( hwnd, GWL_ID), (LPARAM)&nmhdr);
+  return (BOOL)sendNotify(hwnd,code,&nmhdr.hdr);
 
 }
@@ -2953,18 +2950,14 @@
   BOOL retval;
   WCHAR *buf;
-  HWND parent = GetParent(hwnd);
-
-  tvdi.hdr.hwndFrom     = hwnd;
-  tvdi.hdr.idFrom       = GetWindowLongA( hwnd, GWL_ID);
-  tvdi.hdr.code         = code;
+
   tvdi.item.mask        = what;
   tvdi.item.hItem       = wineItem->hItem;
   tvdi.item.state       = wineItem->state;
   tvdi.item.lParam      = wineItem->lParam;
-  tvdi.item.pszText     = (WCHAR*)COMCTL32_Alloc(128*((infoPtr->header.uNotifyFormat == NFR_UNICODE) ? sizeof(WCHAR):sizeof(char)));
+  tvdi.item.pszText     = (WCHAR*)COMCTL32_Alloc(128*(isUnicodeNotify(&infoPtr->header) ? sizeof(WCHAR):sizeof(char)));
   tvdi.item.cchTextMax = 128;
   buf = tvdi.item.pszText;
 
-  retval = (BOOL)SendMessageA(parent,WM_NOTIFY,(WPARAM)tvdi.hdr.idFrom,(LPARAM)&tvdi);
+  retval = (BOOL)sendNotify(hwnd,code,&tvdi.hdr);
 
   /* Ignore posible changes */
@@ -2974,5 +2967,5 @@
   if (what & TVIF_TEXT)
   {
-    if (infoPtr->header.uNotifyFormat == NFR_UNICODE)
+    if (isUnicodeNotify(&infoPtr->header))
     {
       wineItem->pszText = tvdi.item.pszText;
@@ -3022,8 +3015,5 @@
   LPNMCUSTOMDRAW nmcd;
 
-  nmcd =& nmcdhdr.nmcd;
-  nmcd->hdr.hwndFrom = hwnd;
-  nmcd->hdr.idFrom =  GetWindowLongA( hwnd, GWL_ID);
-  nmcd->hdr.code   = NM_CUSTOMDRAW;
+  nmcd = &nmcdhdr.nmcd;
   nmcd->dwDrawStage= dwDrawStage;
   nmcd->hdc        = hdc;
@@ -3039,6 +3029,5 @@
   nmcdhdr.iLevel   = 0;
 
-  return (BOOL)SendMessageA (GetParent (hwnd), WM_NOTIFY,
-                               (WPARAM) GetWindowLongA( hwnd, GWL_ID), (LPARAM)&nmcdhdr);
+  return (BOOL)sendNotify(hwnd,NM_CUSTOMDRAW,&nmcdhdr.nmcd.hdr);
 }
 
@@ -3067,7 +3056,4 @@
 
   nmcd= & nmcdhdr.nmcd;
-  nmcd->hdr.hwndFrom = hwnd;
-  nmcd->hdr.idFrom =  GetWindowLongA( hwnd, GWL_ID);
-  nmcd->hdr.code   = NM_CUSTOMDRAW;
   nmcd->dwDrawStage= dwDrawStage;
   nmcd->hdc                = hdc;
@@ -3087,6 +3073,5 @@
   //               dwDrawStage, hdc, dwItemSpec, uItemState);
 
-  retval=SendMessageA (GetParent (hwnd), WM_NOTIFY,
-                 (WPARAM) GetWindowLongA( hwnd, GWL_ID), (LPARAM)&nmcdhdr);
+  retval = sendNotify(hwnd,NM_CUSTOMDRAW,&nmcdhdr.nmcd.hdr);
 
   infoPtr->clrText=nmcdhdr.clrText;
@@ -3100,11 +3085,8 @@
   NMTVKEYDOWN nmkdhdr;
 
-  nmkdhdr.hdr.hwndFrom = hwnd;
-  nmkdhdr.hdr.idFrom   =  GetWindowLongA( hwnd, GWL_ID);
-  nmkdhdr.hdr.code     = code;
   nmkdhdr.wVKey = wVKey;
   nmkdhdr.flags = 0;
 
-  SendMessageA(GetParent(hwnd),WM_NOTIFY,(WPARAM)nmkdhdr.hdr.idFrom,(LPARAM)&nmkdhdr);
+  sendNotify(hwnd,code,&nmkdhdr.hdr);
 }
 
@@ -3387,5 +3369,4 @@
   NMTVDISPINFOW tvdi;
   DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
-  HWND parent = GetParent(hwnd);
   BOOL bCommit;
   WCHAR *textW = NULL;
@@ -3396,7 +3377,4 @@
      return FALSE;
 
-  tvdi.hdr.hwndFrom     = hwnd;
-  tvdi.hdr.idFrom       = GetWindowLongA(hwnd, GWL_ID);
-  tvdi.hdr.code         = TVN_ENDLABELEDIT;
   tvdi.item.mask        = 0;
   tvdi.item.hItem       = editedItem->hItem;
@@ -3414,5 +3392,5 @@
     //}
 
-    if (infoPtr->header.uNotifyFormat == NFR_UNICODE) tvdi.item.pszText = textW; else
+    if (isUnicodeNotify(&infoPtr->header)) tvdi.item.pszText = textW; else
     {
       INT len = iLength+1;
@@ -3430,9 +3408,9 @@
   }
 
-  bCommit = (BOOL)SendMessageA(parent,WM_NOTIFY,(WPARAM)tvdi.hdr.idFrom,(LPARAM)&tvdi);
+  bCommit = (BOOL)sendNotify(hwnd,TVN_ENDLABELEDIT,&tvdi.hdr);
 
   if (!bCancel && bCommit) /* Apply the changes */
   {
-    if (infoPtr->header.uNotifyFormat == NFR_ANSI)
+    if (!isUnicodeNotify(&infoPtr->header))
       lstrcpynAtoW(textW,textA,iLength+1);
     if (lstrcmpW(textW,editedItem->pszText) != 0)
@@ -3577,16 +3555,12 @@
       {
         NMTVGETINFOTIPW tvgit;
-        HWND parent = GetParent(hwnd);
-
-        tvgit.hdr.hwndFrom = hwnd;
-        tvgit.hdr.idFrom   =  GetWindowLongA(hwnd,GWL_ID);
-        tvgit.hdr.code     = (infoPtr->header.uNotifyFormat == NFR_UNICODE) ? TVN_GETINFOTIPW:TVN_GETINFOTIPA;
-        tvgit.pszText    = (WCHAR*)COMCTL32_Alloc((infoPtr->header.uNotifyFormat == NFR_UNICODE) ? INFOTIPSIZE*sizeof(WCHAR):INFOTIPSIZE*sizeof(CHAR));
+
+        tvgit.pszText    = (WCHAR*)COMCTL32_Alloc(isUnicodeNotify(&infoPtr->header) ? INFOTIPSIZE*sizeof(WCHAR):INFOTIPSIZE*sizeof(CHAR));
         tvgit.cchTextMax = INFOTIPSIZE;
         tvgit.hItem      = item->hItem;
         tvgit.lParam     = item->lParam;
 
-        SendMessageA(parent,WM_NOTIFY,(WPARAM)tvgit.hdr.idFrom,(LPARAM)&tvgit);
-        if (infoPtr->header.uNotifyFormat == NFR_UNICODE)
+        sendNotify(hwnd,isUnicodeNotify(&infoPtr->header) ? TVN_GETINFOTIPW:TVN_GETINFOTIPA,&tvgit.hdr);
+        if (isUnicodeNotify(&infoPtr->header))
         {
           text = tvgit.pszText;
@@ -4010,10 +3984,10 @@
 
     case SB_PAGEUP:
-      newY = infoPtr->lefttop.y-MAX(((INT)(infoPtr->uVisibleHeight/infoPtr->uVScrollStep))*infoPtr->uVScrollStep,infoPtr->uVisibleHeight);
+      newY = infoPtr->lefttop.y-MAX(((INT)(infoPtr->uVisibleHeight/infoPtr->uVScrollStep))*infoPtr->uVScrollStep,infoPtr->uVScrollStep);
       if (newY < 0) newY = 0;
       break;
 
     case SB_PAGEDOWN:
-      newY = infoPtr->lefttop.y+MAX(((INT)(infoPtr->uVisibleHeight/infoPtr->uVScrollStep))*infoPtr->uVScrollStep,infoPtr->uVisibleHeight);
+      newY = infoPtr->lefttop.y+MAX(((INT)(infoPtr->uVisibleHeight/infoPtr->uVScrollStep))*infoPtr->uVScrollStep,infoPtr->uVScrollStep);
       if (newY > maxY) newY = maxY;
       break;
