|
-
Jan 17th, 2001, 08:43 AM
#1
Thread Starter
New Member
HI,
i'm making a program that wil change registry settings for a user. I want to build in a listbox in checkbox state and the user must be able to click on the item(There by checking it) en then when the press save and the registry settings will be saved. The problem is i dont how how to get selected box's and pass the value's.
Example.: If a user selected NoFind in the list box i must change the dword HKEY_blab\anotherkey\..\NoFind in to 1
normaly i would do this like X=savesettings HKEY_blab\anotherkey\..\check1.value (i when use checkboxes)
But how do i do this with a listbox ??
Thanx in advance for the help
-
Jan 17th, 2001, 09:20 AM
#2
_______
<?>
normaly i would do this like X=savesettings HKEY_blab\anotherkey\..\check1.value (i when use checkboxes)
'if you do it in the click event of the listbox
If list1.text = "nofind" then
myVal = 1
else
myVal = 0
End If
X=savesettings HKEY_blab\anotherkey\..\myVal
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Jan 17th, 2001, 09:29 AM
#3
Fanatic Member
If you want to loop through the ListItems then:
Code:
Dim intLoop As Integer
Dim intVal As Integer
For intLoop = 0 To List1.Listcount - 1
List1.ListIndex = intLoop
If List1.Selected(intLoop) = True Then
intVal = 1
Else
intVal = 0
End If
'// SaveSetting here
End If
-
Jan 17th, 2001, 10:14 AM
#4
PowerPoster
Jerry, you shouldn't loop through the list, it will slow if the ListBox have a large number of item, try use API.
Code:
Dim i As Integer
Dim Idx As Integer
Dim sCount As Integer
Dim sBuff(512) As Long
'Get the number of selected item
sCount = SendMessage(List1.hwnd, LB_GETSELCOUNT, 0, 0)
If sCount = 1 Then
'For Single selection
Idx = SendMessage(List1.hwnd, LB_GETCURSEL, 0, 0)
'Paste your save setting into registry code here
' [Sample]
' "HKEY_blab\anotherkey\..\" & list1.List (idx)
Else
'For Multi selection
If sCount < 512 Then
Idx = SendMessage(List1.hwnd, LB_GETSELITEMS, 512, sBuff(0))
For i = Idx - 1 To 0 Step -1
'Paste your save setting into registry code here
' [Sample]
' "HKEY_blab\anotherkey\..\" & list1.List (idx)
Next
Else
MsgBox "Too many selected item!", vbExclamation + vbOKOnly, "ListBox"
End If
End If
-
Jan 17th, 2001, 03:49 PM
#5
Thread Starter
New Member
Will this work for more then one check?
Thank you all for you help i will try it out, but chris one question will this work for more then one checkbox??
Because there will be about 13 check boxes (no multi line)
and each one of then will have a different setting. Would please explain to me how i can do that
Once again Thanx in Advance
-
Jan 17th, 2001, 03:55 PM
#6
Just reading it...
yep Mystic....
its right in chris' code...
this section shows the multiselection handling...
Code:
.........From chris....
'For Multi selection
If sCount < 512 Then
Idx = SendMessage(List1.hwnd, LB_GETSELITEMS, 512, sBuff(0))
For i = Idx - 1 To 0 Step -1
'Paste your save setting into registry code here
' [Sample]
' "HKEY_blab\anotherkey\..\" & list1.List (idx)
Next
Else
MsgBox "Too many selected item!", vbExclamation + vbOKOnly, "ListBox"
End If
.......
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
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
|