读书人

LB_GETSELITEMS是不是不能在XP下使用?

发布时间: 2012-01-13 22:43:29 作者: rapoo

LB_GETSELITEMS是不是不能在XP下使用?
如题,代码贴出来了,测试全部为0,微软的说明上没说支持XP,不知道大家怎么看>


Public Sub mHighlightLBItem(ByVal LBHwnd As Long, _
ByVal x As Single, ByVal Y As Single) '获取多选条目下的listbox选中条目
Dim ItemIndex As Long
Dim AtThisPoint As POINTAPI
Dim FHwnd As Integer
Dim ItemIndexes() As Long, iNumItems As Integer

AtThisPoint.x = x \ Screen.TwipsPerPixelX
AtThisPoint.Y = Y \ Screen.TwipsPerPixelY
Call ClientToScreen(LBHwnd, AtThisPoint)
ItemIndex = LBItemFromPt(LBHwnd, AtThisPoint.x, _
AtThisPoint.Y, False)

iNumItems = 数据列字段设置.List1.SelCount
If iNumItems <> ItemIndex Then 数据列字段设置.List1.Selected((iNumItems)) = True
MsgBox SendMessage(LBHwnd, LB_GETSELITEMS, 0, 0)


End Sub

[解决办法]
不是无效!
SendMessage返回的不是选中的项目,返回的项目在第四个参数中,以数组形式,如下

VB code
Dim ItemIndexes() As Long, x As Integer, iNumItems As IntegeriNumItems = List1.SelCountIf iNumItems Then   ReDim ItemIndexes(iNumItems - 1)   SendMessage List1.hwnd, LB_GETSELITEMS, iNumItems, _     ItemIndexes(0)End Ifr = "你选择的是:"For x = 0 To iNumItems - 1   r = r & "(" & List1.List(ItemIndexes(x)) & ") "Next xMsgBox r 

读书人网 >VB

热点推荐