Skip to content

Commit cba8137

Browse files
committed
Initial commit
0 parents  commit cba8137

File tree

6 files changed

+301
-0
lines changed

6 files changed

+301
-0
lines changed

.gitattributes

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# VB6 source files (show diff + keep CRLF in zip download)
2+
3+
*.bas working-tree-encoding=CP1252 text eol=crlf linguist-language=vb6
4+
*.cls working-tree-encoding=CP1252 text eol=crlf linguist-language=vb6
5+
*.ctl working-tree-encoding=CP1252 text eol=crlf linguist-language=vb6
6+
*.dob working-tree-encoding=CP1252 text eol=crlf linguist-language=vb6
7+
*.dsr working-tree-encoding=CP1252 text eol=crlf linguist-language=vb6
8+
*.frm working-tree-encoding=CP1252 text eol=crlf linguist-language=vb6
9+
*.pag working-tree-encoding=CP1252 text eol=crlf linguist-language=vb6
10+
*.vbg working-tree-encoding=CP1252 text eol=crlf
11+
*.vbl working-tree-encoding=CP1252 text eol=crlf
12+
*.vbp working-tree-encoding=CP1252 text eol=crlf
13+
*.vbr working-tree-encoding=CP1252 text eol=crlf
14+
*.vbw working-tree-encoding=CP1252 text eol=crlf
15+
16+
# Other source files (show diff + LF only in zip download)
17+
18+
*.asm text
19+
*.asp text
20+
*.bat text
21+
*.c text
22+
*.cpp text
23+
*.dsp text
24+
*.dsw text
25+
*.h text
26+
*.idl text
27+
*.java text
28+
*.js text
29+
*.manifest text
30+
*.odl text
31+
*.php text
32+
*.php3 text
33+
*.rc text
34+
*.sln text
35+
*.sql text
36+
*.vb text
37+
*.vbs text
38+
39+
# Binary
40+
41+
*.res binary
42+
*.frx binary
43+
*.ctx binary
44+
*.dsx binary
45+
*.exe binary
46+
*.dll binary
47+
*.ocx binary
48+
*.cmp binary
49+
*.pdb binary
50+
*.tlb binary
51+
*.xls binary
52+
*.doc binary
53+
*.ppt binary
54+
*.xlsx binary
55+
*.docx binary
56+
*.pptx binary
57+
*.chm binary
58+
*.hlp binary
59+
*.jpg binary
60+
*.png binary
61+
*.bmp binary
62+
*.gif binary
63+
*.ico binary
64+
*.zip binary
65+
*.cab binary
66+
*.7z binary
67+
*.gz binary
68+
69+
# Text files but keep as binary (no diff)
70+
71+
# *.cfg text
72+
# *.conf text
73+
# *.csi text
74+
# *.css text
75+
# *.csv text
76+
# *.def text
77+
# *.htm text
78+
# *.html text
79+
# *.inf text
80+
# *.ini text
81+
# *.log text
82+
# *.reg text
83+
# *.rtf text
84+
# *.txt text
85+
# *.url text
86+
# *.xml text

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
*.scc
2+
*.dca
3+
*.oca
4+
*.obj
5+
vb*.tmp
6+
@PSC*

Form1.frm

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
VERSION 5.00
2+
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
3+
Begin VB.Form Form1
4+
Caption = "Form1"
5+
ClientHeight = 3765
6+
ClientLeft = 60
7+
ClientTop = 345
8+
ClientWidth = 8220
9+
LinkTopic = "Form1"
10+
ScaleHeight = 3765
11+
ScaleWidth = 8220
12+
StartUpPosition = 3 'Windows Default
13+
Begin VB.TextBox Text1
14+
Height = 2895
15+
Left = 4560
16+
MultiLine = -1 'True
17+
ScrollBars = 3 'Both
18+
TabIndex = 3
19+
Top = 120
20+
Width = 3615
21+
End
22+
Begin VB.CommandButton Command2
23+
Caption = "Copy selected items to textbox"
24+
Height = 375
25+
Left = 4560
26+
TabIndex = 2
27+
Top = 3120
28+
Width = 3615
29+
End
30+
Begin VB.CommandButton Command1
31+
Caption = "Count the selected items"
32+
Height = 375
33+
Left = 120
34+
TabIndex = 1
35+
Top = 3120
36+
Width = 4335
37+
End
38+
Begin MSComctlLib.ListView lvwDetails
39+
Height = 2895
40+
Left = 120
41+
TabIndex = 0
42+
Top = 120
43+
Width = 4335
44+
_ExtentX = 7646
45+
_ExtentY = 5106
46+
MultiSelect = -1 'True
47+
LabelWrap = -1 'True
48+
HideSelection = -1 'True
49+
_Version = 393217
50+
ForeColor = -2147483640
51+
BackColor = -2147483643
52+
BorderStyle = 1
53+
Appearance = 1
54+
NumItems = 0
55+
End
56+
End
57+
Attribute VB_Name = "Form1"
58+
Attribute VB_GlobalNameSpace = False
59+
Attribute VB_Creatable = False
60+
Attribute VB_PredeclaredId = True
61+
Attribute VB_Exposed = False
62+
Option Explicit
63+
64+
65+
Private Sub Command1_Click()
66+
67+
MsgBox CountSelectedItemsInListview(lvwDetails) & " item(s) are selected"
68+
End Sub
69+
70+
Private Sub Command2_Click()
71+
Dim itemx As ListItem
72+
Dim myCol As Collection
73+
74+
Set myCol = GetSelectedItemsFromListview(lvwDetails)
75+
Text1.Text = ""
76+
77+
For Each itemx In myCol
78+
Text1.Text = Text1.Text & itemx.Text & vbCrLf
79+
Next itemx
80+
End Sub
81+
82+
Private Sub Form_Load()
83+
Dim i
84+
85+
'Add some items in listview
86+
87+
For i = 1 To 100
88+
lvwDetails.ListItems.Add , , i
89+
Next i
90+
91+
92+
End Sub
93+

Project1.vbp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
Type=Exe
2+
Form=Form1.frm
3+
Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#C:\WINNT\System32\stdole2.tlb#OLE Automation
4+
Object={831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0; MSCOMCTL.OCX
5+
Module=modListview; modListview.bas
6+
IconForm="Form1"
7+
Startup="Form1"
8+
Command32=""
9+
Name="Project1"
10+
HelpContextID="0"
11+
CompatibleMode="0"
12+
MajorVer=1
13+
MinorVer=0
14+
RevisionVer=0
15+
AutoIncrementVer=0
16+
ServerSupportFiles=0
17+
VersionCompanyName="Fleur-IT"
18+
CompilationType=0
19+
OptimizationType=0
20+
FavorPentiumPro(tm)=0
21+
CodeViewDebugInfo=0
22+
NoAliasing=0
23+
BoundsCheck=0
24+
OverflowCheck=0
25+
FlPointCheck=0
26+
FDIVCheck=0
27+
UnroundedFP=0
28+
StartMode=0
29+
Unattended=0
30+
Retained=0
31+
ThreadPerObject=0
32+
MaxNumberOfThreads=1

README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<div align="center">
2+
3+
## Counting en Getting Selected listview items with the SendMessage Api
4+
5+
6+
</div>
7+
8+
### Description
9+
10+
!! Update !!
11+
12+
Now counting the selected items in a listview
13+
14+
and get the selected items quick from the listview
15+
16+
### More Info
17+
18+
19+
20+
<span> |<span>
21+
--- |---
22+
**Submitted On** |2003-09-22 13:35:12
23+
**By** |[pvdv](https://github.com/Planet-Source-Code/PSCIndex/blob/master/ByAuthor/pvdv.md)
24+
**Level** |Intermediate
25+
**User Rating** |4.8 (19 globes from 4 users)
26+
**Compatibility** |VB 6\.0
27+
**Category** |[Custom Controls/ Forms/ Menus](https://github.com/Planet-Source-Code/PSCIndex/blob/master/ByCategory/custom-controls-forms-menus__1-4.md)
28+
**World** |[Visual Basic](https://github.com/Planet-Source-Code/PSCIndex/blob/master/ByWorld/visual-basic.md)
29+
**Archive File** |[Counting\_e1648759222003\.zip](https://github.com/Planet-Source-Code/pvdv-counting-en-getting-selected-listview-items-with-the-sendmessage-api__1-48704/archive/master.zip)
30+
31+
32+
33+
34+
35+
36+
37+

modListview.bas

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
Attribute VB_Name = "modListview"
2+
Option Explicit
3+
4+
Private Const LVM_FIRST = &H1000
5+
Private Const LVM_GETNEXTITEM = (LVM_FIRST + 12)
6+
Private Const LVNI_SELECTED = &H2
7+
Private Const LVM_GETSELECTEDCOUNT = (LVM_FIRST + 50)
8+
Private Const LVM_SETEXTENDEDLISTVIEWSTYLE = LVM_FIRST + 54
9+
Private Const LVM_GETEXTENDEDLISTVIEWSTYLE = LVM_FIRST + 55
10+
Private Const LVS_EX_FULLROWSELECT = &H20
11+
Private Const LVIF_TEXT = &H1
12+
Private Const LVM_SETITEMSTATE As Long = (LVM_FIRST + 43)
13+
Private Const LVM_GETITEMSTATE As Long = (LVM_FIRST + 44)
14+
Private Const LVM_GETITEMTEXT As Long = (LVM_FIRST + 45)
15+
16+
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
17+
18+
19+
Public Function GetSelectedItemsFromListview(oListview As ListView) As Collection
20+
Dim lCurSelectedItemIndex As Long
21+
Dim myCol As Collection
22+
Dim myListItem As ListItem
23+
Dim i
24+
25+
'begin/start position in the listview
26+
lCurSelectedItemIndex = -1
27+
'create collection to hold selected items
28+
Set myCol = New Collection
29+
30+
For i = 1 To CountSelectedItemsInListview(oListview)
31+
'get the itemx index from the selected (current)item
32+
lCurSelectedItemIndex = SendMessage(oListview.hwnd, LVM_GETNEXTITEM, lCurSelectedItemIndex, ByVal LVNI_SELECTED)
33+
'add the listitem to the collection
34+
myCol.Add oListview.ListItems.Item(lCurSelectedItemIndex + 1)
35+
Next i
36+
37+
'return the collection
38+
Set GetSelectedItemsFromListview = myCol
39+
40+
End Function
41+
Public Function CountSelectedItemsInListview(oListview As ListView) As Long
42+
43+
'count the selected items
44+
CountSelectedItemsInListview = SendMessage(oListview.hwnd, LVM_GETSELECTEDCOUNT, 0, 0)
45+
46+
End Function
47+

0 commit comments

Comments
 (0)