However, the mouse cursor still changes to the double-arrow resize cursor
when the mouse is over a column divider in the listview header.
How can I prevent the cursor change as well?
=== BEGIN CODE ===
Function WindowProc(ByVal hWnd As Long, ByVal uMsg As Long, _
ByVal wParam As Long, ByVal lParam As Long) As Long
Dim nmh As NMHDR
If uMsg = WM_NOTIFY Then
Call MoveMemory(nmh, ByVal lParam, Len(nmh))
Select Case nmh.code
Case HDN_BEGINTRACK, HDN_DIVIDERDBLCLICK
WindowProc = 1
Exit Function
End Select
End If
WindowProc = CallWindowProc(lpPrevWndProc, hWnd, uMsg, wParam, lParam)
End Function
=== END CODE ===
--
Tim Rude
tim...@NOSPAM.hotmail.com
(remove NOSPAM. for correct email address)
[Please reply via the newsgroup so all can benefit]
"Tim Rude" <tim...@NOSPAM.hotmail.com> wrote in message
news:O1eyxpDj...@TK2MSFTNGP15.phx.gbl...
--
Tim Rude
tim...@NOSPAM.hotmail.com
(remove NOSPAM. for correct email address)
[Please reply via the newsgroup so all can benefit]
"Rob" <none> wrote in message news:u6feb2F...@TK2MSFTNGP11.phx.gbl...
I fired up Spy++ and if I just watch the messages for the ListView's own
hwnd (the one exposed by the .hwnd property), there is no message fired when
I move over the header dividers and the cursor changes. It only gets
notification messages when a mouse button is depressed.
Spy++ shows a child window under the main ListView window named
'msvb_lib_header'. This is the window that gets the WM_SETCURSOR message.
But I don't know how to find the hwnd of this child window in VB to subclass
it and look for the WM_SETCURSOR message.
--
Tim Rude
tim...@NOSPAM.hotmail.com
(remove NOSPAM. for correct email address)
[Please reply via the newsgroup so all can benefit]
"Tim Rude" <tim...@NOSPAM.hotmail.com> wrote in message
news:#zIfekKj...@TK2MSFTNGP10.phx.gbl...
Regards,
Rob
"Tim Rude" <tim...@NOSPAM.hotmail.com> wrote in message
news:u7ZgI4Kj...@TK2MSFTNGP11.phx.gbl...
I was coming up with the EnumChildWindows/EnumChildProc callback to locate
the header hwnd. But I sure like your method a whole lot better.
BTW, since I'm preventing resizing of _all_ columns, subclassing the header
is as simple as returning 1 for any WM_SETCURSOR message. The cursor stays
as the standard pointer just like I wanted.
It seems kind of clunky to have to subclass both the listview and the header
to do all of this though. I wonder if there's a way to prevent column
resizing by subclassing only the header.
--
Tim Rude
tim...@NOSPAM.hotmail.com
(remove NOSPAM. for correct email address)
[Please reply via the newsgroup so all can benefit]
"Rob" <none> wrote in message news:egJNLVNj...@TK2MSFTNGP11.phx.gbl...
I would be cautious about using this method. This will work fine if the
pointer is moving from a header, which displays an arrow pointer anyway, to
the divider but won't work if the pointer is moving from something which
doesn't show an arrow to a divider.
> It seems kind of clunky to have to subclass both the listview and the
header
> to do all of this though. I wonder if there's a way to prevent column
> resizing by subclassing only the header.
It's possible but it's a bit more work because the most useful messages like
HDN_TRACK are sent to the header's parent window.
Essentially you subclass the WM_LBUTTONDOWN message. Use the HDM_HITTEST
message to determine which header your clicking on (if any). If you're on a
header Check that the HHT_ONDIVIDER or HHT_ONDIVOPEN flags are set. If they
are set then you're clicking on a divider so return 0 to prevent the header
from doing anything.
Air code (Header WndProc)
Dim hdhtiHotItem As HDHITTESTINFO
Dim iHotIndex As Long
Select Case uMsg
Case WM_LBUTTONDOWN
iHotIndex = SendMessage(m_hWnd, HDM_HITTEST, ByVal 0, hdhtiHotItem)
If (iHotIndex >= 0) Then
If (hdhtiHotItem.flags And (HHT_ONDIVIDER Or HHT_ONDIVOPEN)) Then
Exit Function 'Return 0
End If
End If
End Select
Reagrds
Rob
I've done a bit of testing regarding your cautionary warning, and you're
right. I overlaid a borderless textbox over a portion of the subclassed
listview header. The I-beam cursor from the textbox stays as an I-beam over
the listbox header if you move the mouse cursor from the textbox directly to
the listbox header. (But only if it's a borderless textbox - if it's got a
border, the border flips the cursor back to an arrow as it goes by). Good
catch!
However, in this app I know that there will never be a borderless textbox
over the listview and I'm pretty sure the odds are slim to none that anyone
will ever experience any cursor 'weirdness', or notice it if they do. In any
case, even if they do it's better than having the resize cursor show up when
resizing isn't allowed. I'm satisfied.
And as for the subclassing, your air-code didn't quite work right (locked me
up good) but that's ok. I'll just subclass both the LV and the header and be
fine with that. Thanks for your help!
--
Tim Rude
tim...@NOSPAM.hotmail.com
(remove NOSPAM. for correct email address)
[Please reply via the newsgroup so all can benefit]
"Rob" <none> wrote in message news:uZjsQKi...@TK2MSFTNGP11.phx.gbl...
Oops, I forgot to set the coordinates to actually hittest. This
definately works
Dim hdhtiHotItem As HDHITTESTINFO
Dim iHotIndex As Long
Select Case uMsg
Case WM_LBUTTONDOWN
hdhtiHotItem.pt.x = LoWord(lParam)
hdhtiHotItem.pt.y = HiWord(lParam)
iHotIndex = SendMessage(m_hWnd, HDM_HITTEST, ByVal 0, hdhtiHotItem)
If (iHotIndex >= 0) Then
If (hdhtiHotItem.flags And (HHT_ONDIVIDER Or HHT_ONDIVOPEN)) Then
Exit Function
Do you think either method is inherently more reliable than the other for
preventing column resizing (i.e. subclassing LV for notifications vs.
subclassing LV-Header for WM_LBUTTONDOWN messages)?
I do like getting it all done with one subclassing, just wondering if there
are any gotcha's.
--
Tim Rude
tim...@NOSPAM.hotmail.com
(remove NOSPAM. for correct email address)
[Please reply via the newsgroup so all can benefit]
"Rob" <none> wrote in message news:OX0FZ5k...@tk2msftngp13.phx.gbl...
Changing the case test to the following should do the trick
Case WM_LBUTTONDOWN, WM_LBUTTONDBLCLK
--
Tim Rude
tim...@NOSPAM.hotmail.com
(remove NOSPAM. for correct email address)
[Please reply via the newsgroup so all can benefit]
"Rob" <none> wrote in message news:eDWB283j...@TK2MSFTNGP12.phx.gbl...