|
-
Oct 26th, 2002, 03:36 PM
#1
Thread Starter
Registered User
counting listview selected
Is it possible to count the number of files in listview as they are being selected when you draw the dotted box using the mouse in the listview
e.g. as soon as a file in the listview goes blue when the dotted box created with the mouse goes over it. is it possible to count the number of files selected and put the value into a text box.
does anyone know how to do this???
-
Oct 26th, 2002, 03:38 PM
#2
PowerPoster
Probably not the most accurate, but you can put code like this in your mousemove event:
VB Code:
Private Sub ListView_MouseMove(some arguments here)
Dim TotalSel As Long
For i = 1 To ListView.ListItems.Count
If ListView.ListItems(i).Selected = True Then
TotalSel = TotalSel + 1
End If
Next
End Sub
-
Oct 26th, 2002, 03:39 PM
#3
VB Code:
Option Explicit
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any) _
As Long
Private Const LVM_FIRST = &H1000
Private Const LVM_GETSELECTEDCOUNT = (LVM_FIRST + 50)
Private Sub Command1_Click()
MsgBox SendMessage(ListView1.hwnd, LVM_GETSELECTEDCOUNT, 0&, 0&)
End Sub
Untested, but try it.
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Oct 28th, 2002, 08:04 AM
#4
crptcblade' solution is the easiest, and the one I would suggest, but if you are going to go the MidgetsBro's route, the If/End If syntax needs to be changed slightly in order to work.
VB Code:
Private Sub ListView1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim i As Long
Dim TotalSel As Long
For i = 1 To ListView1.ListItems.Count
If ListView1.ListItems.Item(i).Selected = True Then
TotalSel = TotalSel + 1
End If
Next
End Sub
-
Oct 28th, 2002, 08:07 AM
#5
Originally posted by crptcblade
VB Code:
Option Explicit
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any) _
As Long
Private Const LVM_FIRST = &H1000
Private Const LVM_GETSELECTEDCOUNT = (LVM_FIRST + 50)
Private Sub Command1_Click()
MsgBox SendMessage(ListView1.hwnd, LVM_GETSELECTEDCOUNT, 0&, 0&)
End Sub
Untested, but try it.
how can you tell what messages you can send to an objects handle... is there documentation on what windows messages a listview will accept? I mean how would one figure this out? I trust that you didn't guess this up yourself..
-
Oct 28th, 2002, 08:20 AM
#6
Originally posted by kleinma
how can you tell what messages you can send to an objects handle... is there documentation on what windows messages a listview will accept? I mean how would one figure this out? I trust that you didn't guess this up yourself..
msdn.microsoft.com
For some reason these guys seem to know a hell of a lot of stuff.
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Oct 28th, 2002, 08:20 AM
#7
PowerPoster
Win32 API book by Dan Appelman is a very good source, but most of the time I personally do lots of researches: MS site is one of them. Most of the information is for C programmers (happend I do know C) but even you don't know it - it'll give general info that is simple enough to convert.
-
Oct 28th, 2002, 08:25 AM
#8
Originally posted by crptcblade
msdn.microsoft.com
For some reason these guys seem to know a hell of a lot of stuff.
i use the MSDN from time to time.. but i find it has SOOO much info that you often get lost looking for a simple answer...
-
Oct 28th, 2002, 08:27 AM
#9
Originally posted by kleinma
i use the MSDN from time to time.. but i find it has SOOO much info that you often get lost looking for a simple answer...
Yeah, most of the time you really need to know what you are looking for, which kind of defeats the purpose, I guess.
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Oct 28th, 2002, 08:31 AM
#10
For ListView specific stuff, download this .BAS file
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
|