如何获得TLISTVIEW(report格式)光标位置的列号?(200分)

  • 主题发起人 主题发起人 dragonhu
  • 开始时间 开始时间
D

dragonhu

Unregistered / Unconfirmed
GUEST, unregistred user!
TLISTVIEW有函数可以获得当前光标所在的行(TListItem),
但如何取到列号->是Caption,还是SubItem(?).
直接用列宽计算我试过,要加常数(列线),但横向滚动后
处理很麻烦。
我的目的是给TLISTVIEW中显示不完全的列加Hint,有好的
控件也可作为答案。
(advListView不行,它不够精确,且无辕马)
 
用StringGrid不就可以很方便吗?
 
ListView_SubItemHitTest


INT ListView_SubItemHitTest(
HWND hwndLV,
LPLVHITTESTINFO pInfo
);
Determines which list view item or subitem is located at a given position. You can use this macro or send the LVM_SUBITEMHITTEST message explicitly.

Returns the index of the item or subitem tested, if any, or -1 otherwise. If an item or subitem is at the given coordinates, the fields of the LVHITTESTINFO structure will be filled with the applicable hit information.
hwndLV
Handle to the list view control that will be hit-tested.
pInfo
Address of an LVHITTESTINFO structure. ThePOINT structure within LVHITTESTINFO must be set to the client coordinates to be hit-tested.

--------------------------------------------------------------------------------
LVHITTESTINFO


typedef struct _LVHITTESTINFO {
POINT pt;
UINT flags;
int iItem;
int iSubItem;
} LVHITTESTINFO, FAR *LPLVHITTESTINFO;
Has been extended to accommodate subitem hit-testing. The LVHITTESTINFO structure contains information about a hit test. It is used in association with the LVM_HITTEST and LVM_SUBITEMHITTEST messages and their related macros. This structure supersedes the LV_HITTESTINFO structure.

pt
Position to hit test, in client coordinates.
flags
Variable that receives information about the results of a hit test. This member can be one or more of the following values: LVHT_ABOVE The position is above the control's client area.
LVHT_BELOW The position is below the control's client area.
LVHT_NOWHERE The position is inside the list view control's client window, but it is not over a list item.
LVHT_ONITEMICON The position is over a list view item's icon.
LVHT_ONITEMLABEL The position is over a list view item's text.
LVHT_ONITEMSTATEICON The position is over the state image of a list view item.
LVHT_TOLEFT The position is to the left of the list view control's client area.
LVHT_TORIGHT The position is to the right of the list view control's client area.

You can use LVHT_ABOVE, LVHT_BELOW, LVHT_TOLEFT, and LVHT_TORIGHT to determine whether to scroll the contents of a list view control. Two of these values may be combined. For example, if the position is above and to the left of the client area, you could use both LVHT_ABOVE and LVHT_TOLEFT.

You can test for LVHT_ONITEM to determine whether a specified position is over a list view item. This value is a bitwise-OR operation on LVHT_ONITEMICON, LVHT_ONITEMLABEL, and LVHT_ONITEMSTATEICON.

iItem
Receives the index of the matching item. Or if hit-testing a subitem, this value represents the subitem's parent item.
iSubItem
Version 4.70. Receives the index of the matching subitem. When hit-testing an item, this member will be zero.

--------------------------------------------------------------------------------
 
uses commctrl;

 
接受答案了.
 
后退
顶部