Index: sdk/include/psdk/uxtheme.h
===================================================================
--- sdk/include/psdk/uxtheme.h	(revision 72511)
+++ sdk/include/psdk/uxtheme.h	(working copy)
@@ -37,6 +37,44 @@
 #define OTD_NONCLIENT               0x0002
 #define OTD_VALIDBITS               (OTD_FORCE_RECT_SIZING | OTD_NONCLIENT)
 
+/* DTTOPTS.dwFlags bits */
+#define DTT_TEXTCOLOR    0x00000001
+#define DTT_BORDERCOLOR  0x00000002
+#define DTT_SHADOWCOLOR  0x00000004
+#define DTT_SHADOWTYPE   0x00000008
+#define DTT_SHADOWOFFSET 0x00000010
+#define DTT_BORDERSIZE   0x00000020
+#define DTT_FONTPROP     0x00000040
+#define DTT_COLORPROP    0x00000080
+#define DTT_STATEID      0x00000100
+#define DTT_CALCRECT     0x00000200
+#define DTT_APPLYOVERLAY 0x00000400
+#define DTT_GLOWSIZE     0x00000800
+#define DTT_CALLBACK     0x00001000
+#define DTT_COMPOSITED   0x00002000
+#define DTT_VALIDBITS    0x00003fff
+
+typedef int (WINAPI *DTT_CALLBACK_PROC)(HDC,LPWSTR,int,RECT*,UINT,LPARAM);
+
+typedef struct _DTTOPTS {
+    DWORD dwSize;
+    DWORD dwFlags;
+    COLORREF crText;
+    COLORREF crBorder;
+    COLORREF crShadow;
+    int iTextShadowType;
+    POINT ptShadowOffset;
+    int iBorderSize;
+    int iFontPropId;
+    int iColorPropId;
+    int iStateId;
+    BOOL fApplyOverlay;
+    int iGlowSize;
+    DTT_CALLBACK_PROC pfnDrawTextCallback;
+    LPARAM lParam;
+} DTTOPTS, *PDTTOPTS;
+
+
 typedef HANDLE HPAINTBUFFER;
 typedef HANDLE HTHEME;
 
@@ -90,6 +128,31 @@
     int cyBottomHeight;
 } MARGINS, *PMARGINS;
 
+typedef HANDLE HANIMATIONBUFFER;
+
+typedef enum _BP_ANIMATIONSTYLE
+{
+    BPAS_NONE,
+    BPAS_LINEAR,
+    BPAS_CUBIC,
+    BPAS_SINE
+} BP_ANIMATIONSTYLE;
+
+typedef struct _BP_ANIMATIONPARAMS
+{
+    DWORD cbSize;
+    DWORD dwFlags;
+    BP_ANIMATIONSTYLE style;
+    DWORD dwDuration;
+} BP_ANIMATIONPARAMS, *PBP_ANIMATIONPARAMS;
+
+
+HPAINTBUFFER WINAPI BeginBufferedPaint(HDC, const RECT *, BP_BUFFERFORMAT, BP_PAINTPARAMS *,HDC *);
+HRESULT WINAPI BufferedPaintClear(HPAINTBUFFER, const RECT *);
+HRESULT WINAPI BufferedPaintSetAlpha(HPAINTBUFFER, const RECT *, BYTE);
+HANIMATIONBUFFER WINAPI BeginBufferedAnimation(HWND, HDC, const RECT *, BP_BUFFERFORMAT, BP_PAINTPARAMS *, BP_ANIMATIONPARAMS *, HDC *, HDC *);
+BOOL WINAPI BufferedPaintRenderAnimation(HWND, HDC);
+HRESULT WINAPI BufferedPaintStopAllAnimations(HWND);
 HRESULT WINAPI CloseThemeData(HTHEME);
 HRESULT WINAPI DrawThemeBackground(HTHEME,HDC,int,int,const RECT*,const RECT*);
 HRESULT WINAPI DrawThemeBackgroundEx(HTHEME,HDC,int,int,const RECT*,const DTBGOPTS*);
@@ -97,8 +160,15 @@
 HRESULT WINAPI DrawThemeIcon(HTHEME,HDC,int,int,const RECT*,HIMAGELIST,int);
 HRESULT WINAPI DrawThemeParentBackground(HWND,HDC,RECT*);
 HRESULT WINAPI DrawThemeText(HTHEME,HDC,int,int,LPCWSTR,int,DWORD,DWORD,const RECT*);
+HRESULT WINAPI DrawThemeTextEx(HTHEME,HDC,int,int,LPCWSTR,int,DWORD,RECT*,const DTTOPTS*);
+HRESULT WINAPI EndBufferedAnimation(HANIMATIONBUFFER, BOOL);
+HRESULT WINAPI EndBufferedPaint(HPAINTBUFFER, BOOL);
 HRESULT WINAPI EnableThemeDialogTexture(HWND,DWORD);
 HRESULT WINAPI EnableTheming(BOOL);
+HRESULT WINAPI GetBufferedPaintBits(HPAINTBUFFER, RGBQUAD **, int *);
+HDC WINAPI GetBufferedPaintDC(HPAINTBUFFER);
+HDC WINAPI GetBufferedPaintTargetDC(HPAINTBUFFER);
+HRESULT WINAPI GetBufferedPaintTargetRect(HPAINTBUFFER, RECT *prc);
 HRESULT WINAPI GetCurrentThemeName(LPWSTR,int,LPWSTR,int,LPWSTR,int);
 DWORD WINAPI GetThemeAppProperties(void);
 HRESULT WINAPI GetThemeBackgroundContentRect(HTHEME,HDC,int,int,const RECT*,RECT*);
@@ -128,6 +198,7 @@
 HRESULT WINAPI GetThemeSysString(HTHEME,int,LPWSTR,int);
 HRESULT WINAPI GetThemeTextExtent(HTHEME,HDC,int,int,LPCWSTR,int,DWORD,const RECT*,RECT*);
 HRESULT WINAPI GetThemeTextMetrics(HTHEME,HDC,int,int,TEXTMETRICW*);
+HRESULT WINAPI GetThemeTransitionDuration(HTHEME,int,int,int,int,DWORD*);
 HTHEME WINAPI GetWindowTheme(HWND);
 HRESULT WINAPI HitTestThemeBackground(HTHEME,HDC,int,int,DWORD,const RECT*,HRGN,POINT,WORD*);
 BOOL WINAPI IsAppThemed(void);
Index: dll/win32/uxtheme/buffer.c
===================================================================
--- dll/win32/uxtheme/buffer.c	(revision 72511)
+++ dll/win32/uxtheme/buffer.c	(working copy)
@@ -67,3 +67,102 @@
     FIXME("Stub (%p %d)\n", hPaintBuffer, fUpdateTarget);
     return S_OK;
 }
+
+/***********************************************************************
+ *      BufferedPaintClear                                 (UXTHEME.@)
+ */
+HRESULT WINAPI BufferedPaintClear(HPAINTBUFFER hBufferedPaint, const RECT *prc)
+{
+    FIXME("Stub (%p %p)\n", hBufferedPaint, prc);
+    return E_NOTIMPL;
+}
+
+/***********************************************************************
+ *      BufferedPaintSetAlpha                              (UXTHEME.@)
+ */
+HRESULT WINAPI BufferedPaintSetAlpha(HPAINTBUFFER hBufferedPaint, const RECT *prc, BYTE alpha)
+{
+    FIXME("Stub (%p %p %u)\n", hBufferedPaint, prc, alpha);
+    return E_NOTIMPL;
+}
+
+/***********************************************************************
+ *      GetBufferedPaintBits                               (UXTHEME.@)
+ */
+HRESULT WINAPI GetBufferedPaintBits(HPAINTBUFFER hBufferedPaint, RGBQUAD **ppbBuffer,
+                                    int *pcxRow)
+{
+    FIXME("Stub (%p %p %p)\n", hBufferedPaint, ppbBuffer, pcxRow);
+    return E_NOTIMPL;
+}
+
+/***********************************************************************
+ *      GetBufferedPaintDC                                 (UXTHEME.@)
+ */
+HDC WINAPI GetBufferedPaintDC(HPAINTBUFFER hBufferedPaint)
+{
+    FIXME("Stub (%p)\n", hBufferedPaint);
+    return NULL;
+}
+
+/***********************************************************************
+ *      GetBufferedPaintTargetDC                           (UXTHEME.@)
+ */
+HDC WINAPI GetBufferedPaintTargetDC(HPAINTBUFFER hBufferedPaint)
+{
+    FIXME("Stub (%p)\n", hBufferedPaint);
+    return NULL;
+}
+
+/***********************************************************************
+ *      GetBufferedPaintTargetRect                         (UXTHEME.@)
+ */
+HRESULT WINAPI GetBufferedPaintTargetRect(HPAINTBUFFER hBufferedPaint, RECT *prc)
+{
+    FIXME("Stub (%p %p)\n", hBufferedPaint, prc);
+    return E_NOTIMPL;
+}
+
+/***********************************************************************
+ *      BeginBufferedAnimation                             (UXTHEME.@)
+ */
+HANIMATIONBUFFER WINAPI BeginBufferedAnimation(HWND hwnd, HDC hdcTarget, const RECT *rcTarget,
+                                               BP_BUFFERFORMAT dwFormat, BP_PAINTPARAMS *pPaintParams,
+                                               BP_ANIMATIONPARAMS *pAnimationParams, HDC *phdcFrom,
+                                               HDC *phdcTo)
+{
+    FIXME("Stub (%p %p %p %u %p %p %p %p)\n", hwnd, hdcTarget, rcTarget, dwFormat,
+          pPaintParams, pAnimationParams, phdcFrom, phdcTo);
+
+    return NULL;
+}
+
+/***********************************************************************
+ *      BufferedPaintRenderAnimation                       (UXTHEME.@)
+ */
+BOOL WINAPI BufferedPaintRenderAnimation(HWND hwnd, HDC hdcTarget)
+{
+    FIXME("Stub (%p %p)\n", hwnd, hdcTarget);
+
+    return FALSE;
+}
+
+/***********************************************************************
+ *      BufferedPaintStopAllAnimations                     (UXTHEME.@)
+ */
+HRESULT WINAPI BufferedPaintStopAllAnimations(HWND hwnd)
+{
+    FIXME("Stub (%p)\n", hwnd);
+
+    return E_NOTIMPL;
+}
+
+/***********************************************************************
+ *      EndBufferedAnimation                               (UXTHEME.@)
+ */
+HRESULT WINAPI EndBufferedAnimation(HANIMATIONBUFFER hbpAnimation, BOOL fUpdateTarget)
+{
+    FIXME("Stub (%p %u)\n", hbpAnimation, fUpdateTarget);
+
+    return E_NOTIMPL;
+}
Index: dll/win32/uxtheme/draw.c
===================================================================
--- dll/win32/uxtheme/draw.c	(revision 72511)
+++ dll/win32/uxtheme/draw.c	(working copy)
@@ -82,9 +82,9 @@
     if(!hParent)
         hParent = hwnd;
     if(prc) {
-        CopyRect(&rt, prc);
+        rt = *prc;
         MapWindowPoints(hwnd, hParent, (LPPOINT)&rt, 2);
-        
+
         clip = CreateRectRgn(0,0,1,1);
         hasClip = GetClipRgn(hdc, clip);
         if(hasClip == -1)
@@ -126,7 +126,7 @@
     opts.dwFlags = 0;
     if(pClipRect) {
         opts.dwFlags |= DTBG_CLIPRECT;
-        CopyRect(&opts.rcClip, pClipRect);
+        opts.rcClip = *pClipRect;
     }
     return DrawThemeBackgroundEx(hTheme, hdc, iPartId, iStateId, pRect, &opts);
 }
@@ -562,7 +562,7 @@
                 int sizingtype = ST_STRETCH;
                 BOOL uniformsizing = FALSE;
 
-                CopyRect(&rcDst, prc);
+                rcDst = *prc;
 
                 dstSize.x = rcDst.right-rcDst.left;
                 dstSize.y = rcDst.bottom-rcDst.top;
@@ -1621,9 +1621,30 @@
  *      DrawThemeText                                       (UXTHEME.@)
  */
 HRESULT WINAPI DrawThemeText(HTHEME hTheme, HDC hdc, int iPartId, int iStateId,
-                             LPCWSTR pszText, int iCharCount, DWORD dwTextFlags,
-                             DWORD dwTextFlags2, const RECT *pRect)
+                             LPCWSTR pszText, int iCharCount, DWORD flags,
+                             DWORD flags2, const RECT *pRect)
 {
+    DTTOPTS opts;
+    RECT rt;
+
+    TRACE("%d %d\n", iPartId, iStateId);
+
+    CopyRect(&rt, pRect);
+
+    opts.dwSize = sizeof(opts);
+    if (flags2 & DTT_GRAYED) {
+        opts.dwFlags = DTT_TEXTCOLOR;
+        opts.crText = GetSysColor(COLOR_GRAYTEXT);
+    }
+    return DrawThemeTextEx(hTheme, hdc, iPartId, iStateId, pszText, iCharCount, flags, &rt, &opts);
+}
+
+/***********************************************************************
+ *      DrawThemeTextEx                                     (UXTHEME.@)
+ */
+HRESULT WINAPI DrawThemeTextEx(HTHEME hTheme, HDC hdc, int iPartId, int iStateId,
+    LPCWSTR pszText, int iCharCount, DWORD flags, RECT *rect, const DTTOPTS *options)
+{
     HRESULT hr;
     HFONT hFont = NULL;
     HGDIOBJ oldFont = NULL;
@@ -1631,11 +1652,15 @@
     COLORREF textColor;
     COLORREF oldTextColor;
     int oldBkMode;
-    RECT rt;
-    
-    TRACE("%d %d: stub\n", iPartId, iStateId);
+
+    TRACE("%p %p %d %d %s:%d 0x%08x %p %p\n", hTheme, hdc, iPartId, iStateId,
+        debugstr_wn(pszText, iCharCount), iCharCount, flags, rect, options);
+
     if(!hTheme)
         return E_HANDLE;
+
+    if (options->dwFlags & ~DTT_TEXTCOLOR)
+        FIXME("unsupported flags 0x%08x\n", options->dwFlags);
     
     hr = GetThemeFont(hTheme, hdc, iPartId, iStateId, TMT_FONT, &logfont);
     if(SUCCEEDED(hr)) {
@@ -1643,12 +1668,12 @@
         if(!hFont)
             TRACE("Failed to create font\n");
     }
-    CopyRect(&rt, pRect);
+
     if(hFont)
         oldFont = SelectObject(hdc, hFont);
-        
-    if(dwTextFlags2 & DTT_GRAYED)
-        textColor = GetSysColor(COLOR_GRAYTEXT);
+
+    if (options->dwFlags & DTT_TEXTCOLOR)
+        textColor = options->crText;
     else {
         if(FAILED(GetThemeColor(hTheme, iPartId, iStateId, TMT_TEXTCOLOR, &textColor)))
             textColor = GetTextColor(hdc);
@@ -1655,7 +1680,7 @@
     }
     oldTextColor = SetTextColor(hdc, textColor);
     oldBkMode = SetBkMode(hdc, TRANSPARENT);
-    DrawTextW(hdc, pszText, iCharCount, &rt, dwTextFlags);
+    DrawTextW(hdc, pszText, iCharCount, rect, flags);
     SetBkMode(hdc, oldBkMode);
     SetTextColor(hdc, oldTextColor);
 
@@ -1710,7 +1735,7 @@
         /* If nothing was found, leave unchanged */
     }
 
-    TRACE("left:%d,top:%d,right:%d,bottom:%d\n", pContentRect->left, pContentRect->top, pContentRect->right, pContentRect->bottom);
+    TRACE("%s\n", wine_dbgstr_rect(pContentRect));
 
     return S_OK;
 }
@@ -1758,152 +1783,121 @@
         /* If nothing was found, leave unchanged */
     }
 
-    TRACE("left:%d,top:%d,right:%d,bottom:%d\n", pExtentRect->left, pExtentRect->top, pExtentRect->right, pExtentRect->bottom);
+    TRACE("%s\n", wine_dbgstr_rect(pExtentRect));
 
     return S_OK;
 }
 
-
-static HBITMAP UXTHEME_DrawThemePartToDib(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, LPCRECT pRect)
+static inline void flush_rgn_data( HRGN rgn, RGNDATA *data )
 {
-    HDC hdcMem;
-    BITMAPINFO bmi;
-    HBITMAP hbmp, hbmpOld;
-    HBRUSH hbrBack;
+    HRGN tmp = ExtCreateRegion( NULL, data->rdh.dwSize + data->rdh.nRgnSize, data );
 
-    hdcMem = CreateCompatibleDC(0);
+    CombineRgn( rgn, rgn, tmp, RGN_OR );
+    DeleteObject( tmp );
+    data->rdh.nCount = 0;
+}
 
-    memset(&bmi, 0, sizeof(bmi));
-    bmi.bmiHeader.biSize = sizeof(bmi.bmiHeader);
-    bmi.bmiHeader.biWidth = pRect->right;
-    bmi.bmiHeader.biHeight = -pRect->bottom;
-    bmi.bmiHeader.biPlanes = 1;
-    bmi.bmiHeader.biBitCount = 32;
-    hbmp = CreateDIBSection(hdcMem, &bmi, DIB_RGB_COLORS , NULL, 0, 0);
+static inline void add_row( HRGN rgn, RGNDATA *data, int x, int y, int len )
+{
+    RECT *rect = (RECT *)data->Buffer + data->rdh.nCount;
 
-    hbmpOld = (HBITMAP)SelectObject(hdcMem, hbmp);
-    
-    /* FIXME: use an internal function that doesn't do transparent blt */
-    hbrBack = CreateSolidBrush(RGB(255,0,255));
-
-    FillRect(hdcMem, pRect, hbrBack);
-
-    DrawThemeBackground(hTheme, hdcMem, iPartId, iStateId, pRect, NULL);
-
-    DeleteObject(hbrBack);
-    SelectObject(hdcMem, hbmpOld);
-    DeleteObject(hdcMem);
-
-    return hbmp;
+    if (len <= 0) return;
+    rect->left   = x;
+    rect->top    = y;
+    rect->right  = x + len;
+    rect->bottom = y + 1;
+    data->rdh.nCount++;
+    if (data->rdh.nCount * sizeof(RECT) > data->rdh.nRgnSize - sizeof(RECT))
+        flush_rgn_data( rgn, data );
 }
 
-#define PT_IN_RECT(lprc,x,y) ( x >= lprc->left && x < lprc->right && \
-                               y >= lprc->top  && y < lprc->bottom)
-
-static HRGN UXTHEME_RegionFromDibBits(RGBQUAD* pBuffer, RGBQUAD* pclrTransparent, LPCRECT pRect)
+static HRESULT create_image_bg_region(HTHEME theme, int part, int state, const RECT *rect, HRGN *rgn)
 {
-    int x, y, xstart;
-    int cMaxRgnRects, cRgnDataSize, cRgnRects;
-    RECT* prcCurrent;
-    PRGNDATA prgnData;
-    ULONG clrTransparent, *pclrCurrent;
-    HRGN hrgnRet;
+    RECT r;
+    HDC dc;
+    HBITMAP bmp;
+    HRGN hrgn;
+    BOOL istrans;
+    COLORREF transcolour;
+    HBRUSH transbrush;
+    unsigned int x, y, start;
+    BITMAPINFO bitmapinfo;
+    DWORD *bits;
+    char buffer[4096];
+    RGNDATA *data = (RGNDATA *)buffer;
 
-    pclrCurrent = (PULONG)pBuffer;
-    clrTransparent = *(PULONG)pclrTransparent;
+    if (FAILED(GetThemeBool(theme, part, state, TMT_TRANSPARENT, &istrans)) || !istrans) {
+        *rgn = CreateRectRgn(rect->left, rect->top, rect->right, rect->bottom);
+        return S_OK;
+    }
 
-    /* Create a region and pre-allocate memory enough for 3 spaces in one row*/
-    cRgnRects = 0;
-    cMaxRgnRects = 4* (pRect->bottom-pRect->top);
-    cRgnDataSize = sizeof(RGNDATA) + cMaxRgnRects * sizeof(RECT);
+    r = *rect;
+    OffsetRect(&r, -r.left, -r.top);
 
-    /* Allocate the region data */
-    prgnData = (PRGNDATA)HeapAlloc(GetProcessHeap(), 0, cRgnDataSize);
+    if (FAILED(GetThemeColor(theme, part, state, TMT_TRANSPARENTCOLOR, &transcolour)))
+        transcolour = RGB(255, 0, 255); /* defaults to magenta */
 
-    prcCurrent = (PRECT)prgnData->Buffer;
-    
-    /* Calculate the region rects */
-    y=0;
-    /* Scan each line of the bitmap */
-    while(y<pRect->bottom)
-    {
-        x=0;
-        /* Scan each pixel */
-        while (x<pRect->right)
-        {
-            /* Check if the pixel is not transparent and it is in the requested rect */
-            if(*pclrCurrent != clrTransparent && PT_IN_RECT(pRect,x,y))
-            {
-                xstart = x;
-                /* Find the end of the opaque row of pixels */
-                while (x<pRect->right)
-                {
-                    if(*pclrCurrent == clrTransparent || !PT_IN_RECT(pRect,x,y))
-                        break;
-                    x++;
-                    pclrCurrent++;
-                }
+    dc = CreateCompatibleDC(NULL);
+    if (!dc) {
+        WARN("CreateCompatibleDC failed\n");
+        return E_FAIL;
+    }
 
-                /* Add the scaned line to the region */
-                SetRect(prcCurrent, xstart, y,x,y+1);
-                prcCurrent++;
-                cRgnRects++;
+    bitmapinfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
+    bitmapinfo.bmiHeader.biWidth = rect->right - rect->left;
+    bitmapinfo.bmiHeader.biHeight = -(rect->bottom - rect->top);
+    bitmapinfo.bmiHeader.biPlanes = 1;
+    bitmapinfo.bmiHeader.biBitCount = 32;
+    bitmapinfo.bmiHeader.biCompression = BI_RGB;
+    bitmapinfo.bmiHeader.biSizeImage = bitmapinfo.bmiHeader.biWidth * bitmapinfo.bmiHeader.biHeight * 4;
+    bitmapinfo.bmiHeader.biXPelsPerMeter = 0;
+    bitmapinfo.bmiHeader.biYPelsPerMeter = 0;
+    bitmapinfo.bmiHeader.biClrUsed = 0;
+    bitmapinfo.bmiHeader.biClrImportant = 0;
 
-                /* Increase the size of the buffer if it is full */
-                if(cRgnRects == cMaxRgnRects)
-                {
-                    cMaxRgnRects *=2;
-                    cRgnDataSize = sizeof(RGNDATA) + cMaxRgnRects * sizeof(RECT);
-                    prgnData = (PRGNDATA)HeapReAlloc(GetProcessHeap(), 
-                                                     0, 
-                                                     prgnData, 
-                                                     cRgnDataSize);
-                    prcCurrent = (RECT*)prgnData->Buffer + cRgnRects;
-                }
-            }
-            else
-            {
-                x++;
-                pclrCurrent++;
-            }
-        }
-        y++;
+    bmp = CreateDIBSection(dc, &bitmapinfo, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
+    if (!bmp) {
+        WARN("CreateDIBSection failed\n");
+        DeleteDC(dc);
+        return E_FAIL;
     }
 
-    /* Fill the region data header */
-    prgnData->rdh.dwSize = sizeof(prgnData->rdh);
-    prgnData->rdh.iType = RDH_RECTANGLES;
-    prgnData->rdh.nCount = cRgnRects;
-    prgnData->rdh.nRgnSize = cRgnDataSize;
-    prgnData->rdh.rcBound = *pRect;
+    SelectObject(dc, bmp);
 
-    /* Create the region*/
-    hrgnRet = ExtCreateRegion (NULL, cRgnDataSize, prgnData);
+    transbrush = CreateSolidBrush(transcolour);
+    FillRect(dc, &r, transbrush);
+    DeleteObject(transbrush);
 
-    /* Free the region data*/
-    HeapFree(GetProcessHeap(),0,prgnData);
+    if (FAILED(DrawThemeBackground(theme, dc, part, state, &r, NULL))) {
+        WARN("DrawThemeBackground failed\n");
+        DeleteObject(bmp);
+        DeleteDC(dc);
+        return E_FAIL;
+    }
 
-    /* return the region*/
-    return hrgnRet;
-}
+    data->rdh.dwSize = sizeof(data->rdh);
+    data->rdh.iType  = RDH_RECTANGLES;
+    data->rdh.nCount = 0;
+    data->rdh.nRgnSize = sizeof(buffer) - sizeof(data->rdh);
 
-HRESULT UXTHEME_GetImageBackBackgroundRegion(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, LPCRECT pRect, HRGN *pRegion)
-{
-    HBITMAP hbmp;
-    DIBSECTION dib;
-    RGBQUAD clrTransparent = {0xFF,0x0, 0xFF,0x0};
+    hrgn = CreateRectRgn(0, 0, 0, 0);
 
-    /* Draw the theme part to a dib */
-    hbmp = UXTHEME_DrawThemePartToDib(hTheme, hdc, iPartId, iStateId, pRect);
+    for (y = 0; y < r.bottom; y++, bits += r.right) {
+        x = 0;
+        while (x < r.right) {
+            while (x < r.right && (bits[x] & 0xffffff) == transcolour) x++;
+            start = x;
+            while (x < r.right && !((bits[x] & 0xffffff) == transcolour)) x++;
+            add_row( hrgn, data, rect->left + start, rect->top + y, x - start );
+        }
+    }
 
-    /* Retrieve the info of the dib section */
-    GetObjectW(hbmp, sizeof (DIBSECTION), &dib);
+    if (data->rdh.nCount > 0) flush_rgn_data(hrgn, data);
 
-    /* Convert the bits of the dib section to a region */
-    *pRegion = UXTHEME_RegionFromDibBits((RGBQUAD*)dib.dsBm.bmBits, &clrTransparent, pRect);
+    *rgn = hrgn;
 
-    /* Free the temp bitmap */
-    DeleteObject(hbmp);
+    DeleteObject(bmp);
+    DeleteDC(dc);
 
     return S_OK;
 }
@@ -1929,7 +1923,7 @@
 
     GetThemeEnumValue(hTheme, iPartId, iStateId, TMT_BGTYPE, &bgtype);
     if(bgtype == BT_IMAGEFILE) {
-        hr = UXTHEME_GetImageBackBackgroundRegion(hTheme, hdc, iPartId, iStateId, pRect, pRegion);
+        hr = create_image_bg_region(hTheme, iPartId, iStateId, pRect, pRegion);
     }
     else if(bgtype == BT_BORDERFILL) {
         *pRegion = CreateRectRgn(pRect->left, pRect->top, pRect->right, pRect->bottom);
@@ -2015,8 +2009,8 @@
         return E_HANDLE;
 
     if(pBoundingRect)
-        CopyRect(&rt, pBoundingRect);
-            
+        rt = *pBoundingRect;
+
     hr = GetThemeFont(hTheme, hdc, iPartId, iStateId, TMT_FONT, &logfont);
     if(SUCCEEDED(hr)) {
         hFont = CreateFontIndirectW(&logfont);
Index: dll/win32/uxtheme/main.c
===================================================================
--- dll/win32/uxtheme/main.c	(revision 72511)
+++ dll/win32/uxtheme/main.c	(working copy)
@@ -31,8 +31,6 @@
             DisableThreadLibraryCalls(hInstDLL);
             UXTHEME_InitSystem(hInstDLL);
             break;
-        case DLL_PROCESS_DETACH:
-            break;
     }
     return TRUE;
 }
Index: dll/win32/uxtheme/metric.c
===================================================================
--- dll/win32/uxtheme/metric.c	(revision 72511)
+++ dll/win32/uxtheme/metric.c	(working copy)
@@ -225,3 +225,15 @@
         return MSSTYLES_GetPropertyString(tp, pszStringBuff, cchMaxStringChars);
     return E_PROP_ID_UNSUPPORTED;
 }
+
+/***********************************************************************
+ *      GetThemeTransitionDuration                          (UXTHEME.@)
+ */
+HRESULT WINAPI GetThemeTransitionDuration(HTHEME hTheme, int iPartId, int iStateIdFrom,
+                                          int iStateIdTo, int iPropId, DWORD *pdwDuration)
+{
+    FIXME("(%p, %u, %u, %u, %u, %p) stub\n", hTheme, iPartId, iStateIdFrom, iStateIdTo,
+          iPropId, pdwDuration);
+
+    return E_NOTIMPL;
+}
Index: dll/win32/uxtheme/uxini.c
===================================================================
--- dll/win32/uxtheme/uxini.c	(revision 72511)
+++ dll/win32/uxtheme/uxini.c	(working copy)
@@ -32,7 +32,7 @@
     LPCWSTR lpIni;
     LPCWSTR lpCurLoc;
     LPCWSTR lpEnd;
-} UXINI_FILE;
+} UXINI_FILE, *PUXINI_FILE;
 
 /***********************************************************************/
 
Index: dll/win32/uxtheme/uxtheme.spec
===================================================================
--- dll/win32/uxtheme/uxtheme.spec	(revision 72511)
+++ dll/win32/uxtheme/uxtheme.spec	(working copy)
@@ -37,59 +37,60 @@
 37 stdcall DrawThemeIcon(ptr ptr long long ptr ptr long)
 38 stdcall DrawThemeParentBackground(ptr ptr ptr)
 39 stdcall DrawThemeText(ptr ptr long long wstr long long long ptr)
-40 stdcall EnableThemeDialogTexture(ptr long)
-41 stdcall EnableTheming(long)
-42 stdcall GetCurrentThemeName(wstr long wstr long wstr long)
-43 stdcall -noname ClassicGetSystemMetrics(long)
-44 stdcall -noname ClassicSystemParametersInfoA(long long ptr long)
-45 stdcall -noname ClassicSystemParametersInfoW(long long ptr long)
-46 stdcall -noname ClassicAdjustWindowRectEx(ptr long long long)
-47 stdcall DrawThemeBackgroundEx(ptr ptr long long ptr ptr)
-48 stub -noname GetThemeParseErrorInfo
-49 stdcall GetThemeAppProperties()
-50 stdcall GetThemeBackgroundContentRect(ptr ptr long long ptr ptr)
-51 stdcall GetThemeBackgroundExtent(ptr ptr long long ptr ptr)
-52 stdcall GetThemeBackgroundRegion(ptr ptr long long ptr ptr)
-53 stdcall GetThemeBool(ptr long long long ptr)
-54 stdcall GetThemeColor(ptr long long long ptr)
-55 stdcall GetThemeDocumentationProperty(wstr wstr wstr long)
-56 stdcall GetThemeEnumValue(ptr long long long ptr)
-57 stdcall GetThemeFilename(ptr long long long wstr long)
-58 stdcall GetThemeFont(ptr ptr long long long ptr)
-59 stdcall GetThemeInt(ptr long long long ptr)
-60 stub -noname CreateThemeDataFromObjects
-61 stdcall -noname OpenThemeDataEx(ptr wstr long)
-62 stub -noname ServerClearStockObjects
-63 stub -noname MarkSelection
-#64 ProcessLoadTheme_RunDLLW
-#65 SetSystemVisualStyle
-#66 ServiceClearStockObjects
-67 stdcall GetThemeIntList(ptr long long long ptr)
-68 stdcall GetThemeMargins(ptr ptr long long long ptr ptr)
-69 stdcall GetThemeMetric(ptr ptr long long long ptr)
-70 stdcall GetThemePartSize(ptr ptr long long ptr long ptr)
-71 stdcall GetThemePosition(ptr long long long ptr)
-72 stdcall GetThemePropertyOrigin(ptr long long long ptr)
-#73 IsThemeActiveByPolicy
-74 stdcall GetThemeRect(ptr long long long ptr)
-75 stdcall GetThemeString(ptr long long long wstr long)
-76 stdcall GetThemeSysBool(ptr long)
-77 stdcall GetThemeSysColor(ptr long)
-78 stdcall GetThemeSysColorBrush(ptr long)
-79 stdcall GetThemeSysFont(ptr long ptr)
-80 stdcall GetThemeSysInt(ptr long ptr)
-81 stdcall GetThemeSysSize(ptr long)
-82 stdcall GetThemeSysString(ptr long wstr long)
-83 stdcall GetThemeTextExtent(ptr ptr long long wstr long long ptr ptr)
-84 stdcall GetThemeTextMetrics(ptr ptr long long ptr)
-85 stdcall GetWindowTheme(ptr)
-86 stdcall HitTestThemeBackground(ptr long long long long ptr long double ptr)
-87 stdcall IsAppThemed()
-88 stdcall IsThemeActive()
-89 stdcall IsThemeBackgroundPartiallyTransparent(ptr long long)
-90 stdcall IsThemeDialogTextureEnabled(ptr)
-91 stdcall IsThemePartDefined(ptr long long)
-92 stdcall OpenThemeData(ptr wstr)
-93 stdcall SetThemeAppProperties(long)
-94 stdcall SetWindowTheme(ptr wstr wstr)
-95 stdcall ThemeInitApiHook(long ptr)
+40 stdcall DrawThemeTextEx(ptr ptr long long wstr long long ptr ptr)
+41 stdcall EnableThemeDialogTexture(ptr long)
+42 stdcall EnableTheming(long)
+43 stdcall GetCurrentThemeName(wstr long wstr long wstr long)
+44 stdcall -noname ClassicGetSystemMetrics(long)
+45 stdcall -noname ClassicSystemParametersInfoA(long long ptr long)
+46 stdcall -noname ClassicSystemParametersInfoW(long long ptr long)
+47 stdcall -noname ClassicAdjustWindowRectEx(ptr long long long)
+48 stdcall DrawThemeBackgroundEx(ptr ptr long long ptr ptr)
+49 stub -noname GetThemeParseErrorInfo
+50 stdcall GetThemeAppProperties()
+51 stdcall GetThemeBackgroundContentRect(ptr ptr long long ptr ptr)
+52 stdcall GetThemeBackgroundExtent(ptr ptr long long ptr ptr)
+53 stdcall GetThemeBackgroundRegion(ptr ptr long long ptr ptr)
+54 stdcall GetThemeBool(ptr long long long ptr)
+55 stdcall GetThemeColor(ptr long long long ptr)
+56 stdcall GetThemeDocumentationProperty(wstr wstr wstr long)
+57 stdcall GetThemeEnumValue(ptr long long long ptr)
+58 stdcall GetThemeFilename(ptr long long long wstr long)
+59 stdcall GetThemeFont(ptr ptr long long long ptr)
+60 stdcall GetThemeInt(ptr long long long ptr)
+61 stub -noname CreateThemeDataFromObjects
+62 stdcall -noname OpenThemeDataEx(ptr wstr long)
+63 stub -noname ServerClearStockObjects
+64 stub -noname MarkSelection
+#65 ProcessLoadTheme_RunDLLW
+#66 SetSystemVisualStyle
+#67 ServiceClearStockObjects
+68 stdcall GetThemeIntList(ptr long long long ptr)
+69 stdcall GetThemeMargins(ptr ptr long long long ptr ptr)
+70 stdcall GetThemeMetric(ptr ptr long long long ptr)
+71 stdcall GetThemePartSize(ptr ptr long long ptr long ptr)
+72 stdcall GetThemePosition(ptr long long long ptr)
+73 stdcall GetThemePropertyOrigin(ptr long long long ptr)
+#74 IsThemeActiveByPolicy
+75 stdcall GetThemeRect(ptr long long long ptr)
+76 stdcall GetThemeString(ptr long long long wstr long)
+77 stdcall GetThemeSysBool(ptr long)
+78 stdcall GetThemeSysColor(ptr long)
+79 stdcall GetThemeSysColorBrush(ptr long)
+80 stdcall GetThemeSysFont(ptr long ptr)
+81 stdcall GetThemeSysInt(ptr long ptr)
+82 stdcall GetThemeSysSize(ptr long)
+83 stdcall GetThemeSysString(ptr long wstr long)
+84 stdcall GetThemeTextExtent(ptr ptr long long wstr long long ptr ptr)
+85 stdcall GetThemeTextMetrics(ptr ptr long long ptr)
+86 stdcall GetWindowTheme(ptr)
+87 stdcall HitTestThemeBackground(ptr long long long long ptr long double ptr)
+88 stdcall IsAppThemed()
+89 stdcall IsThemeActive()
+90 stdcall IsThemeBackgroundPartiallyTransparent(ptr long long)
+91 stdcall IsThemeDialogTextureEnabled(ptr)
+92 stdcall IsThemePartDefined(ptr long long)
+93 stdcall OpenThemeData(ptr wstr)
+94 stdcall SetThemeAppProperties(long)
+95 stdcall SetWindowTheme(ptr wstr wstr)
+96 stdcall ThemeInitApiHook(long ptr)
