Option ExplicitPrivate Const LB_ITEMFROMPOINT = &H1A9 private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As LongPrivate Sub List1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) Dim pos As Long, idx As Long
pos = X / Screen.TwipsPerPixelX + Y / Screen.TwipsPerPixelY * 65536 idx = SendMessage(List1.hwnd, LB_ITEMFROMPOINT, 0, ByVal pos)
If idx < 65536 Then list1.selected(idx)=true End Sub 参考一下
private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As LongPrivate Sub List1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim pos As Long, idx As Long
pos = X / Screen.TwipsPerPixelX + Y / Screen.TwipsPerPixelY * 65536
idx = SendMessage(List1.hwnd, LB_ITEMFROMPOINT, 0, ByVal pos)
If idx < 65536 Then list1.selected(idx)=true
End Sub
参考一下
答案是:否。
把ListBox的Style设为1
再拦截窗体的WM_DrawItem消息,再用绘图API画出不同颜色的项目就行了