-
May 11th, 2016, 01:10 AM
#1
Thread Starter
Hyperactive Member
Listview Column Header BugFix
- How do I hover/hot focus listview column from code.
- How to click a column via code (when one clicks a manifested listview column header..it behaves like a button:: sunken and raised effect...how to do that via coding)
LucasMKG
?
Last edited by LucasMKG; May 12th, 2016 at 03:51 AM.
-
May 11th, 2016, 03:31 AM
#2
Re: Hover/Hot Listview Column
Originally Posted by LucasMKG
- How do I hover/hot focus listview column from code.
Try sending the HDM_SETFOCUSEDITEM message to the header control.
Originally Posted by LucasMKG
- How to click a column via code (when one clicks a manifested listview column header..it behaves like a button:: sunken and raised effect...how to do that via coding)
Send a pair of WM_LBUTTONDOWN and WM_LBUTTONUP messages to it. You'll probably have to send the HDM_GETITEMRECT message first in order to obtain the correct coordinates.
On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)
-
May 11th, 2016, 04:15 AM
#3
Thread Starter
Hyperactive Member
Re: Hover/Hot Listview Column
Thanks Bonnie West,
But HDM_SETFOCUSEDITEM doesn't help...or it might be that I'm executing it incorrectly.
Code:
SendMessage(m_hWnd, HDM_SETFOCUSEDITEM, 0, nIndex)
, test it and see if you'll be able to get the column header focus.
LucasMKG
.
Last edited by LucasMKG; May 11th, 2016 at 04:20 AM.
-
May 11th, 2016, 05:05 AM
#4
Thread Starter
Hyperactive Member
Re: Hover/Hot Listview Column
Bonnie West,
Originally Posted by Bonnie West
Cell focus rectangle shifts to the correct row...but the column isn't clicked (column header button clicked effect is not showing nor focus/highlighting thereof)
Code:
'My take:
If LeftKeyState Then
PostMessage m_lHdrHwnd, WM_LBUTTONDOWN, vbLeftButton, ByVal True
PostMessage m_lHdrHwnd, WM_LBUTTONUP, vbLeftButton, ByVal True
...
, and also HDM_SETITEM or my take on it doesn't produce desired results
Code:
'My take:
Dim uHDI as HDITEM
With uHDI
.Mask = HDI_FORMAT
SendMessage m_lHdrHwnd, HDM_GETITEM, 2, ByVal VarPtr(uHDI)
.State = .State Or HDIS_FOCUSED
.Mask = .Mask Or HDI_STATE
End With
SendMessage m_lHdrHwnd, HDM_SETITEM, nIndex, ByVal VarPtr(uHDI)
Note, definitely my take is incorrect..so what's your take on these issues?
LucasMKG
.
Last edited by LucasMKG; May 11th, 2016 at 05:17 AM.
-
May 11th, 2016, 08:08 AM
#5
Re: Hover/Hot Listview Column
Well when the columns are click you get a WM_NOTIFY message of NM_ITEMCLICK (A or W depending on your unicode situation re: WM_NOTIFYFORMAT) in the WndProc for the ListView, since presumably your ListView is subclassed anyway you could try calling the WndProc with that, assuming you don't cancel it and the message continues to DefSubclassProc. Just a thought, I'm pretty tired right now.
-
May 11th, 2016, 08:15 AM
#6
Thread Starter
Hyperactive Member
Re: Hover/Hot Listview Column
fafalone,
you're contributing a lot to VB6..and I would rather have you fully-charged.
LucasMKG
...
-
May 12th, 2016, 02:42 AM
#7
Thread Starter
Hyperactive Member
Re: Hover/Hot Listview Column
- How do I hover/hot focus listview column from code.
...will LVM_SETHOTITEM work in Column header?
EDIT:: If I can have Column hover/hot focus or whatever it's called...and button click simulation for column headers : the column header bug will be solved.
Bugfix:
the unresponsive click and mouse move events will be trapped in the [WM_SETCURSOR HdrHitHorzSizer]...since it won't register with HDN_BEGINTRACK, LVN_COLUMNCLICK,NM_CLICK and WM_LBUTTONDOWN.
NB: If what I asked in thread #1 is provided, the rest will be sorted-out effortlessly.::
LucasMKG
..
Last edited by LucasMKG; May 12th, 2016 at 03:10 AM.
-
May 12th, 2016, 03:30 AM
#8
Thread Starter
Hyperactive Member
Re: Hover/Hot Listview Column
To get the bug I'm referring to:
- just have 2 or more listview columns (the listview has to be manifested)
- move your cursor slowly towards the end of the first column..just before you approach the1st column boundary line you will be welcomed by the 'west/east sizing cursor' prematurely. that will persist until you far pass the 1st column boundary line until almost (2/10) in the second column.
That is what I'm trying to address
- you will note that even when your almost (2/10) in the second column the hot focus is still in the first column...and the mouse clicks won't register..but can be trapped as per thread #7.
It's not just for cosmetics/looks..the bug is so nasty that when the second column is having a checkbox, roughly (2/10) of the checkbox can't be clicked or the 'west/east sizing cursor' is still there.
LucasMKG
.....
Last edited by LucasMKG; May 12th, 2016 at 03:44 AM.
-
May 12th, 2016, 03:13 PM
#9
Re: Hover/Hot Listview Column
Originally Posted by LucasMKG
But HDM_SETFOCUSEDITEM doesn't help...or it might be that I'm executing it incorrectly.
Yeah, I thought it would work, but when I tried it myself, it did nothing noticeable.
Originally Posted by Bonnie West
Sorry, but I couldn't get this to work properly either (only the 1st column gets clicked).
Originally Posted by LucasMKG
To get the bug I'm referring to:
. . .
the bug is so nasty ...
I don't think it's a bug at all. The ListView developers most likely designed it that way in order to take into account Fitts's law (i.e., a narrow area is harder/slower to target than a wider one).
Last edited by Bonnie West; May 12th, 2016 at 03:38 PM.
On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)
-
May 12th, 2016, 05:30 PM
#10
Re: Listview Column Header BugFix
I suspect that the "headers" are a sub-control (see Header Control). As such you probably have to enumerate the child windows of the ListView window to locate the correct hWnd to send the message to.
-
May 13th, 2016, 01:49 AM
#11
Thread Starter
Hyperactive Member
Re: Listview Column Header BugFix
HDM_SETFOCUSEDITEM acts like LVM_ENSUREVISIBLE for column header.
LucasMKG
.....
-
May 15th, 2016, 03:08 AM
#12
Thread Starter
Hyperactive Member
Re: Listview Column Header BugFix
dilettante,
Originally Posted by dilettante
I suspect that the "headers" are a sub-control (see Header Control). As such you probably have to enumerate the child windows of the ListView window to locate the correct hWnd to send the message to.
I'm sending messages to the correct hWnd
Code:
M_lHdrHwnd = SendMessageLong (m_lHGHwnd, LVM_GETHEADER, 0&, ByVal 0&)
LucasMKG
.
-
May 23rd, 2016, 01:46 AM
#13
Thread Starter
Hyperactive Member
Re: Hover/Hot Listview Column
Originally Posted by LucasMKG
...
Bugfix:
the unresponsive click and mouse move events will be trapped in the [WM_SETCURSOR HdrHitHorzSizer]...since it won't register with HDN_BEGINTRACK, LVN_COLUMNCLICK,NM_CLICK and WM_LBUTTONDOWN.
....
.. I was wrong, HDN_BEGINTRACK respond..and WM_SETCURSOR respond after second click :: So HDN_BEGINTRACK is the best option for capturing checkbox click and mouse click events in that buffer_zone.
LucasMKG
...giving up is not registering in my vocabulary..
To all those who responded in this thread..thanks.
Last edited by LucasMKG; May 23rd, 2016 at 01:54 AM.
-
May 23rd, 2016, 11:34 PM
#14
Re: Listview Column Header BugFix
Capturing a column header checkbox click?
It fires a HDN_ITEMCHANGED notification. Seem to get one when the sizer is clicked too.
-
May 24th, 2016, 12:36 AM
#15
Thread Starter
Hyperactive Member
Re: Listview Column Header BugFix
fafalone,
true HDN_ITEMCHANGED fires..but not in the buffer_zone as per thread #8
- Try to click the first 2/10 of the checkbox..to see what I mean.
EDIT:: HDM_SETFOCUSEDITEM Header_SetFocusedItem ... returns True (only for Listview_header_hWnd as per thread #12)..but the header focus doesn't change..
LucasMKG
..
Last edited by LucasMKG; May 24th, 2016 at 03:47 AM.
-
May 25th, 2016, 02:15 AM
#16
Thread Starter
Hyperactive Member
Re: Listview Column Header BugFix
Listview Column Header:
Done & dusted...
- Locked column: preventing locked column from being sized, prevent locked column checkbox from being clicked
- Buffer_zone: checkbox..and non checkbox area.
- West/East sizing (adjusted) + custom cursors...for [explorer theme]
- Sizing column height (North/South sizing)...for [explorer theme]
- Custom Tooltips...for [explorer themes]
- Multiline_Column_Header (or whatever it's called) ...only for [skinned headers]
Still waiting for assistance with:
- How do I hover/hot focus listview column from code.
- How to click a column via code (when one clicks a manifested listview column header..it behaves like a button:: sunken and raised effect...how to do that via coding)
.. the rest (below listed) I'll do it myself:
[TODO...tweak: explorer theme header: custom sort arrow, custom drag&drop, custom filter (don't like the ugly standard filter) and adding checkbox in skinned header.]
LucasMKG
...slowly but surely making progress
when I'm done with vhGrid..even the author won't recognize it.. (hope I don't mess it up)
Last edited by LucasMKG; May 25th, 2016 at 03:21 AM.
-
Mar 16th, 2022, 02:13 AM
#17
Thread Starter
Hyperactive Member
Re: Listview Column Header BugFix
from this
Code:
Private Const HHT_NOWHERE As Long = &H1
Private Const HHT_ONHEADER As Long = &H2
Private Const HHT_ONDIVIDER As Long = &H4
Private Const HHT_ONDIVOPEN As Long = &H8
How do you get the red marked area fromf the column header first colum
for the benefit of the vb community, let me post this (warning not trimmed)
else where:
Code:
Friend Function HeaderHitTest() As EHdrHitTest
Dim lColumn As Long
Dim lHzOffset As Long
Dim tPnt As POINTAPI
Dim tRect As RECT
Dim tRcpy As RECT
Dim tRcpyChkBox As RECT 'Seal.added ColumnCheckboxes
Dim tRBtn As RECT
Dim tRBtnChkBox As RECT 'Seal.added ColumnCheckboxes
Dim tHdHit As HD_HITTESTINFO
GetCursorPos tPnt
ScreenToClient m_lHdrHwnd, tPnt
With tHdHit
.pt = tPnt
SendMessageA m_lHdrHwnd, HDM_HITTEST, 0&, tHdHit
lColumn = .iItem
's.......Seal.relocated
If m_bIsNt Then
SendMessageW m_lHdrHwnd, HDM_GETITEMRECT, lColumn, tRect
Else
SendMessageA m_lHdrHwnd, HDM_GETITEMRECT, lColumn, tRect
End If
CopyRect tRcpy, tRect
'e.......Seal.relocated
If Not (lColumn = -1) Then
m_lSelectedColumn = lColumn
Select Case .flags
Case HHT_NOWHERE
HeaderHitTest = HdrOffColumn
Case HHT_ONDIVIDER, HHT_ONDIVOPEN
HeaderHitTest = HdrHitHorzSizer
's.......Seal.added: ColumnCheckboxes-Buffer
If Not (lColumn = 0) Then
With tRect
.left = .Right + 4 'Seal.added [ColumnCheckboxes-Buffer] HdrHitHorzSizer
.Right = .left + 4 'Seal.added [ColumnCheckboxes-Buffer] HdrHitHorzSizer
End With
If Not (PtInRect(tRect, tPnt.x, tPnt.y) = 0) Then
HeaderHitTest = HdrHitCheckboxes_Buffer 'Seal.added [ColumnCheckboxes-Buffer] HdrHitHorzSizer
'Debug.Print "HdrHitHorzSizer: .x " & tPnt.x & " .y: " & tPnt.y
End If
End If
'e.......Seal.added: ColumnCheckboxes-Buffer
Case HHT_ONHEADER
'rem.Seal: Relocated If m_bIsNt Then
'rem.Seal: Relocated SendMessageW m_lHdrHwnd, HDM_GETITEMRECT, lColumn, tRect
'rem.Seal: Relocated Else
'rem.Seal: Relocated SendMessageA m_lHdrHwnd, HDM_GETITEMRECT, lColumn, tRect
'rem.Seal: Relocated End If
'rem.Seal: Relocated CopyRect tRcpy, tRect
CopyRect tRcpyChkBox, tRect 'Seal.added ColumnCheckboxes
With tRect
.top = .Bottom - 2 '8 'Seal.modified [8 to 2] HdrHitVertSizer
.Bottom = .Bottom + 2 '8 'Seal.modified [8 to 2] HdrHitVertSizer
End With
If Not (PtInRect(tRect, tPnt.x, tPnt.y) = 0) Then
HeaderHitTest = HdrHitVertSizer
Else
' If m_bColumnFilters Then 'Seal.added: bug (If m_bColumnFiltered(lColumn) Then)
' If m_bColumnFiltered(lColumn) Then
' lHzOffset = ((tRcpy.Bottom \ 2) - 7)
' With tRBtn
' If (lColumn = m_lColumnSorted) Then
' .left = tRcpy.left + ((tRcpy.Right - tRcpy.left) - 44)
' .Right = (tRcpy.Right - 30)
' Else
' .left = ((tRcpy.left + (tRcpy.Right - tRcpy.left)) - 20)
' .Right = (tRcpy.Right - 4)
' End If
' .top = lHzOffset
' .Bottom = (lHzOffset + 14)
' End With
' With tPnt
' If Not (PtInRect(tRBtn, .x, .y) = 0) Then
' HeaderHitTest = HdrHitFilter
' Else
' HeaderHitTest = HdrHitColumn
' End If
' End With
' End If
's........Seal.added.ColumnCheckboxes adopted from ColumnFilter
' ElseIf m_bColumnCheckboxes(lColumn) Then
If m_bColumnCheckboxes(lColumn) Then
lHzOffset = ((tRcpyChkBox.Bottom - tRcpyChkBox.top) - 14) / 2 'Seal.modified (to centre ColumnCheckBox
With tRBtnChkBox
If (lColumn = m_lColumnSorted) Then
.left = tRcpyChkBox.left '+ 1 '(tRcpyChkBox.Right - tRcpyChkBox.left)) - 20)
.Right = tRcpyChkBox.left + 17 '(tRcpyChkBox.Right - 4)
End If
.top = lHzOffset
.Bottom = (lHzOffset + 13)
End With
With tPnt
If Not (PtInRect(tRBtnChkBox, .x, .y) = 0) Then
HeaderHitTest = HdrHitCheckboxes
'Debug.Print "HdrHitCheckboxes: .x " & .x & " .y: " & .y
Else
HeaderHitTest = HdrHitColumn
End If
End With
'. End If
'e........Seal.added.ColumnCheckboxes adopted from ColumnFilter
Else
HeaderHitTest = HdrHitColumn
End If
End If
End Select
Else
HeaderHitTest = HdrOffColumn
End If
End With
End Function
In WndProc (vhGrid...clsSkinHeader):
Code:
Case WM_LBUTTONDOWN
m_eHeaderLastHitState = HeaderHitTest
If m_bToolTips Then
m_cColumnToolTip.StopTimer
End If
Select Case m_eHeaderLastHitState
Case HdrHitHorzSizer
If ArrayCheck(m_lSelectedColumn) Then 'BugFix - Seal.added :: HdrHitHorzSizer - Err.9: (Subscript out of range) is triggered
If m_bColumnLocked(m_lSelectedColumn) Then
lReturn = 1
bHandled = True
End If
End If
m_lCurrState = 0
Case HdrHitVertSizer
m_bClickInColumnSizer = True
m_lCurrState = 0
Case HdrHitFilter
m_lCurrState = 0
Case HdrHitCheckboxes 'Seal.added.ColumnCheckboxes adopted from ColumnFilter
If m_bColumnCheckboxes(m_lSelectedColumn) Then
Debug.Print "clicked :: Column: " & m_lSelectedColumn
lReturn = 1
bHandled = True
End If
m_lCurrState = 0
Case HdrHitCheckboxes_Buffer 'Seal.added [ColumnCheckboxes-Buffer] HdrHitHorzSizer
'HdrHitCheckboxes_Buffer = 6& 'Seal.added [ColumnCheckboxes-Buffer] HdrHitHorzSizer
Dim lColumn As Long
lColumn = (m_lSelectedColumn + 1)
If lColumn <= Cols Then
If m_bColumnCheckboxes(lColumn) Then
Debug.Print "Buffer clicked of :: Column: " & lColumn
lReturn = 1
bHandled = True
End If
m_lCurrState = 0
End If
Case HdrHitColumn
If m_bDragState Then
m_lCurrState = 0
Else
m_lCurrState = 1
End If
End Select
SendMessageLongA lHwnd, WM_PAINT, 0&, 0&
LucasMKG
?
Last edited by LucasMKG; Mar 16th, 2022 at 02:32 AM.
-
Mar 16th, 2022, 04:22 AM
#18
Re: Listview Column Header BugFix
A lot more flags have been added...
Code:
Public Enum HeaderHitTestFlags
HHT_NOWHERE = &H1
HHT_ONHEADER = &H2
HHT_ONDIVIDER = &H4
HHT_ONDIVOPEN = &H8
'#if (_WIN32_IE >= =&h0500)
HHT_ONFILTER = &H10
HHT_ONFILTERBUTTON = &H20
'#End If
HHT_ABOVE = &H100
HHT_BELOW = &H200
HHT_TORIGHT = &H400
HHT_TOLEFT = &H800
'#if _WIN32_WINNT >= =&h0600
HHT_ONITEMSTATEICON = &H1000
HHT_ONDROPDOWN = &H2000
HHT_ONOVERFLOW = &H4000
End Enum
That red area, if it's not considered a header or a divider, would belong to the state icon (the checkbox, they're actually icons you can replace, or have more than 2 of, via HDM_SETIMAGELIST/HSDIL_STATE).
-
Mar 16th, 2022, 05:01 AM
#19
Thread Starter
Hyperactive Member
Re: Listview Column Header BugFix
faf,
as for HSDIL_STATE, i've never seen it used anywhere
but, as for HDM_SETIMAGELIST
vhGrid add columns by using it
Code:
SendMessageLong m_lHdrHwnd, HDM_SETIMAGELIST, 0&, ByVal m_lImgLstColumnHeaderHndl
But which HeaderHitTestFlags will trigger a click or mousemove in the red area?
LucasMKG
?
-
Mar 16th, 2022, 05:27 AM
#20
Re: Listview Column Header BugFix
Not sure what you mean... hit tests tell you what's at a point, you can't trigger a click event with one.
-
Mar 16th, 2022, 06:12 AM
#21
Thread Starter
Hyperactive Member
Re: Listview Column Header BugFix
exactly, which flag would best track the mousemove point?
just try those flags, they won't even register x or y points @ the area i specifying :: or the issue is the way i sortoff 'code'
LucasMKG
..
Last edited by LucasMKG; Mar 16th, 2022 at 06:16 AM.
-
Mar 16th, 2022, 08:21 AM
#22
Re: Listview Column Header BugFix
Oh ok then yeah like I said, if it's not on the header, it's on the state icon. It can be on the header but not an a header item too ('nowhere'). 0 would be completely off the control.
What is HDM_HITTEST actually returning, in raw values? Return value, iItem value, and Flags value?
-
Mar 17th, 2022, 02:15 AM
#23
Thread Starter
Hyperactive Member
Re: Listview Column Header BugFix
Originally Posted by fafalone
...if it's not on the header, it's on the state icon
Perfect, u're just awesome
Originally Posted by fafalone
A lot more flags have been added...
Code:
Public Enum HeaderHitTestFlags
HHT_NOWHERE = &H1
HHT_ONHEADER = &H2
HHT_ONDIVIDER = &H4
HHT_ONDIVOPEN = &H8
'#if (_WIN32_IE >= =&h0500)
HHT_ONFILTER = &H10
HHT_ONFILTERBUTTON = &H20
'#End If
HHT_ABOVE = &H100
HHT_BELOW = &H200
HHT_TORIGHT = &H400
HHT_TOLEFT = &H800
'#if _WIN32_WINNT >= =&h0600
HHT_ONITEMSTATEICON = &H1000
HHT_ONDROPDOWN = &H2000
HHT_ONOVERFLOW = &H4000
End Enum
....
HHT_ONITEMSTATEICON..does it, and it seems it ONLY tracks 'red area' in 1st column
LucasMKG
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|