Ownerdraw works with ListView 5.0 but not with ListView 6.0 
Author Message
 Ownerdraw works with ListView 5.0 but not with ListView 6.0

I am trying to modify a virtual ListView found on the net.
It uses the ListView from MS Common Controls 5.0. When I
replace the ListView in the UserControl with the ListView
from MS Common Controls 6.0 it crashes ?!?

I hav narrowed the problem to the following function that
sets the LVS_OWNERDATA in the ListView during creation. If I
remove the line

    "Call SetWindowLong(hWnd, GWL_STYLE, C.style)"

...from the code below it does not crash, but off cource I
do now receive the needed LVN_GETDISPINFO messages.

The original full project can be downloaded here:
http://"www.mvps.org/vbvision/_samples/Virtual ListView

If anyone successfully replaces the 5.0 ListView with a 6.0
ListView, then please telle me how

PS. I am aware that the classname for the 5.0 ListView is
"ListViewWndClass" and for the 6.0 ListView it is
"ListView20WndClass" (it is used elsewhere in the program).

// Code that goes wrong
Public Function VirtualListOrStyle_WndProc(ByVal hWnd As
Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam
As Long) As Long
    ' we set this subclass up in the VirtualListAppHook
function and now we can actually set
    ' the window styles of the listbox to what we want them
to be.
    ' check for a WM_CREATE message
    Select Case Msg
        Case WM_CREATE
            Dim C As CREATESTRUCT
            ' when we get the message, copy the creation
struct to our local variable
            CopyMemory C, ByVal lParam, Len(C)
            ' then add the styles we want....
            C.style = C.style Or LVS_OWNERDATA
            ' copy our altered local struct back to the one
that was passed by windows
            CopyMemory ByVal lParam, C, Len(C)
            ' alter the styles in the actual window data
            Call SetWindowLong(hWnd, GWL_STYLE, C.style)
            ' release this subclass since we have
accomplished what we came here for
            Call SetWindowLong(hWnd, GWL_WNDPROC,
    End Select
    ' pass all messages on to the default windowproc
    VirtualListOrStyle_WndProc =
CallWindowProc(m_hHookWndProc, hWnd, Msg, wParam, lParam)
End Function


/\ preben nielsen

Thu, 26 Feb 2004 22:09:51 GMT  
 [ 1 post ] 

 Relevant Pages 

1. Ownerdraw works with ListView 5.0 but not with ListView 6.0 (in this sample)

2. VB 6.0/5.0 and ListViews

3. VB 6.0/5.0 and ListViews

4. Listview 6.0 does not generate MouseUp event when performing multiselect

5. OwnerDraw ListView Headers

6. Ownerdrawn columnheader in (report) listview example, wanted

7. Ownerdrawn columnheader in (report) listview example, wanted

8. MouseMove event in ListView does not trigger when ListView in Small/Large Icon View mode

9. ItemCheck event on Listviews not working as expected

10. Why does not format work with listviews?

11. ListView.FindItem not working when sorted

12. Tooltip for ListView Report-View does not work


Powered by phpBB® Forum Software