Hi guys
is there an equivalence api (or user made function) to BeginBufferedPaint (uxtheme.dll in windows 7) that works on windowsXP ?
I need to build 2 functions existant in uxtheme for win 7 to winxp:
BeginBufferedPaint
EndBufferedPaint
Any ideas ?
Best Regards,
guga
it's probably a set wrapper of functions (BufferedPaintInit, BeginBufferedPaint, BeginBufferedPaint)
albeit a complex set
use CreateCompatibleDC and double-buffer the paint operation
i found these 1 examples that seems to replace those functions
http://dome.rssing.com/chan-1366198/all_p6.html
Is that it ?
Here is the code i´m trying to port
the routines i´m trying to port are:
mov eax D$BoundingRect.right | sub eax D$BoundingRect.left | mov D@pContentRect_rightDis eax
and D@pContentRect_leftDis 0
mov eax D$BoundingRect.bottom | sub eax D$BoundingRect.top | mov D@pContentRect_bottomDis eax
and D@pContentRect_topDis 0
mov D$BP_PAINTPARAMS.cbSize Size_of_BP_PAINTPARAMS
mov D$BP_PAINTPARAMS.dwFlags &BPPF_ERASE
lea eax D@hdcDest
call 'UxTheme.BeginBufferedPaint' D@hDC, D@pContentRect, 0, BP_PAINTPARAMS, eax
call 'UxTheme.EndBufferedPaint' D@hBufferedPaint, 0
The full function i´m working is one called Progress_PaintThemedHighlight from uxtheme.dll for windows7 (This is exactly the same function inside uxtheme.dll converted to rosasm syntax)
How to convert the above functions to work with XP ?
; SIZE structure
[PtThemeHl:
PtThemeHl.x: D$ 0
PtThemeHl.y: D$ 0]
[BP_PAINTPARAMS:
BP_PAINTPARAMS.cbSize: D$ len
BP_PAINTPARAMS.dwFlags: D$ 0
BP_PAINTPARAMS.prcExclude: D$ 0
BP_PAINTPARAMS.pBlendFunction: D$ 0]
[Size_of_BP_PAINTPARAMS 16]
[BLENDFUNCTION:
BLENDFUNCTION.BlendOp: B$ 0
BLENDFUNCTION.BlendFlags: B$ 0
BLENDFUNCTION.SourceConstantAlpha: B$ 0
BLENDFUNCTION.AlphaFormat: B$ 0]
[Size_of_BLENDFUNCTION 4]
Proc Progress_PaintThemedHighlight:
Arguments @hMem, @hDC, @pRect
Local @hdcDest, @ResultValue, @iPartId, @RcLeft, @RcTop, @RcRight, @RcBottom, @BarSize, @hBufferedPaint, @heightDest, @widthSrc, @heightSrc
Structure @pContentRect 16, @pContentRect_leftDis 0, @pContentRect_topDis 4, @pContentRect_rightDis 8, @pContentRect_bottomDis 12
Uses ebx, esi, edi, ecx, edx
mov edi D@pRect
move D@RcLeft D$edi+RECT.LeftDis
move D@RcTop D$edi+RECT.topDis
move D@RcRight D$edi+RECT.rightDis
move D@RcBottom D$edi+RECT.bottomDis
mov D@hdcDest 0
mov D$BLENDFUNCTION 0
call ZeroMemory PtThemeHl, Size_Of_POINT
call ZeroMemory BoundingRect, Size_Of_RECT
call ZeroMemory BP_PAINTPARAMS, Size_of_BP_PAINTPARAMS
mov esi D@hMem
mov eax D$esi+PRO_DATA2.dwStyleDis
and eax &PBS_VERTICAL
mov ebx eax
or ebx 16
xor ecx ecx
shr ebx 1
test eax eax
setne cl
mov B@ResultValue 0
lea ecx D$ecx+ecx+7
mov D@iPartId ecx
If eax = 0
mov eax D@RcBottom | sub eax D@RcTop
Else
mov eax D@RcRight | sub eax D@RcLeft
End_If
mov D@BarSize eax
call 'UxTheme.GetThemePartSize' D$esi+PRO_DATA2._hThemeDis, D@hDC, ebx, 0, D@pRect, &TS_TRUE, PtThemeHl
...If eax =>s 0
call 'USER32.CopyRect' BoundingRect, D@pRect
.Test_If B$esi+PRO_DATA2.dwStyleDis &PBS_VERTICAL
mov eax D$PtThemeHl.y
mov ecx D$BoundingRect.bottom
add D@BarSize eax
sub ecx eax
sub eax D$esi+56
mov D$BoundingRect.top ecx
call 'USER32.OffsetRect' BoundingRect, 0, eax
mov eax D$BoundingRect.bottom
If eax >s D@RcTop
call 'UxTheme.DrawThemeBackground' D$esi+PRO_DATA2._hThemeDis, D@hDC, ebx, 0, BoundingRect, D@pRect
mov B@ResultValue 01
End_If
.Test_Else
mov eax D$PtThemeHl.x
mov ecx D$BoundingRect.left
add D@BarSize eax
add ecx eax
mov D$BoundingRect.right ecx
mov ecx D$esi+56
sub ecx eax
call 'USER32.OffsetRect' BoundingRect, ecx, 0
mov eax D$BoundingRect.left
If eax <s D@RcRight
call 'UxTheme.DrawThemeBackground' D$esi+PRO_DATA2._hThemeDis, D@hDC, ebx, 0, BoundingRect, D@pRect
mov B@ResultValue 01
End_If
.Test_End
...End_If
mov eax D@BarSize
...If eax <s 0
call 'UxTheme.GetThemePartSize' D$esi+PRO_DATA2._hThemeDis, D@hDC, D@iPartId, 0, D@pRect, &TS_TRUE, PtThemeHl
..If eax =>s 0
call ZeroMemory BoundingRect, Size_Of_RECT
call 'USER32.CopyRect' BoundingRect, D@pRect
.Test_If B$esi+PRO_DATA2.dwStyleDis &PBS_VERTICAL
mov D@hBufferedPaint 2
lea eax D@hBufferedPaint
call 'UxTheme.GetThemeEnumValue' D$esi+PRO_DATA2._hThemeDis, D@iPartId, 0, &TMT_VALIGN, eax
If D@hBufferedPaint = 0
mov eax D$PtThemeHl.y
mov ecx D$BoundingRect.top | add ecx eax
mov D$BoundingRect.bottom ecx
Else_If D@hBufferedPaint = 1
mov eax D$BoundingRect.bottom | sub eax D$BoundingRect.top
mov ecx D$PtThemeHl.y
sub eax ecx
cdq
sub eax edx
sar eax 1
add D$BoundingRect.top eax
mov eax D$BoundingRect.top
add eax ecx
mov D$BoundingRect.bottom eax
Else
mov eax D$BoundingRect.bottom | sub eax D$PtThemeHl.y
mov D$BoundingRect.top eax
End_if
.Test_Else
mov D@hBufferedPaint 0
lea eax D@hBufferedPaint
call 'UxTheme.GetThemeEnumValue' D$esi+PRO_DATA2._hThemeDis, D@iPartId, 0, &TMT_HALIGN, eax
If D@hBufferedPaint = 0
mov eax D$PtThemeHl.x
mov ecx D$BoundingRect.left
add ecx eax
mov D$BoundingRect.right ecx
Else_If D@hBufferedPaint = 1
mov eax D$BoundingRect.right
sub eax D$BoundingRect.left
mov ecx D$PtThemeHl.x
sub eax ecx
cdq
sub eax edx
sar eax 1
add D$BoundingRect.left eax
mov eax D$BoundingRect.left
add eax ecx
mov D$BoundingRect.right eax
Else
mov eax D$BoundingRect.right
sub eax D$PtThemeHl.x
mov D$BoundingRect.left eax
End_If
.Test_End
mov edi 01FF
call 'KERNEL32.MulDiv' D$esi+56, 01FF, D@BarSize
mov ebx eax
If ebx >s 255
sub edi ebx
mov ebx edi
End_If
mov eax D$BoundingRect.right | sub eax D$BoundingRect.left | mov D@pContentRect_rightDis eax
and D@pContentRect_leftDis 0
mov eax D$BoundingRect.bottom | sub eax D$BoundingRect.top | mov D@pContentRect_bottomDis eax
and D@pContentRect_topDis 0
mov D$BP_PAINTPARAMS.cbSize Size_of_BP_PAINTPARAMS
mov D$BP_PAINTPARAMS.dwFlags &BPPF_ERASE
lea eax D@hdcDest
;call 'UxTheme.BeginBufferedPaint' D@hDC, D@pContentRect, 0, BP_PAINTPARAMS, eax
mov D@hBufferedPaint eax
.If eax <> 0
lea eax D@pContentRect
call 'UxTheme.DrawThemeBackground' D$esi+PRO_DATA2._hThemeDis, D@hdcDest, D@iPartId, 0, eax, 0
If eax =>s 0
mov B$BLENDFUNCTION.BlendOp &AC_SRC_OVER
mov B$BLENDFUNCTION.BlendFlags 0
mov B$BLENDFUNCTION.SourceConstantAlpha bl
mov B$BLENDFUNCTION.AlphaFormat &AC_SRC_ALPHA
mov eax D@pContentRect_bottomDis | sub eax D@pContentRect_topDis | mov D@heightSrc eax
mov eax D@pContentRect_rightDis | sub eax D@pContentRect_leftDis | mov D@widthSrc eax
mov eax D$BoundingRect.bottom | sub eax D$BoundingRect.top | mov D@heightDest eax
mov eax D$BoundingRect.right | sub eax D$BoundingRect.left
call 'GDI32.GdiAlphaBlend' D@hDC, D$BoundingRect.left, D$BoundingRect.top, eax, D@heightDest,
D@hdcDest, D@pContentRect_leftDis, D@pContentRect_topDis,
D@widthSrc, D@heightSrc, D$BLENDFUNCTION
End_If
mov B@ResultValue 01
;call 'UxTheme.EndBufferedPaint' D@hBufferedPaint, 0
.End_If
..End_If
...End_If
mov al B@ResultValue
EndP
Ok...i guess i built the necessary functions that works for WinXp and below ..Can someone see if it is ok ?
;;
BeginBufferedPaintXP V 1.0
Begins a buffered paint operation.
This function was designed to work in WinXp and below, on a similar way as BeginBufferedPaint existent in uxtheme.dll used in Windows Vista and above.
Arguments:
hDCWin (in) - The handle of the target DC on which the buffer will be painted.
pRect (in) - A pointer to a RECT structure that specifies the area of the target DC in which to paint.
phdcMem (out) - A pointer to the new device context created.
pBmp (out) - A pointer to the newly created DIB
phbmPrev (out) - Pointer to a handle of the selected bitmap (DIB).
Return Values:
If the function suceeds it returns a handle to the buffered paint context. (hdcMem)
If the function fails, it returns &FALSE
Remarks:
If this function suceeds, it creates the values for phdcMem, pBmp, phbmPrev
You must End this function using EndBufferedPaint
Author:
Gustavo Trigueiros (a.k.a: Beyond2000! or guga)
25/06/2.012
;;
Proc BeginBufferedPaintXP:
Arguments @hDCWin, @pRect, @phdcMem, @pBmp, @phbmPrev
Local @RgbQuad
Structure @BITMAPINFO 44, @BITMAPINFO.bmiHeader.biSizeDis 0, @BITMAPINFO.bmiHeader.biWidthDis 4, @BITMAPINFO.bmiHeader.biHeightDis 8, @BITMAPINFO.bmiHeader.biPlanesDis 12,
@BITMAPINFO.bmiHeader.biBitCountDis 14, @BITMAPINFO.bmiHeader.biCompressionDis 16, @BITMAPINFO.bmiHeader.biSizeImageDis 20,
@BITMAPINFO.bmiHeader.biXPelsPerMeterDis 24, @BITMAPINFO.bmiHeader.biYPelsPerMeterDis 28, @BITMAPINFO.bmiHeader.biClrUsedDis 32,
@BITMAPINFO.bmiHeader.biClrImportantDis 36, @BITMAPINFO.bmiColors.rgbBlueDis 40, @BITMAPINFO.bmiColors.rgbGreenDis 41,
@BITMAPINFO.bmiColors.rgbRedDis 42, @BITMAPINFO.bmiColors.rgbReservedDis 43
Uses edi, ecx, ebx
xor eax eax
On D@phdcMem = 0, ExitP
On D@pBmp = 0, ExitP
On D@phbmPrev = 0, ExitP
mov ecx D@phdcMem | mov D$ecx 0
mov ecx D@pBmp | mov D$ecx 0
mov ecx D@phbmPrev | mov D$ecx 0
call 'GDI32.CreateCompatibleDC' D@hDCWin
On eax = 0, ExitP
mov edi D@phdcMem
mov D$edi eax
call ZeroMemory D@BITMAPINFO, 44
mov D@RgbQuad 0
mov ecx D@pRect
mov ebx D$ecx+RECT.rightDis ; cx
mov esi D$ecx+RECT.bottomDis ; cy
mov D@BITMAPINFO.bmiHeader.biSizeDis 44
mov D@BITMAPINFO.bmiHeader.biWidthDis ebx
mov D@BITMAPINFO.bmiHeader.biHeightDis esi
mov W@BITMAPINFO.bmiHeader.biPlanesDis 1
mov D@BITMAPINFO.bmiHeader.biCompressionDis &BI_RGB
lea eax D@RgbQuad
call 'GDI32.CreateDIBSection' D@hDCWin, D@BITMAPINFO, &DIB_RGB_COLORS, eax, &NULL, 0
.If eax = &NULL
call 'GDI32.DeleteDC' D@phdcMem
xor eax eax
.Else
mov edi D@pBmp
mov D$edi eax
; SelectBitmap
call 'GDI32.SelectObject' D@phdcMem, D@pBmp
If eax = &NULL
call 'GDI32.DeleteObject' D@pBmp
call 'GDI32.DeleteDC' D@phdcMem
xor eax eax
Else
mov edi D@phbmPrev
mov D$edi eax
mov eax D@phdcMem
End_If
.End_If
EndP
;;
EndBufferedPaintXP V 1.0
Completes a buffered paint operation and frees the associated buffered paint handle.
This function was designed to work in WinXp and below, on a similar way as EndBufferedPaint existent in uxtheme.dll used in Windows Vista and above.
Arguments:
phdcMem (in) - A pointer to the new device context created with BeginBufferedPaintXP
pBmp (in) - A pointer to the newly created DIB using BeginBufferedPaintXP
phbmPrev (in) - Pointer to a handle of the selected bitmap (DIB) using BeginBufferedPaintXP.
Return Values:
If the function suceeds it returns &TRUE
If the function fails, it returns &FALSE
Remarks:
The arguments must be previously created with BeginBufferedPaintXP.
Author:
Gustavo Trigueiros (a.k.a: Beyond2000! or guga)
25/06/2.012
;;
Proc EndBufferedPaintXP:
Arguments @hdcMem, @hBMP, @hbmPrev
xor eax eax
On D@hdcMem = 0, ExitP
If_and D@hBMP <> 0, D@hbmPrev = 0
call 'GDI32.DeleteObject' D@hBMP
call 'GDI32.DeleteDC' D@hdcMem
xor eax eax
Else_If_and D@hBMP = 0, D@hbmPrev <> 0
call 'GDI32.DeleteDC' D@hdcMem
xor eax eax
Else_If_and D@hBMP <> 0, D@hbmPrev <> 0
call 'GDI32.SelectObject' D@hdcMem, D@hbmPrev
call 'GDI32.DeleteObject' D@hBMP
call 'GDI32.DeleteDC' D@hdcMem
mov eax &TRUE
End_If
EndP
Usage example is the code on the previous post:
__________________________________________________________________________________________________
; SIZE structure
[PtThemeHl:
PtThemeHl.x: D$ 0
PtThemeHl.y: D$ 0]
[BP_PAINTPARAMS:
BP_PAINTPARAMS.cbSize: D$ len
BP_PAINTPARAMS.dwFlags: D$ 0
BP_PAINTPARAMS.prcExclude: D$ 0
BP_PAINTPARAMS.pBlendFunction: D$ 0]
[Size_of_BP_PAINTPARAMS 16]
[BLENDFUNCTION:
BLENDFUNCTION.BlendOp: B$ 0
BLENDFUNCTION.BlendFlags: B$ 0
BLENDFUNCTION.SourceConstantAlpha: B$ 0
BLENDFUNCTION.AlphaFormat: B$ 0]
[Size_of_BLENDFUNCTION 4]
Proc Progress_PaintThemedHighlight:
Arguments @hMem, @hDC, @pRect
Local @hdcDest, @ResultValue, @iPartId, @RcLeft, @RcTop, @RcRight, @RcBottom, @BarSize, @hBufferedPaint, @heightDest, @widthSrc, @heightSrc, @hBmp, @bmPrev
Structure @pContentRect 16, @pContentRect_leftDis 0, @pContentRect_topDis 4, @pContentRect_rightDis 8, @pContentRect_bottomDis 12
Uses ebx, esi, edi, ecx, edx
mov edi D@pRect
move D@RcLeft D$edi+RECT.LeftDis
move D@RcTop D$edi+RECT.topDis
move D@RcRight D$edi+RECT.rightDis
move D@RcBottom D$edi+RECT.bottomDis
mov D@hdcDest 0
mov D@hBmp 0
mov D@bmPrev 0
mov D$BLENDFUNCTION 0
call ZeroMemory PtThemeHl, Size_Of_POINT
call ZeroMemory BoundingRect, Size_Of_RECT
call ZeroMemory BP_PAINTPARAMS, Size_of_BP_PAINTPARAMS
mov esi D@hMem
mov eax D$esi+PRO_DATA2.dwStyleDis
and eax &PBS_VERTICAL
mov ebx eax
or ebx 16
xor ecx ecx
shr ebx 1
test eax eax
setne cl
mov B@ResultValue 0
lea ecx D$ecx+ecx+7
mov D@iPartId ecx
If eax = 0
mov eax D@RcBottom | sub eax D@RcTop
Else
mov eax D@RcRight | sub eax D@RcLeft
End_If
mov D@BarSize eax
call 'UxTheme.GetThemePartSize' D$esi+PRO_DATA2._hThemeDis, D@hDC, ebx, 0, D@pRect, &TS_TRUE, PtThemeHl
...If eax =>s 0
call 'USER32.CopyRect' BoundingRect, D@pRect
.Test_If B$esi+PRO_DATA2.dwStyleDis &PBS_VERTICAL
mov eax D$PtThemeHl.y
mov ecx D$BoundingRect.bottom
add D@BarSize eax
sub ecx eax
sub eax D$esi+56
mov D$BoundingRect.top ecx
call 'USER32.OffsetRect' BoundingRect, 0, eax
mov eax D$BoundingRect.bottom
If eax >s D@RcTop
call 'UxTheme.DrawThemeBackground' D$esi+PRO_DATA2._hThemeDis, D@hDC, ebx, 0, BoundingRect, D@pRect
mov B@ResultValue 01
End_If
.Test_Else
mov eax D$PtThemeHl.x
mov ecx D$BoundingRect.left
add D@BarSize eax
add ecx eax
mov D$BoundingRect.right ecx
mov ecx D$esi+56
sub ecx eax
call 'USER32.OffsetRect' BoundingRect, ecx, 0
mov eax D$BoundingRect.left
If eax <s D@RcRight
call 'UxTheme.DrawThemeBackground' D$esi+PRO_DATA2._hThemeDis, D@hDC, ebx, 0, BoundingRect, D@pRect
mov B@ResultValue 01
End_If
.Test_End
...End_If
mov eax D@BarSize
...If eax <s 0
call 'UxTheme.GetThemePartSize' D$esi+PRO_DATA2._hThemeDis, D@hDC, D@iPartId, 0, D@pRect, &TS_TRUE, PtThemeHl
..If eax =>s 0
call ZeroMemory BoundingRect, Size_Of_RECT
call 'USER32.CopyRect' BoundingRect, D@pRect
.Test_If B$esi+PRO_DATA2.dwStyleDis &PBS_VERTICAL
mov D@hBufferedPaint 2
lea eax D@hBufferedPaint
call 'UxTheme.GetThemeEnumValue' D$esi+PRO_DATA2._hThemeDis, D@iPartId, 0, &TMT_VALIGN, eax
If D@hBufferedPaint = 0
mov eax D$PtThemeHl.y
mov ecx D$BoundingRect.top | add ecx eax
mov D$BoundingRect.bottom ecx
Else_If D@hBufferedPaint = 1
mov eax D$BoundingRect.bottom | sub eax D$BoundingRect.top
mov ecx D$PtThemeHl.y
sub eax ecx
cdq
sub eax edx
sar eax 1
add D$BoundingRect.top eax
mov eax D$BoundingRect.top
add eax ecx
mov D$BoundingRect.bottom eax
Else
mov eax D$BoundingRect.bottom | sub eax D$PtThemeHl.y
mov D$BoundingRect.top eax
End_if
.Test_Else
mov D@hBufferedPaint 0
lea eax D@hBufferedPaint
call 'UxTheme.GetThemeEnumValue' D$esi+PRO_DATA2._hThemeDis, D@iPartId, 0, &TMT_HALIGN, eax
If D@hBufferedPaint = 0
mov eax D$PtThemeHl.x
mov ecx D$BoundingRect.left
add ecx eax
mov D$BoundingRect.right ecx
Else_If D@hBufferedPaint = 1
mov eax D$BoundingRect.right
sub eax D$BoundingRect.left
mov ecx D$PtThemeHl.x
sub eax ecx
cdq
sub eax edx
sar eax 1
add D$BoundingRect.left eax
mov eax D$BoundingRect.left
add eax ecx
mov D$BoundingRect.right eax
Else
mov eax D$BoundingRect.right
sub eax D$PtThemeHl.x
mov D$BoundingRect.left eax
End_If
.Test_End
mov edi 01FF
call 'KERNEL32.MulDiv' D$esi+56, 01FF, D@BarSize
mov ebx eax
If ebx >s 255
sub edi ebx
mov ebx edi
End_If
mov eax D$BoundingRect.right | sub eax D$BoundingRect.left | mov D@pContentRect_rightDis eax
and D@pContentRect_leftDis 0
mov eax D$BoundingRect.bottom | sub eax D$BoundingRect.top | mov D@pContentRect_bottomDis eax
and D@pContentRect_topDis 0
;mov D$BP_PAINTPARAMS.cbSize Size_of_BP_PAINTPARAMS
;mov D$BP_PAINTPARAMS.dwFlags &BPPF_ERASE
;lea eax D@hdcDest
;call 'UxTheme.BeginBufferedPaint' D@hDC, D@pContentRect, 0, BP_PAINTPARAMS, eax
lea eax D@hdcDest
lea ecx D@hBmp
lea edx D@bmPrev
call BeginBufferedPaintXP D@hDC, D@pContentRect, eax, ecx, edx
.If eax <> 0
lea eax D@pContentRect
call 'UxTheme.DrawThemeBackground' D$esi+PRO_DATA2._hThemeDis, D@hdcDest, D@iPartId, 0, eax, 0
If eax =>s 0
mov B$BLENDFUNCTION.BlendOp &AC_SRC_OVER
mov B$BLENDFUNCTION.BlendFlags 0
mov B$BLENDFUNCTION.SourceConstantAlpha bl
mov B$BLENDFUNCTION.AlphaFormat &AC_SRC_ALPHA
mov eax D@pContentRect_bottomDis | sub eax D@pContentRect_topDis | mov D@heightSrc eax
mov eax D@pContentRect_rightDis | sub eax D@pContentRect_leftDis | mov D@widthSrc eax
mov eax D$BoundingRect.bottom | sub eax D$BoundingRect.top | mov D@heightDest eax
mov eax D$BoundingRect.right | sub eax D$BoundingRect.left
call 'GDI32.GdiAlphaBlend' D@hDC, D$BoundingRect.left, D$BoundingRect.top, eax, D@heightDest,
D@hdcDest, D@pContentRect_leftDis, D@pContentRect_topDis,
D@widthSrc, D@heightSrc, D$BLENDFUNCTION
End_If
mov B@ResultValue 01
;call 'UxTheme.EndBufferedPaint' D@hBufferedPaint, 0
.End_If
call EndBufferedPaintXP D@hdcDest, D@hBmp, D@bmPrev
..End_If
...End_If
mov al B@ResultValue
EndP
Best Regards
guga