dotnet / dotnet/winforms

ListViewHitTestLocations need to be updated for new ComCtl values

Open
#2,629 9 comments 3 reactions 2 assignees Claimed by @lonitra View on GitHub
api-suggestion enhancement
Dominant language
C#
Stars
4.9k
Forks
1.1k
Avg merge
1d 13m
Merged PRs (30d)
85

Description

**Background and motivation**
`ListViewHitTestLocations` is currently missing some values, the values should be updated to match the values specified in [LVHITTESTINFO](https://learn.microsoft.com/windows/win32/api/commctrl/ns-commctrl-lvhittestinfo). This will allow us to handle them in `ListView.HitTest`.

These values were missing because .NET framework supported Windows version older than Vista.

**API Proposal**
```csharp
[Flags]
public enum ListViewHitTestLocations
{
None = (int)LVHITTESTINFO_FLAGS.LVHT_NOWHERE,
AboveClientArea = 0x0100,
BelowClientArea = (int)LVHITTESTINFO_FLAGS.LVHT_BELOW,
LeftOfClientArea = (int)LVHITTESTINFO_FLAGS.LVHT_TOLEFT,
RightOfClientArea = (int)LVHITTESTINFO_FLAGS.LVHT_TORIGHT,
Image = (int)LVHITTESTINFO_FLAGS.LVHT_ONITEMICON,
StateImage = 0x0200,
Label = (int)LVHITTESTINFO_FLAGS.LVHT_ONITEMLABEL,
GroupHeader = (int)LVHITTESTINFO_FLAGS.LVHT_EX_GROUP_HEADER,
GroupFooter = (int)LVHITTESTINFO_FLAGS.LVHT_EX_GROUP_FOOTER,
GroupExpandCollapse = (int)LVHITTESTINFO_FLAGS.LVHT_EX_GROUP_COLLAPSE,
GroupBackground = unchecked((int)LVHITTESTINFO_FLAGS.LVHT_EX_GROUP_BACKGROUND),
GroupStateImage = (int)LVHITTESTINFO_FLAGS.LVHT_EX_GROUP_STATEICON,
GroupSubsetLink = (int)LVHITTESTINFO_FLAGS.LVHT_EX_GROUP_SUBSETLINK,
Group = GroupHeader | GroupFooter | GroupExpandCollapse | GroupBackground | GroupStateImage | GroupSubsetLink,
Contents = (int)LVHITTESTINFO_FLAGS.LVHT_EX_ONCONTENTS,
Footer = (int)LVHITTESTINFO_FLAGS.LVHT_EX_FOOTER,
}
```
**API Usage**
`ListViewHitTestLocations.GroupBackground`

**Alternative Designs**
N/A

**Risks**
Low risk as only adding missing enum values.

_Original Issue Comment_
# Problem
- We're missing the following definitions from `ListViewHitTestLocations`. These should be added to the public enum because currently we may have unknown values in `ListView.HitTest`

Name | Description
----- | -----
LVHT_EX_GROUP_HEADER | Windows Vista. The point is within the group header.
LVHT_EX_GROUP_FOOTER | Windows Vista. The point is within the group footer.
LVHT_EX_GROUP_COLLAPSE | Windows Vista. The point is within the collapse/expand button of the group.
LVHT_EX_GROUP_BACKGROUND | Windows Vista. The point is within the area of the group where items are displayed.
LVHT_EX_GROUP_STATEICON | Windows Vista. The point is within the state icon of the group.
LVHT_EX_GROUP_SUBSETLINK | Windows Vista. The point is within the subset link of the group.
LVHT_EX_GROUP | Windows Vista. LVHT_EX_GROUP_BACKGROUND \| LVHT_EX_GROUP_COLLAPSE \| LVHT_EX_GROUP_FOOTER \| LVHT_EX_GROUP_HEADER \| LVHT_EX_GROUP_STATEICON \| LVHT_EX_GROUP_SUBSETLINK.
LVHT_EX_ONCONTENTS | Windows Vista. The point is within the icon or text content of the item and not on the background.
LVHT_EX_FOOTER

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.