News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Treeview with gradient background

Started by GM, June 28, 2005, 02:19:33 PM

Previous topic - Next topic

GM

Hi,
based on this link http://www.freevbcode.com/code/TreeViewGradient.zip
I'm trying to put a gradient background to the treeview control in \masm32\icztutes\tute19.

This is the proc of the subclassed treeview control.

.data
vert TRIVERTEX <0,0,0F000h,0f000h,0F000h,0>
TRIVERTEX <100,100,0,0,0f000h,0>
gRect GRADIENT_RECT <0,1>
bPainting dd FALSE

.data?
OldTreeViewProc dd ?

.code
NewTreeViewProc proc hWnd:dword, uMsg:dword, wParam:dword, lParam:dword
local TVDC :dword
local TempDC :dword
local oldBMP :dword
local TempBMP :dword
local ps :PAINTSTRUCT
local r: RECT

.if uMsg==WM_PAINT
.if bPainting==FALSE
mov bPainting, TRUE
invoke BeginPaint, hWnd, addr ps

invoke CreateCompatibleDC, ps.hdc
mov TempDC, eax

;create offscreen dc, bmp
invoke GetClientRect, hWnd, addr r
invoke CreateCompatibleBitmap, ps.hdc, r.right, r.bottom
mov TempBMP, eax
invoke SelectObject, TempDC, TempBMP
mov oldBMP, eax

;paint on memDC
invoke CallWindowProc, OldTreeViewProc, hWnd, WM_PAINT, TempDC, lParam

;Do gradient fill
mov eax, offset vert + sizeof(TRIVERTEX)
mov ecx,r.right
mov [eax],ecx
add eax, 4
mov ecx, r.bottom
mov [eax],ecx
invoke GradientFill, ps.hdc,addr vert,2,addr gRect,1,GRADIENT_FILL_RECT_V

;do transparent BitBlt
invoke GetSysColor, COLOR_WINDOW
invoke TransparentBlt, ps.hdc, 0, 0, r.right, r.bottom, TempDC, 0, 0, r.right, r.bottom, eax

;free handles
invoke SelectObject, TempDC, oldBMP
invoke DeleteObject, TempBMP
invoke DeleteDC, TempDC

invoke EndPaint, hWnd, addr ps
mov bPainting, FALSE
mov eax, 0
ret
.endif

.elseif uMsg==WM_ERASEBKGND
mov eax, 1
ret

.elseif (uMsg==WM_HSCROLL) || (uMsg==WM_VSCROLL) || (uMsg==WM_MOUSEWHEEL)
invoke InvalidateRect, hWnd, 0, FALSE
.else
.endif
invoke CallWindowProc, OldTreeViewProc, hWnd, uMsg, wParam, lParam
ret
NewTreeViewProc endp


For some reason that doesn't work. Any idea?

Thanks in advance.

GM

OK, I found a way to get it working.
But I have still a problem with flicker.
The problem is that I don't know how I can make the painting on a memory dc.
Acording to msdn I can send a WM_PAINT message with wParam = memDC, but that doesn't work. See my first post.

I've attached the source and binary code of my new program.

I hope that somebody can give me a hint. ::)



[attachment deleted by admin]