Hi,
I was looking for a way to use a static background image on a listview. I mean static, scrolling must not scroll the background image too.
Did a forum search and got little about the subject, so after playing got this and wanted to post for the records:
* Subclass the listview:
* In listview proc intercept %WM_VSCROLL and invalidaterect hwnd, BYVAL 0, 1 there.
* Intercept %WM_ERASEBKGND, createDC, bitblt (or stretchblt), deletedc.
Regards, GdS
I was looking for a way to use a static background image on a listview. I mean static, scrolling must not scroll the background image too.
Did a forum search and got little about the subject, so after playing got this and wanted to post for the records:
* Subclass the listview:
* In listview proc intercept %WM_VSCROLL and invalidaterect hwnd, BYVAL 0, 1 there.
* Intercept %WM_ERASEBKGND, createDC, bitblt (or stretchblt), deletedc.
Code:
oldproc = SetWindowLong(hlistview, %GWL_WNDPROC, CODEPTR(ListviewProc)) ListviewProc 0, 0, oldproc , 0 ... 'this assumes globals bitmap handle on hbackground and a bitmapinfo struc in bmpbackground FUNCTION listviewProc(BYVAL hWnd AS LONG, BYVAL wMsg AS LONG, BYVAL wParam AS LONG, BYVAL lParam AS LONG) EXPORT AS LONG static oldproc as dword local hBmpDC as long, rc as rect if hwnd = 0 then oldproc = wparam: exit function SELECT CASE AS LONG wmsg CASE %WM_VSCROLL invalidaterect hwnd, BYVAL 0, 1 CASE %WM_ERASEBKGND getclientrect hwnd, rc hBmpDC = CreateCompatibleDC(wparam) SelectObject hBmpDC, hbackground stretchBlt wparam, 0, 0, rc.nright - rc.nleft, rc.nbottom - rc.ntop, hBmpDC, 0, 0, bmpbackground.bmwidth, bmpbackground.bmheight, %SRCCOPY DeleteDC hBmpDC FUNCTION = 1: EXIT FUNCTION CASE %WM_DESTROY SetWindowLong(hWnd, %GWL_WNDPROC, OldProc) END SELECT FUNCTION = CallWindowProc(OldProc, hwnd, wMsg, wParam, lParam) END FUNCTION