Sync to Wine-20050524:
Alexandre Julliard <julliard@winehq.org>
- Added rules for building import libraries in the individual dll
  makefiles, and added support for building a .def.a static import
  library too.
Francois Gouget <fgouget@free.fr>
- Assorted spelling fixes.
Kouji Sasaki <taro-x@justsystem.co.jp>
- Added handling of WM_ENABLE message.
James Hawkins <truiken@gmail.com>
- Audit the List-View control.
- Select the item under the point (x,y) in MouseHover.
- Store the click point in LISTVIEW_INFO.
- Move mouse tracking to MouseMove.
- Use DragDetect instead of TrackMouse.
- Remove the unused TrackMouse function.
- Fixed centering of tab text.
Dimi Paun <dimi@lattica.com>
- Do not compute the hit test if we don't really need it.
- Make it more explicit how we deal with WS_DISABLED.
Felix Nawothnig <felix.nawothnig@t-online.de>
- Resize listview column to autofit on a doubleclick on the
  header-divider.
- Implemented WM_ENABLE.
- Rewrote item layouting - new code fixes bitmap/image position for
  non-left-aligned text, prevents jumping when resizing non-left-aligned
  text, implements clipping for images and correctly aligns bitmaps when
  an image is already there.
- Set iItem to index before notifying callback items.
Duane Clark <dclark@akamail.com>
- Misc rectangle fixes.
- The date should be initialized from local time.
Aric Stewart <aric@codeweavers.com>
- Handle WM_NCCALCSIZE in the tab control.
Hans Leidekker <hans@it.vu.nl>
- Fix uninitialized warnings.
Modified: trunk/reactos/lib/comctl32/Makefile.in
Modified: trunk/reactos/lib/comctl32/comboex.c
Modified: trunk/reactos/lib/comctl32/comctl32undoc.c
Modified: trunk/reactos/lib/comctl32/datetime.c
Modified: trunk/reactos/lib/comctl32/header.c
Modified: trunk/reactos/lib/comctl32/hotkey.c
Modified: trunk/reactos/lib/comctl32/imagelist.c
Modified: trunk/reactos/lib/comctl32/ipaddress.c
Modified: trunk/reactos/lib/comctl32/listview.c
Modified: trunk/reactos/lib/comctl32/monthcal.c
Modified: trunk/reactos/lib/comctl32/tab.c
Modified: trunk/reactos/lib/comctl32/toolbar.c
Modified: trunk/reactos/lib/comctl32/updown.c

Modified: trunk/reactos/lib/comctl32/Makefile.in
--- trunk/reactos/lib/comctl32/Makefile.in	2005-05-26 20:39:17 UTC (rev 15530)
+++ trunk/reactos/lib/comctl32/Makefile.in	2005-05-26 20:52:12 UTC (rev 15531)
@@ -4,6 +4,7 @@
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = comctl32.dll
+IMPORTLIB = libcomctl32.$(IMPLIBEXT)
 IMPORTS   = user32 gdi32 advapi32 kernel32
 DELAYIMPORTS = winmm
 EXTRALIBS = $(LIBUNICODE)

Modified: trunk/reactos/lib/comctl32/comboex.c
--- trunk/reactos/lib/comctl32/comboex.c	2005-05-26 20:39:17 UTC (rev 15530)
+++ trunk/reactos/lib/comctl32/comboex.c	2005-05-26 20:52:12 UTC (rev 15531)
@@ -283,6 +283,26 @@
 }
 
 
+static INT COMBOEX_GetIndex(COMBOEX_INFO *infoPtr, CBE_ITEMDATA *item)
+{
+    CBE_ITEMDATA *moving;
+    INT index;
+    
+    moving = infoPtr->items;
+    index = infoPtr->nb_items - 1;
+
+    while (moving && (moving != item)) {
+        moving = moving->next;
+        index--;
+    }
+    if (!moving || (index < 0)) {
+        ERR("COMBOBOXEX item structures broken. Please report!\n");
+        return -1;
+    }
+    return index;
+}
+
+
 static LPCWSTR COMBOEX_GetText(COMBOEX_INFO *infoPtr, CBE_ITEMDATA *item)
 {
     NMCOMBOBOXEXW nmce;
@@ -295,6 +315,7 @@
     ZeroMemory(&nmce, sizeof(nmce));
     nmce.ceItem.mask = CBEIF_TEXT;
     nmce.ceItem.lParam = item->lParam;
+    nmce.ceItem.iItem = COMBOEX_GetIndex(infoPtr, item);
     COMBOEX_NotifyItem(infoPtr, CBEN_GETDISPINFOW, &nmce);
 
     if (is_textW(nmce.ceItem.pszText)) {
@@ -1389,6 +1410,7 @@
 	    ZeroMemory(&nmce, sizeof(nmce));
 	    nmce.ceItem.mask = CBEIF_INDENT;
 	    nmce.ceItem.lParam = item->lParam;
+	    nmce.ceItem.iItem = dis->itemID;
 	    COMBOEX_NotifyItem(infoPtr, CBEN_GETDISPINFOW, &nmce);
 	    if (nmce.ceItem.mask & CBEIF_DI_SETITEM)
 		item->iIndent = nmce.ceItem.iIndent;
@@ -1453,6 +1475,7 @@
 	    ZeroMemory(&nmce, sizeof(nmce));
 	    nmce.ceItem.mask = (drawstate == ILD_NORMAL) ? CBEIF_IMAGE : CBEIF_SELECTEDIMAGE;
 	    nmce.ceItem.lParam = item->lParam;
+	    nmce.ceItem.iItem = dis->itemID;
 	    COMBOEX_NotifyItem(infoPtr, CBEN_GETDISPINFOW, &nmce);
 	    if (drawstate == ILD_NORMAL) {
 	    	if (nmce.ceItem.mask & CBEIF_DI_SETITEM) item->iImage = nmce.ceItem.iImage;
@@ -1468,6 +1491,7 @@
 	    ZeroMemory(&nmce, sizeof(nmce));
 	    nmce.ceItem.mask = CBEIF_OVERLAY;
 	    nmce.ceItem.lParam = item->lParam;
+	    nmce.ceItem.iItem = dis->itemID;
 	    COMBOEX_NotifyItem(infoPtr, CBEN_GETDISPINFOW, &nmce);
 	    if (nmce.ceItem.mask & CBEIF_DI_SETITEM)
 		item->iOverlay = nmce.ceItem.iOverlay;

Modified: trunk/reactos/lib/comctl32/comctl32undoc.c
--- trunk/reactos/lib/comctl32/comctl32undoc.c	2005-05-26 20:39:17 UTC (rev 15530)
+++ trunk/reactos/lib/comctl32/comctl32undoc.c	2005-05-26 20:52:12 UTC (rev 15531)
@@ -588,7 +588,7 @@
     if ((err = RegOpenKeyExW( mp->extview.hKey, mp->extview.lpszSubKey,
 			      0, KEY_WRITE, &newkey))) {
 	/* not present - what to do ??? */
-	ERR("Can not open key, error=%d, attempting to create\n",
+	ERR("Could not open key, error=%d, attempting to create\n",
 	    err);
 	if ((err = RegCreateKeyExW( mp->extview.hKey, mp->extview.lpszSubKey,
 				    0,
@@ -980,7 +980,7 @@
 				&newkey,
 				&dwdisp))) {
 	/* error - what to do ??? */
-	ERR("(%lu %lu %lx %lx \"%s\" %p): Can not open key, error=%d\n",
+	ERR("(%lu %lu %lx %lx \"%s\" %p): Could not open key, error=%d\n",
 	    mp->extview.cbSize, mp->extview.nMaxItems, mp->extview.dwFlags,
 	    (DWORD)mp->extview.hKey, debugstr_w(mp->extview.lpszSubKey),
 				 mp->extview.lpfnCompare, err);

Modified: trunk/reactos/lib/comctl32/datetime.c
--- trunk/reactos/lib/comctl32/datetime.c	2005-05-26 20:39:17 UTC (rev 15530)
+++ trunk/reactos/lib/comctl32/datetime.c	2005-05-26 20:52:12 UTC (rev 15531)
@@ -607,7 +607,7 @@
     RECT *checkbox = &infoPtr->checkbox;
     SIZE size;
     COLORREF oldTextColor;
-    SHORT fieldWidth;
+    SHORT fieldWidth = 0;
 
     /* draw control edge */
     TRACE("\n");

Modified: trunk/reactos/lib/comctl32/header.c
--- trunk/reactos/lib/comctl32/header.c	2005-05-26 20:39:17 UTC (rev 15530)
+++ trunk/reactos/lib/comctl32/header.c	2005-05-26 20:52:12 UTC (rev 15531)
@@ -163,7 +163,7 @@
     HEADER_INFO *infoPtr = HEADER_GetInfoPtr (hwnd);
     HEADER_ITEM *phdi = &infoPtr->items[iItem];
     RECT r;
-    INT  oldBkMode;
+    INT  oldBkMode, cxEdge = GetSystemMetrics(SM_CXEDGE);
 
     TRACE("DrawItem(iItem %d bHotTrack %d unicode flag %d)\n", iItem, bHotTrack, infoPtr->bUnicode);
 
@@ -188,6 +188,9 @@
     else
         DrawEdge (hdc, &r, EDGE_ETCHED, BF_BOTTOM | BF_RIGHT | BF_ADJUST);
 
+    r.left  -= cxEdge;
+    r.right += cxEdge;
+
     if (phdi->fmt & HDF_OWNERDRAW) {
 	DRAWITEMSTRUCT dis;
 	dis.CtlType    = ODT_HEADER;
@@ -206,149 +209,117 @@
             SetBkMode(hdc, oldBkMode);
     }
     else {
-        UINT uTextJustify = DT_LEFT;
+	UINT rw, rh, /* width and height of r */
+	     *x = NULL, *w = NULL; /* x and width of the pic (bmp or img) which is part of cnt */
+	  /* cnt,txt,img,bmp */
+	UINT cx, tx, ix, bx,
+	     cw, tw, iw, bw;
+	BITMAP bmp;
 
-        if ((phdi->fmt & HDF_JUSTIFYMASK) == HDF_CENTER)
-            uTextJustify = DT_CENTER;
-        else if ((phdi->fmt & HDF_JUSTIFYMASK) == HDF_RIGHT)
-            uTextJustify = DT_RIGHT;
+	cw = tw = iw = bw = 0;
+	rw = r.right - r.left;
+	rh = r.bottom - r.top;
 
-	if ((phdi->fmt & HDF_BITMAP) && !(phdi->fmt & HDF_BITMAP_ON_RIGHT) && (phdi->hbm)) {
-	    BITMAP bmp;
-	    HDC    hdcBitmap;
-	    INT    yD, yS, cx, cy, rx, ry;
+	if (phdi->fmt & HDF_STRING) {
+	    RECT textRect;
 
-	    GetObjectW (phdi->hbm, sizeof(BITMAP), (LPVOID)&bmp);
+	    DrawTextW (hdc, phdi->pszText, -1,
+	               &textRect, DT_LEFT|DT_VCENTER|DT_SINGLELINE|DT_CALCRECT);
+	    cw = textRect.right - textRect.left + 2 * infoPtr->iMargin;
+	}
 
-	    ry = r.bottom - r.top;
-	    rx = r.right - r.left;
-
-	    if (ry >= bmp.bmHeight) {
-		cy = bmp.bmHeight;
-		yD = r.top + (ry - bmp.bmHeight) / 2;
-		yS = 0;
-	    }
-	    else {
-		cy = ry;
-		yD = r.top;
-		yS = (bmp.bmHeight - ry) / 2;
-
-	    }
-
-	    if (rx >= bmp.bmWidth + infoPtr->iMargin) {
-		cx = bmp.bmWidth;
-	    }
-	    else {
-		cx = rx - infoPtr->iMargin;
-	    }
-
-	    hdcBitmap = CreateCompatibleDC (hdc);
-	    SelectObject (hdcBitmap, phdi->hbm);
-	    BitBlt (hdc, r.left + infoPtr->iMargin, yD, cx, cy, hdcBitmap, 0, yS, SRCCOPY);
-	    DeleteDC (hdcBitmap);
-
-	    r.left += (bmp.bmWidth + infoPtr->iMargin);
+	if ((phdi->fmt & HDF_IMAGE) && (infoPtr->himl)) {
+	    iw = infoPtr->himl->cx + 2 * infoPtr->iMargin;
+	    x = &ix;
+	    w = &iw;
 	}
 
-
-	if ((phdi->fmt & HDF_BITMAP) && (phdi->fmt & HDF_BITMAP_ON_RIGHT) && (phdi->hbm)) {
-	    BITMAP bmp;
-	    HDC    hdcBitmap;
-	    INT    xD, yD, yS, cx, cy, rx, ry, tx;
-	    RECT   textRect;
-
+	if ((phdi->fmt & HDF_BITMAP) && (phdi->hbm)) {
 	    GetObjectW (phdi->hbm, sizeof(BITMAP), (LPVOID)&bmp);
-
-	    textRect = r;
-	    if (phdi->fmt & HDF_STRING) {
-		DrawTextW (hdc, phdi->pszText, -1,
-			   &textRect, DT_LEFT|DT_VCENTER|DT_SINGLELINE|DT_CALCRECT);
-		tx = textRect.right - textRect.left;
+	    bw = bmp.bmWidth + 2 * infoPtr->iMargin;
+	    if (!iw) {
+		x = &bx;
+		w = &bw;
 	    }
-	    else
-		tx = 0;
-	    ry = r.bottom - r.top;
-	    rx = r.right - r.left;
+	}
 
-	    if (ry >= bmp.bmHeight) {
-		cy = bmp.bmHeight;
-		yD = r.top + (ry - bmp.bmHeight) / 2;
-		yS = 0;
-	    }
-	    else {
-		cy = ry;
-		yD = r.top;
-		yS = (bmp.bmHeight - ry) / 2;
+	if (bw || iw)
+	    cw += *w; 
 
+	/* align cx using the unclipped cw */
+	if ((phdi->fmt & HDF_JUSTIFYMASK) == HDF_LEFT)
+	    cx = r.left;
+	else if ((phdi->fmt & HDF_JUSTIFYMASK) == HDF_CENTER)
+	    cx = r.left + rw / 2 - cw / 2;
+	else /* HDF_RIGHT */
+	    cx = r.right - cw;
+        
+	/* clip cx & cw */
+	if (cx < r.left)
+	    cx = r.left;
+	if (cx + cw > r.right)
+	    cw = r.right - cx;
+	
+	tx = cx + infoPtr->iMargin;
+	/* since cw might have changed we have to recalculate tw */
+	tw = cw - infoPtr->iMargin * 2;
+			
+	if (iw || bw) {
+	    tw -= *w;
+	    if (phdi->fmt & HDF_BITMAP_ON_RIGHT) {
+		/* put pic behind text */
+		*x = cx + tw + infoPtr->iMargin * 3;
+	    } else {
+		*x = cx + infoPtr->iMargin;
+		/* move text behind pic */
+		tx += *w;
 	    }
-
-	    if (r.left + tx + bmp.bmWidth + 2*infoPtr->iMargin <= r.right) {
-		cx = bmp.bmWidth;
-		xD = r.left + tx + infoPtr->iMargin;
-	    }
-	    else {
-		if (rx >= bmp.bmWidth + infoPtr->iMargin ) {
-		    cx = bmp.bmWidth;
-		    xD = r.right - bmp.bmWidth - infoPtr->iMargin;
-		    r.right = xD - infoPtr->iMargin;
-		}
-		else {
-		    cx = rx - infoPtr->iMargin;
-		    xD = r.left;
-		    r.right = r.left;
-		}
-	    }
-
-	    hdcBitmap = CreateCompatibleDC (hdc);
-	    SelectObject (hdcBitmap, phdi->hbm);
-	    BitBlt (hdc, xD, yD, cx, cy, hdcBitmap, 0, yS, SRCCOPY);
-	    DeleteDC (hdcBitmap);
 	}
 
-	if ((phdi->fmt & HDF_IMAGE) && !(phdi->fmt & HDF_BITMAP_ON_RIGHT) && (infoPtr->himl)) {
-	    r.left += infoPtr->iMargin;
-	    ImageList_DrawEx(infoPtr->himl, phdi->iImage, hdc, r.left, r.top + (r.bottom-r.top- infoPtr->himl->cy)/2,
-			     infoPtr->himl->cx, r.bottom-r.top, CLR_DEFAULT, CLR_DEFAULT, 0); 
-	    r.left += infoPtr->himl->cx;
+	if (iw && bw) {
+	    /* since we're done with the layout we can
+	       now calculate the position of bmp which
+	       has no influence on alignment and layout
+	       because of img */
+	    if ((phdi->fmt & HDF_JUSTIFYMASK) == HDF_RIGHT)
+	        bx = cx - bw + infoPtr->iMargin;
+	    else
+	        bx = cx + cw + infoPtr->iMargin;
 	}
 
-	if ((phdi->fmt & HDF_IMAGE) && (phdi->fmt & HDF_BITMAP_ON_RIGHT) && (infoPtr->himl)) {
-	    RECT textRect;
-	    INT  tx;    
+	if (iw || bw) {
+	    HDC hClipDC = GetDC(hwnd);
+	    HRGN hClipRgn = CreateRectRgn(r.left, r.top, r.right, r.bottom);
+	    SelectClipRgn(hClipDC, hClipRgn);
+	    
+	    if (bw) {
+	        HDC hdcBitmap = CreateCompatibleDC (hClipDC);
+	        SelectObject (hdcBitmap, phdi->hbm);
+	        BitBlt (hClipDC, bx, r.top + ((INT)rh - bmp.bmHeight) / 2, 
+		        bmp.bmWidth, bmp.bmHeight, hdcBitmap, 0, 0, SRCCOPY);
+	        DeleteDC (hdcBitmap);
+	    }
 
-	    textRect = r;
-	    if (phdi->fmt & HDF_STRING) {
-		DrawTextW (hdc, phdi->pszText, -1,
-			   &textRect, DT_LEFT|DT_VCENTER|DT_SINGLELINE|DT_CALCRECT);
-		tx = textRect.right - textRect.left;
-	    } 
-	    else
-		tx = 0;
-
-	    if (tx < (r.right-r.left - infoPtr->himl->cx - GetSystemMetrics(SM_CXEDGE)))
-		ImageList_DrawEx(infoPtr->himl, phdi->iImage, hdc, r.left + tx + 2*infoPtr->iMargin,
-				 r.top + (r.bottom-r.top-infoPtr->himl->cy)/2, infoPtr->himl->cx, r.bottom-r.top, 
-				 CLR_DEFAULT, CLR_DEFAULT, 0);
-	    else {
-		INT x = max(r.right - infoPtr->iMargin - infoPtr->himl->cx, r.left);
-		INT cx = min(infoPtr->himl->cx, r.right-r.left - GetSystemMetrics(SM_CXEDGE));
-		ImageList_DrawEx(infoPtr->himl, phdi->iImage, hdc, x ,
-				 r.top + (r.bottom-r.top-infoPtr->himl->cy)/2, cx, r.bottom-r.top, 
-				 CLR_DEFAULT, CLR_DEFAULT, 0);	
-		r.right -= infoPtr->himl->cx - infoPtr->iMargin;
+	    if (iw) {
+	        ImageList_DrawEx (infoPtr->himl, phdi->iImage, hClipDC, 
+	                          ix, r.top + ((INT)rh - infoPtr->himl->cy) / 2,
+	                          infoPtr->himl->cx, infoPtr->himl->cy, CLR_DEFAULT, CLR_DEFAULT, 0);
 	    }
-	}	
 
-        if (((phdi->fmt & HDF_STRING)
+	    DeleteObject(hClipRgn);
+	    DeleteDC(hClipDC);
+	}
+        
+	if (((phdi->fmt & HDF_STRING)
 		|| (!(phdi->fmt & (HDF_OWNERDRAW|HDF_STRING|HDF_BITMAP|
 				   HDF_BITMAP_ON_RIGHT|HDF_IMAGE)))) /* no explicit format specified? */
 	    && (phdi->pszText)) {
-            oldBkMode = SetBkMode(hdc, TRANSPARENT);
-	    r.left += infoPtr->iMargin;
-	    r.right -= infoPtr->iMargin;
+	    oldBkMode = SetBkMode(hdc, TRANSPARENT);
 	    SetTextColor (hdc, (bHotTrack) ? COLOR_HIGHLIGHT : COLOR_BTNTEXT);
+	    r.left  = tx;
+	    r.right = tx + tw;
 	    DrawTextW (hdc, phdi->pszText, -1,
-	               &r, uTextJustify|DT_END_ELLIPSIS|DT_VCENTER|DT_SINGLELINE);
+	               &r, DT_LEFT|DT_END_ELLIPSIS|DT_VCENTER|DT_SINGLELINE);
 	    if (oldBkMode != TRANSPARENT)
 	        SetBkMode(hdc, oldBkMode);
         }

Modified: trunk/reactos/lib/comctl32/hotkey.c
--- trunk/reactos/lib/comctl32/hotkey.c	2005-05-26 20:39:17 UTC (rev 15530)
+++ trunk/reactos/lib/comctl32/hotkey.c	2005-05-26 20:52:12 UTC (rev 15531)
@@ -54,7 +54,7 @@
     BYTE  CurrMod;
     INT   CaretPos;
     DWORD ScanCode;
-    WCHAR strNone[15]; /* hope its long enough ... */
+    WCHAR strNone[15]; /* hope it's long enough ... */
 } HOTKEY_INFO;
 
 static const WCHAR HOTKEY_plussep[] = { ' ', '+', ' ' };

Modified: trunk/reactos/lib/comctl32/imagelist.c
--- trunk/reactos/lib/comctl32/imagelist.c	2005-05-26 20:39:17 UTC (rev 15530)
+++ trunk/reactos/lib/comctl32/imagelist.c	2005-05-26 20:52:12 UTC (rev 15531)
@@ -98,7 +98,7 @@
  *     nothing
  *
  * NOTES
- *     This function can NOT be used to reduce the number of images.
+ *     This function CANNOT be used to reduce the number of images.
  */
 static void
 IMAGELIST_InternalExpandBitmaps (HIMAGELIST himl, INT nImageCount, INT cx, INT cy)

Modified: trunk/reactos/lib/comctl32/ipaddress.c
--- trunk/reactos/lib/comctl32/ipaddress.c	2005-05-26 20:39:17 UTC (rev 15530)
+++ trunk/reactos/lib/comctl32/ipaddress.c	2005-05-26 20:52:12 UTC (rev 15531)
@@ -62,6 +62,7 @@
 {
     HWND	Self;
     HWND	Notify;
+    BOOL	Enabled;
     IPPART_INFO	Part[4];
 } IPADDRESS_INFO;
 
@@ -127,12 +128,26 @@
     static const WCHAR dotW[] = { '.', 0 };
     RECT rect, rcPart;
     POINT pt;
+    COLORREF bgCol, fgCol;
     int i;
 
     TRACE("\n");
 
     GetClientRect (infoPtr->Self, &rect);
+
+    if (infoPtr->Enabled) {
+        bgCol = COLOR_WINDOW;
+        fgCol = COLOR_WINDOWTEXT;
+    } else {
+        bgCol = COLOR_3DFACE;
+        fgCol = COLOR_GRAYTEXT;
+    }
+    
+    FillRect (hdc, &rect, (HBRUSH) (bgCol+1));
     DrawEdge (hdc, &rect, EDGE_SUNKEN, BF_RECT | BF_ADJUST);
+    
+    SetBkColor  (hdc, GetSysColor(bgCol));
+    SetTextColor(hdc, GetSysColor(fgCol));
 
     for (i = 0; i < 3; i++) {
         GetWindowRect (infoPtr->Part[i].EditHwnd, &rcPart);
@@ -174,6 +189,7 @@
     edit.bottom = rcClient.bottom - 2;
 
     infoPtr->Self = hwnd;
+    infoPtr->Enabled = FALSE;
     infoPtr->Notify = lpCreate->hwndParent;
 
     for (i = 0; i < 4; i++) {
@@ -215,6 +231,20 @@
 }
 
 
+static LRESULT IPADDRESS_Enable (IPADDRESS_INFO *infoPtr, BOOL enabled)
+{
+    int i;
+
+    infoPtr->Enabled = enabled;
+
+    for (i = 0; i < 4; i++)
+        EnableWindow(infoPtr->Part[i].EditHwnd, enabled);
+
+    InvalidateRgn(infoPtr->Self, NULL, FALSE);
+    return 0;
+}
+
+
 static LRESULT IPADDRESS_Paint (IPADDRESS_INFO *infoPtr, HDC hdc)
 {
     PAINTSTRUCT ps;
@@ -517,6 +547,10 @@
 	case WM_DESTROY:
 	    return IPADDRESS_Destroy (infoPtr);
 
+	case WM_ENABLE:
+	    return IPADDRESS_Enable (infoPtr, (BOOL)wParam);
+	    break;
+
 	case WM_PAINT:
 	    return IPADDRESS_Paint (infoPtr, (HDC)wParam);
 

Modified: trunk/reactos/lib/comctl32/listview.c
--- trunk/reactos/lib/comctl32/listview.c	2005-05-26 20:39:17 UTC (rev 15530)
+++ trunk/reactos/lib/comctl32/listview.c	2005-05-26 20:52:12 UTC (rev 15531)
@@ -24,7 +24,7 @@
  * NOTES
  *
  * This code was audited for completeness against the documented features
- * of Comctl32.dll version 6.0 on Oct. 21, 2002, by Dimitrie O. Paun.
+ * of Comctl32.dll version 6.0 on May. 20, 2005, by James Hawkins.
  * 
  * Unless otherwise noted, we believe this code to be complete, as per
  * the specification mentioned above.
@@ -32,6 +32,17 @@
  * 
  * TODO:
  *
+ * Default Message Processing
+ *   -- EN_KILLFOCUS should be handled in WM_COMMAND
+ *   -- WM_CREATE: create the icon and small icon image lists at this point only if
+ *      the LVS_SHAREIMAGELISTS style is not specified.
+ *   -- WM_ERASEBKGND: forward this message to the parent window if the bkgnd
+ *      color is CLR_NONE.
+ *   -- WM_WINDOWPOSCHANGED: arrange the list items if the current view is icon
+ *      or small icon and the LVS_AUTOARRANGE style is specified.
+ *   -- WM_TIMER
+ *   -- WM_WININICHANGE
+ *
  * Features
  *   -- Hot item handling, mouse hovering
  *   -- Workareas support
@@ -74,6 +85,8 @@
  *   -- LVS_NOLABELWRAP
  *   -- LVS_NOSCROLL (see Q137520)
  *   -- LVS_SORTASCENDING, LVS_SORTDESCENDING
+ *   -- LVS_ALIGNTOP
+ *   -- LVS_TYPESTYLEMASK
  *
  * Extended Styles
  *   -- LVS_EX_BORDERSELECT
@@ -99,6 +112,7 @@
  *   -- LVN_ODFINDITEM
  *   -- LVN_SETDISPINFO
  *   -- NM_HOVER
+ *   -- LVN_BEGINRDRAG
  *
  * Messages:
  *   -- LVM_CANCELEDITLABEL
@@ -130,6 +144,20 @@
  *   -- LVM_SORTGROUPS
  *   -- LVM_SORTITEMSEX
  *
+ * Macros:
+ *   -- ListView_GetCheckSate, ListView_SetCheckState
+ *   -- ListView_GetHoverTime, ListView_SetHoverTime
+ *   -- ListView_GetISearchString
+ *   -- ListView_GetNumberOfWorkAreas
+ *   -- ListView_GetOrigin
+ *   -- ListView_GetTextBkColor
+ *   -- ListView_GetUnicodeFormat, ListView_SetUnicodeFormat
+ *   -- ListView_GetWorkAreas, ListView_SetWorkAreas
+ *   -- ListView_SortItemsEx
+ *
+ * Functions:
+ *   -- LVGroupComparE
+ *
  * Known differences in message stream from native control (not known if
  * these differences cause problems):
  *   LVM_INSERTITEM issues LVM_SETITEMSTATE and LVM_SETITEM in certain cases.
@@ -225,6 +253,7 @@
   HIMAGELIST himlState;
   BOOL bLButtonDown;
   BOOL bRButtonDown;
+  POINT ptClickPos;         /* point where the user clicked */ 
   BOOL bNoItemMetrics;		/* flags if item metrics are not yet computed */
   INT nItemHeight;
   INT nItemWidth;
@@ -394,6 +423,7 @@
 static BOOL LISTVIEW_EnsureVisible(LISTVIEW_INFO *, INT, BOOL);
 static HWND CreateEditLabelT(LISTVIEW_INFO *, LPCWSTR, DWORD, INT, INT, INT, INT, BOOL);
 static HIMAGELIST LISTVIEW_SetImageList(LISTVIEW_INFO *, INT, HIMAGELIST);
+static INT LISTVIEW_HitTest(LISTVIEW_INFO *, LPLVHITTESTINFO, BOOL, BOOL);
 
 /******** Text handling functions *************************************/
 
@@ -3143,7 +3173,23 @@
   return bResult;
 }
 
+static BOOL LISTVIEW_GetItemAtPt(LISTVIEW_INFO *infoPtr, LPLVITEMW lpLVItem, POINT pt)
+{
+    LVHITTESTINFO lvHitTestInfo;
 
+    ZeroMemory(&lvHitTestInfo, sizeof(lvHitTestInfo));
+    lvHitTestInfo.pt.x = pt.x;
+    lvHitTestInfo.pt.y = pt.y;
+
+    LISTVIEW_HitTest(infoPtr, &lvHitTestInfo, TRUE, FALSE);
+
+    lpLVItem->mask = LVIF_PARAM;
+    lpLVItem->iItem = lvHitTestInfo.iItem;
+    lpLVItem->iSubItem = 0;
+
+    return LISTVIEW_GetItemT(infoPtr, lpLVItem, TRUE);
+}
+
 /***
  * DESCRIPTION:
  * Called when the mouse is being actively tracked and has hovered for a specified
@@ -3164,10 +3210,18 @@
  */
 static LRESULT LISTVIEW_MouseHover(LISTVIEW_INFO *infoPtr, WORD fwKyes, INT x, INT y)
 {
-    if(infoPtr->dwLvExStyle & LVS_EX_TRACKSELECT)
-	/* FIXME: select the item!!! */
-	/*LISTVIEW_GetItemAtPt(infoPtr, pt)*/;
+    if (infoPtr->dwLvExStyle & LVS_EX_TRACKSELECT)
+    {
+        LVITEMW item;
+        POINT pt;
 
+        pt.x = x;
+        pt.y = y;
+
+        if (LISTVIEW_GetItemAtPt(infoPtr, &item, pt))
+            LISTVIEW_SetSelection(infoPtr, item.iItem);
+    }
+
     return 0;
 }
 
@@ -3185,8 +3239,25 @@
  */
 static LRESULT LISTVIEW_MouseMove(LISTVIEW_INFO *infoPtr, WORD fwKeys, INT x, INT y)
 {
-  TRACKMOUSEEVENT trackinfo;
+    TRACKMOUSEEVENT trackinfo;
 
+    if (infoPtr->bLButtonDown && DragDetect(infoPtr->hwndSelf, infoPtr->ptClickPos))
+    {
+        LVHITTESTINFO lvHitTestInfo;
+        NMLISTVIEW nmlv;
+
+        lvHitTestInfo.pt = infoPtr->ptClickPos;
+        LISTVIEW_HitTest(infoPtr, &lvHitTestInfo, TRUE, TRUE);
+
+        ZeroMemory(&nmlv, sizeof(nmlv));
+        nmlv.iItem = lvHitTestInfo.iItem;
+        nmlv.ptAction = infoPtr->ptClickPos;
+
+        notify_listview(infoPtr, LVN_BEGINDRAG, &nmlv);
+
+        return 0;
+    } 
+
   /* see if we are supposed to be tracking mouse hovering */
   if(infoPtr->dwLvExStyle & LVS_EX_TRACKSELECT) {
      /* fill in the trackinfo struct */
@@ -7492,6 +7563,25 @@
 
 /***
  * DESCRIPTION:
+ * Enables the listview control.
+ *
+ * PARAMETER(S):
+ * [I] infoPtr : valid pointer to the listview structure
+ * [I] bEnable : specifies whether to enable or disable the window
+ *
+ * RETURN:
+ *   SUCCESS : TRUE
+ *   FAILURE : FALSE
+ */
+static BOOL LISTVIEW_Enable(LISTVIEW_INFO *infoPtr, BOOL bEnable)
+{
+    if (infoPtr->dwStyle & LVS_OWNERDRAWFIXED)
+        InvalidateRect(infoPtr->hwndSelf, NULL, TRUE);
+    return TRUE;
+}
+
+/***
+ * DESCRIPTION:
  * Erases the background of the listview control.
  *
  * PARAMETER(S):
@@ -7905,70 +7995,8 @@
     return 0;
 }
 
-
 /***
  * DESCRIPTION:
- * Track mouse/dragging
- *
- * PARAMETER(S):
- * [I] infoPtr : valid pointer to the listview structure
- * [I] pt : mouse coordinate
- *
- * RETURN:
- * Zero
- */
-static LRESULT LISTVIEW_TrackMouse(LISTVIEW_INFO *infoPtr, POINT pt)
-{
-    INT cxDrag = GetSystemMetrics(SM_CXDRAG);
-    INT cyDrag = GetSystemMetrics(SM_CYDRAG);
-    RECT r;
-    MSG msg;
-
-    TRACE("\n");
-
-    r.top = pt.y - cyDrag;
-    r.left = pt.x - cxDrag;
-    r.bottom = pt.y + cyDrag;
-    r.right = pt.x + cxDrag;
-
-    SetCapture(infoPtr->hwndSelf);
-
-    while (1)
-    {
-	if (PeekMessageW(&msg, 0, 0, 0, PM_REMOVE | PM_NOYIELD))
-	{
-	    if (msg.message == WM_MOUSEMOVE)
-	    {
-		pt.x = (short)LOWORD(msg.lParam);
-		pt.y = (short)HIWORD(msg.lParam);
-		if (PtInRect(&r, pt))
-		    continue;
-		else
-		{
-		    ReleaseCapture();
-		    return 1;
-		}
-	    }
-	    else if (msg.message >= WM_LBUTTONDOWN &&
-		     msg.message <= WM_RBUTTONDBLCLK)
-	    {
-		break;
-	    }
-
-	    DispatchMessageW(&msg);
-	}
-
-	if (GetCapture() != infoPtr->hwndSelf)
-	    return 0;
-    }
-
-    ReleaseCapture();
-    return 0;
-}
-
-
-/***
- * DESCRIPTION:
  * Processes double click messages (left mouse button).
  *
  * PARAMETER(S):
@@ -8027,8 +8055,9 @@
 
   if (!infoPtr->bFocus) SetFocus(infoPtr->hwndSelf);
 
-  /* set left button down flag */
+  /* set left button down flag and record the click position */
   infoPtr->bLButtonDown = TRUE;
+  infoPtr->ptClickPos = pt;
 
   lvHitTestInfo.pt.x = x;
   lvHitTestInfo.pt.y = y;
@@ -8051,20 +8080,7 @@
         }
         return 0;
     }
-    if (LISTVIEW_TrackMouse(infoPtr, lvHitTestInfo.pt))
-    {
-        NMLISTVIEW nmlv;
 
-	ZeroMemory(&nmlv, sizeof(nmlv));
-        nmlv.iItem = nItem;
-        nmlv.ptAction.x = lvHitTestInfo.pt.x;
-        nmlv.ptAction.y = lvHitTestInfo.pt.y;
-
-        notify_listview(infoPtr, LVN_BEGINDRAG, &nmlv);
-
-        return 0;
-    }
-
     if (infoPtr->dwStyle & LVS_SINGLESEL)
     {
       if (LISTVIEW_GetItemState(infoPtr, nItem, LVIS_SELECTED))
@@ -8292,6 +8308,11 @@
             notify_listview(infoPtr, LVN_COLUMNCLICK, &nmlv);
         }
 	break;
+
+	case HDN_DIVIDERDBLCLICKW:
+	case HDN_DIVIDERDBLCLICKA:
+            LISTVIEW_SetColumnWidth(infoPtr, lpnmh->iItem, LVSCW_AUTOSIZE);
+            break;
     }
 
     return 0;
@@ -8621,7 +8642,7 @@
 {
     TRACE("infoPtr->bRedraw=%d, bRedraw=%d\n", infoPtr->bRedraw, bRedraw);
 
-    /* we can not use straight equality here because _any_ non-zero value is TRUE */
+    /* we cannot use straight equality here because _any_ non-zero value is TRUE */
     if ((infoPtr->bRedraw && bRedraw) || (!infoPtr->bRedraw && !bRedraw)) return 0;
 
     infoPtr->bRedraw = bRedraw;
@@ -9194,6 +9215,9 @@
   case WM_CREATE:
     return LISTVIEW_Create(hwnd, (LPCREATESTRUCTW)lParam);
 
+  case WM_ENABLE:
+    return LISTVIEW_Enable(infoPtr, (BOOL)wParam);
+
   case WM_ERASEBKGND:
     return LISTVIEW_EraseBkgnd(infoPtr, (HDC)wParam);
 

Modified: trunk/reactos/lib/comctl32/monthcal.c
--- trunk/reactos/lib/comctl32/monthcal.c	2005-05-26 20:39:17 UTC (rev 15530)
+++ trunk/reactos/lib/comctl32/monthcal.c	2005-05-26 20:52:12 UTC (rev 15531)
@@ -473,29 +473,23 @@
   SetTextColor(hdc, infoPtr->titletxt);
   currentFont = SelectObject(hdc, infoPtr->hBoldFont);
 
-  /* titlemonth->left and right are set in MONTHCAL_UpdateSize */
-  titlemonth->left   = title->left;
-  titlemonth->right  = title->right;
-
   GetLocaleInfoW( LOCALE_USER_DEFAULT,LOCALE_SMONTHNAME1+infoPtr->currentMonth -1,
 		  buf1,countof(buf1));
   wsprintfW(buf, fmt1W, buf1, infoPtr->currentYear);
 
-  if(IntersectRect(&rcTemp, &(ps->rcPaint), titlemonth))
+  if(IntersectRect(&rcTemp, &(ps->rcPaint), title))
   {
-    DrawTextW(hdc, buf, strlenW(buf), titlemonth,
+    DrawTextW(hdc, buf, strlenW(buf), title,
                         DT_CENTER | DT_VCENTER | DT_SINGLELINE);
   }
 
-  SelectObject(hdc, infoPtr->hFont);
-
 /* titlemonth left/right contained rect for whole titletxt('June  1999')
   * MCM_HitTestInfo wants month & year rects, so prepare these now.
   *(no, we can't draw them separately; the whole text is centered)
   */
   GetTextExtentPoint32W(hdc, buf, strlenW(buf), &size);
-  titlemonth->left = title->right / 2 - size.cx / 2;
-  titleyear->right = title->right / 2 + size.cx / 2;
+  titlemonth->left = title->right / 2 + title->left / 2 - size.cx / 2;
+  titleyear->right = title->right / 2 + title->left / 2 + size.cx / 2;
   GetTextExtentPoint32W(hdc, buf1, strlenW(buf1), &size);
   titlemonth->right = titlemonth->left + size.cx;
   titleyear->left = titlemonth->right;
@@ -524,6 +518,7 @@
   infoPtr->wdays.left   = infoPtr->days.left   = infoPtr->weeknums.right;
 /* draw day abbreviations */
 
+  SelectObject(hdc, infoPtr->hFont);
   SetBkColor(hdc, infoPtr->monthbk);
   SetTextColor(hdc, infoPtr->trailingtxt);
 
@@ -673,9 +668,9 @@
     wsprintfW(buf, fmt2W, buf1, buf2);
     SelectObject(hdc, infoPtr->hBoldFont);
 
+    DrawTextW(hdc, buf, -1, &rtoday, DT_CALCRECT | DT_LEFT | DT_VCENTER | DT_SINGLELINE);
     if(IntersectRect(&rcTemp, &(ps->rcPaint), &rtoday))
     {
-      DrawTextW(hdc, buf, -1, &rtoday, DT_CALCRECT | DT_LEFT | DT_VCENTER | DT_SINGLELINE);
       DrawTextW(hdc, buf, -1, &rtoday, DT_LEFT | DT_VCENTER | DT_SINGLELINE);
     }
     SelectObject(hdc, infoPtr->hFont);
@@ -1424,18 +1419,19 @@
 			   0,
 			 WS_VISIBLE | WS_CHILD |UDS_SETBUDDYINT,
 			 infoPtr->titleyear.left+3,infoPtr->titlebtnnext.top,
-			 infoPtr->titleyear.right-infoPtr->titleyear.left,
+			 infoPtr->titleyear.right-infoPtr->titleyear.left+4,
 			 infoPtr->textHeight,
 			 infoPtr->hwndSelf,
 			 NULL,
 			 NULL,
 			 NULL);
+    SendMessageW( infoPtr->hWndYearEdit, WM_SETFONT, (WPARAM) infoPtr->hBoldFont, (LPARAM)TRUE);
     infoPtr->hWndYearUpDown=CreateWindowExW(0,
 			 UPDOWN_CLASSW,
 			   0,
 			 WS_VISIBLE | WS_CHILD |UDS_SETBUDDYINT|UDS_NOTHOUSANDS|UDS_ARROWKEYS,
-			 infoPtr->titleyear.right+6,infoPtr->titlebtnnext.top,
-			 20,
+			 infoPtr->titleyear.right+7,infoPtr->titlebtnnext.top,
+			 18,
 			 infoPtr->textHeight,
 			 infoPtr->hwndSelf,
 			 NULL,
@@ -1733,7 +1729,7 @@
 
   xdiv = (dwStyle & MCS_WEEKNUMBERS) ? 8 : 7;
 
-  infoPtr->width_increment = size.cx * 2;
+  infoPtr->width_increment = size.cx * 2 + 4;
   infoPtr->height_increment = infoPtr->textHeight;
   left_offset = (rcClient.right - rcClient.left) - (infoPtr->width_increment * xdiv);
 
@@ -1852,7 +1848,7 @@
   /* initialize info structure */
   /* FIXME: calculate systemtime ->> localtime(substract timezoneinfo) */
 
-  GetSystemTime(&infoPtr->todaysDate);
+  GetLocalTime(&infoPtr->todaysDate);
   MONTHCAL_SetFirstDayOfWeek(infoPtr, (LPARAM)-1);
   infoPtr->currentMonth = infoPtr->todaysDate.wMonth;
   infoPtr->currentYear = infoPtr->todaysDate.wYear;

Modified: trunk/reactos/lib/comctl32/tab.c
--- trunk/reactos/lib/comctl32/tab.c	2005-05-26 20:39:17 UTC (rev 15530)
+++ trunk/reactos/lib/comctl32/tab.c	2005-05-26 20:52:12 UTC (rev 15531)
@@ -1727,12 +1727,12 @@
       else
         drawRect->bottom-=center_offset_h;
 
-      center_offset_v = ((drawRect->right - drawRect->left) - ((rcText.bottom - rcText.top) + infoPtr->uVItemPadding)) / 2;
+      center_offset_v = ((drawRect->right - drawRect->left) - (rcText.bottom - rcText.top) + infoPtr->uVItemPadding) / 2;
     }
     else
     {
       drawRect->left += center_offset_h;
-      center_offset_v = ((drawRect->bottom - drawRect->top) - ((rcText.bottom - rcText.top) + infoPtr->uVItemPadding)) / 2;
+      center_offset_v = ((drawRect->bottom - drawRect->top) - (rcText.bottom - rcText.top) + infoPtr->uVItemPadding) / 2;
     }
 
     if (center_offset_v < 0)
@@ -2961,9 +2961,16 @@
   return 0;
 }
 
+static LRESULT TAB_NCCalcSize(HWND hwnd, WPARAM wParam, LPARAM lParam)
+{
+  if (!wParam)
+    return 0;
+  return WVR_ALIGNTOP;
+}
+
 static inline LRESULT
 TAB_SetItemExtra (TAB_INFO *infoPtr, INT cbInfo)
-{   
+{
   if (!infoPtr || cbInfo <= 0)
     return FALSE;
 
@@ -3143,6 +3150,9 @@
     case WM_NCHITTEST:
       return TAB_NCHitTest(infoPtr, lParam);
 
+    case WM_NCCALCSIZE:
+      return TAB_NCCalcSize(hwnd, wParam, lParam);
+
     default:
       if (uMsg >= WM_USER && uMsg < WM_APP)
 	WARN("unknown msg %04x wp=%08x lp=%08lx\n",

Modified: trunk/reactos/lib/comctl32/toolbar.c
--- trunk/reactos/lib/comctl32/toolbar.c	2005-05-26 20:39:17 UTC (rev 15530)
+++ trunk/reactos/lib/comctl32/toolbar.c	2005-05-26 20:52:12 UTC (rev 15531)
@@ -6233,7 +6233,7 @@
      * forgets to specify TBSTYLE_TRANSPARENT but does specify either
      * CCS_TOP or CCS_BOTTOM (_NOMOVEY and _TOP), then the control
      * does *not* set TBSTYLE_TRANSPARENT even though it should!!!!
-     * Some how, the only cases of this seem to be MFC programs.
+     * Somehow, the only cases of this seem to be MFC programs.
      *
      * Note also that the addition of _TRANSPARENT occurs *only* here. It
      * does not occur in the WM_STYLECHANGING routine.

Modified: trunk/reactos/lib/comctl32/updown.c
--- trunk/reactos/lib/comctl32/updown.c	2005-05-26 20:39:17 UTC (rev 15530)
+++ trunk/reactos/lib/comctl32/updown.c	2005-05-26 20:52:12 UTC (rev 15531)
@@ -775,9 +775,12 @@
 	    break;
 
 	case WM_ENABLE:
-	    infoPtr->dwStyle &= ~WS_DISABLED;
-	    infoPtr->dwStyle |= (wParam ? 0 : WS_DISABLED);
-	    if (infoPtr->dwStyle & WS_DISABLED) UPDOWN_CancelMode (infoPtr);
+	    if (wParam) {
+		infoPtr->dwStyle &= ~WS_DISABLED;
+	    } else {
+		infoPtr->dwStyle |= WS_DISABLED;
+	    	UPDOWN_CancelMode (infoPtr);
+	    }
 	    InvalidateRect (infoPtr->Self, NULL, FALSE);
 	    break;