Index: trunk/src/comctl32/trackbar.c
===================================================================
--- trunk/src/comctl32/trackbar.c	(revision 537)
+++ trunk/src/comctl32/trackbar.c	(revision 538)
@@ -1,3 +1,3 @@
-/* $Id: trackbar.c,v 1.12 1999-08-14 16:13:15 cbratschi Exp $ */
+/* $Id: trackbar.c,v 1.13 1999-08-17 21:13:57 cbratschi Exp $ */
 /*
  * Trackbar control
@@ -12,6 +12,5 @@
  *
  *   - more notifications. (CB: should be complete)
- *   - TRACKBAR_UpdateThumb, TRACKBAR_UpdateThumbPosition:
- *     use a memory dc to avoid flickering by short movements
+ *   - Status: ready to use
  */
 
@@ -22,5 +21,5 @@
 
 
-#define TRACKBAR_GetInfoPtr(wndPtr) ((TRACKBAR_INFO *)GetWindowLongA (hwnd,0))
+#define TRACKBAR_GetInfoPtr(hwnd) ((TRACKBAR_INFO*)GetWindowLongA(hwnd,0))
 
 
@@ -730,11 +729,12 @@
 //update thumb position
 
-static VOID TRACKBAR_UpdateThumbPosition(HWND hwnd,INT lastPos)
+static VOID TRACKBAR_UpdateThumbPosition(HWND hwnd,INT lastPos,BOOL mustRedraw)
 {
    HDC hdc;
    TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr(hwnd);
    DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
-   RECT lastRect,newRect;
-   HRGN hrgn,hrgnLast,hrgnNew;
+   RECT lastRect,newRect,windowRect;
+   HDC hdcCompatible;
+   HBITMAP bitmap,oldbmp;
 
    //last
@@ -755,4 +755,6 @@
    newRect = infoPtr->rcFullThumb;
 
+   //same rect?
+   if (!mustRedraw && EqualRect(&lastRect,&newRect)) return;
 
    //3D frame adjustation
@@ -762,15 +764,37 @@
    newRect.bottom++;
 
+   //BitBlt from memory -> no flickering
+   GetClientRect(hwnd,&windowRect);
    hdc = GetDC(hwnd);
-   hrgnLast = CreateRectRgnIndirect(&lastRect);
-   hrgnNew = CreateRectRgnIndirect(&newRect);
-   hrgn = CreateRectRgn(0,0,0,0);
-   CombineRgn(hrgn,hrgnLast,hrgnNew,RGN_OR);
-   SelectClipRgn(hdc,hrgn);
-   TRACKBAR_Draw(hwnd,hdc);
-   SelectClipRgn(hdc,0);
-   DeleteObject(hrgnLast);
-   DeleteObject(hrgnNew);
-   DeleteObject(hrgn);
+   hdcCompatible = CreateCompatibleDC(hdc);
+   bitmap = CreateCompatibleBitmap(hdc,windowRect.right,windowRect.bottom);
+   oldbmp = SelectObject(hdcCompatible,bitmap);
+   TRACKBAR_Draw(hwnd,hdcCompatible);
+   if (dwStyle & TBS_VERT)
+   {
+     if (lastRect.top > newRect.top && lastRect.top < newRect.bottom)
+       BitBlt(hdc,newRect.left,newRect.top,newRect.right-newRect.left,lastRect.bottom-newRect.top,hdcCompatible,newRect.left,newRect.top,SRCCOPY);
+     else if (lastRect.bottom < newRect.bottom && lastRect.bottom > newRect.top)
+       BitBlt(hdc,lastRect.left,lastRect.top,lastRect.right-lastRect.left,newRect.bottom-lastRect.top,hdcCompatible,lastRect.left,lastRect.top,SRCCOPY);
+     else
+     {
+       BitBlt(hdc,lastRect.left,lastRect.top,lastRect.right-lastRect.left,lastRect.bottom-lastRect.top,hdcCompatible,lastRect.left,lastRect.top,SRCCOPY);
+       BitBlt(hdc,newRect.left,newRect.top,newRect.right-newRect.left,newRect.bottom-newRect.top,hdcCompatible,newRect.left,newRect.top,SRCCOPY);
+     }
+   } else
+   {
+     if (lastRect.right > newRect.left && lastRect.right < newRect.right)
+       BitBlt(hdc,lastRect.left,lastRect.top,newRect.right-lastRect.left,lastRect.bottom-lastRect.top,hdcCompatible,lastRect.left,lastRect.top,SRCCOPY);
+     else if (lastRect.left < newRect.right && lastRect.left > newRect.left)
+       BitBlt(hdc,newRect.left,newRect.top,lastRect.right-newRect.left,newRect.bottom-newRect.top,hdcCompatible,newRect.left,newRect.top,SRCCOPY);
+     else
+     {
+       BitBlt(hdc,lastRect.left,lastRect.top,lastRect.right-lastRect.left,lastRect.bottom-lastRect.top,hdcCompatible,lastRect.left,lastRect.top,SRCCOPY);
+       BitBlt(hdc,newRect.left,newRect.top,newRect.right-newRect.left,newRect.bottom-newRect.top,hdcCompatible,newRect.left,newRect.top,SRCCOPY);
+     }
+   }
+   SelectObject(hdcCompatible,oldbmp);
+   DeleteObject(bitmap);
+   DeleteDC(hdcCompatible);
    ReleaseDC(hwnd,hdc);
 }
@@ -1143,5 +1167,5 @@
     infoPtr->flags |= TB_THUMBPOSCHANGED;
 
-    if (wParam) TRACKBAR_UpdateThumbPosition(hwnd,lastPos);
+    if (wParam) TRACKBAR_UpdateThumbPosition(hwnd,lastPos,FALSE);
 
     return 0;
@@ -1695,5 +1719,5 @@
     {
       infoPtr->flags |= TB_THUMBPOSCHANGED;
-      TRACKBAR_UpdateThumbPosition(hwnd,prevPos);
+      TRACKBAR_UpdateThumbPosition(hwnd,prevPos,TRUE);
     }
 
@@ -1781,5 +1805,5 @@
     {
       infoPtr->flags |= TB_THUMBPOSCHANGED;
-      TRACKBAR_UpdateThumbPosition(hwnd,prevPos);
+      TRACKBAR_UpdateThumbPosition(hwnd,prevPos,FALSE);
     }
 
@@ -1796,5 +1820,5 @@
       int lastPos = infoPtr->nPos;
       infoPtr->nPos = infoPtr->dragPos;
-      if (lastPos != infoPtr->nPos) TRACKBAR_UpdateThumbPosition(hwnd,lastPos);
+      if (lastPos != infoPtr->nPos) TRACKBAR_UpdateThumbPosition(hwnd,lastPos,TRUE);
     }
 
@@ -1919,5 +1943,5 @@
     infoPtr->flags |= TB_DRAGPOSVALID;
 
-    TRACKBAR_UpdateThumbPosition(hwnd,infoPtr->nPos); //infoPtr->nPos now set
+    TRACKBAR_UpdateThumbPosition(hwnd,infoPtr->nPos,FALSE); //infoPtr->nPos now set
 
     TRACKBAR_SendNotify(hwnd,TB_THUMBTRACK | (infoPtr->nPos >> 16));
@@ -2003,5 +2027,5 @@
     {
       infoPtr->flags |= TB_THUMBPOSCHANGED;
-      TRACKBAR_UpdateThumbPosition(hwnd,pos);
+      TRACKBAR_UpdateThumbPosition(hwnd,pos,FALSE);
     }
 
