|
-
Aug 3rd, 2008, 07:49 PM
#1
Thread Starter
Lively Member
loose cursor on listbox
Hi. I used the following code to disable the cursor over the listbox (try to still have the scrolling function for the listbox but disable its clicks).
Code:
Private Sub List1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
ListBoxToolTip List1, y, "(empty)"
If (x < 0) Or (y < 0) Or (x > List1.Width) Or (y > List1.Height) Then
ReleaseCapture
ShowCursor 1
ElseIf GetCapture() <> List1.hwnd Then
SetCapture List1.hwnd
ShowCursor 0
End If
End Sub
However, when I tested again today, found the listed items could be selected still and once one is selected, the cursor disapares totally, not just within the listbox. Anything wrong? Can anyone help? or any other better solutions for this??
Thanks.
-
Aug 4th, 2008, 06:23 AM
#2
Re: loose cursor on listbox
Are you trying to set it so that nothing can be selected from the ListBox?
-
Aug 4th, 2008, 07:14 PM
#3
Thread Starter
Lively Member
Re: lose cursor on listbox
 Originally Posted by Hack
Are you trying to set it so that nothing can be selected from the ListBox?
yes.
But I don't want to use something like
Code:
List1.ListIndex <> -1 Then List1.ListIndex = -1
as the mouse still can click on the listbox and the item changes color that confuse the user (because I have a few other lists on the same form). Any ideas??
-
Aug 4th, 2008, 08:01 PM
#4
Re: loose cursor on listbox
I have one solution, but its way different and a bit more code. Basically it puts a clear picture box over a control so the user can see it perfectly as if the control was enabled but can't select anything or use the scroll bars.
-
Aug 4th, 2008, 08:39 PM
#5
Re: loose cursor on listbox
I don't have VB6 with me. This work for me with Form2 ListBox in VBA: user still can use scrollbar but cannot click on list items.
Try to see if it works with VB ListBox.
Code:
'-- In VB, "ByVal" may not present
Private Sub List1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
'-- 14 : this number is a bit smaller than the width of scrollbar that you can adjust
List1.Locked = (X < List1.Width - 14)
End Sub
Last edited by anhn; Aug 4th, 2008 at 08:43 PM.
-
Aug 5th, 2008, 12:24 AM
#6
Thread Starter
Lively Member
Re: loose cursor on listbox
 Originally Posted by anhn
I don't have VB6 with me. This work for me with Form2 ListBox in VBA: user still can use scrollbar but cannot click on list items.
Try to see if it works with VB ListBox.
Code:
'-- In VB, "ByVal" may not present
Private Sub List1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
'-- 14 : this number is a bit smaller than the width of scrollbar that you can adjust
List1.Locked = (X < List1.Width - 14)
End Sub
".locked" is not available in VB6
-
Aug 5th, 2008, 12:28 AM
#7
Thread Starter
Lively Member
Re: loose cursor on listbox
 Originally Posted by Edgemeal
I have one solution, but its way different and a bit more code. Basically it puts a clear picture box over a control so the user can see it perfectly as if the control was enabled but can't select anything or use the scroll bars.
I tried, it's ok still seeing the listbox behind the picture box, but I need the scrallbar working. And the cursor still dispears if I hit on the listbox
-
Aug 5th, 2008, 01:59 PM
#8
Re: loose cursor on listbox
There's probably a lot easier way to do this if you subclassed the listbox, but heres one idea I came up without subclassing.
The sample project places a transparent Picture box over a ListBox to act as a .Locked method, but still allows the user to scroll the list box.
Edit: Updated code for Listbox Tabstop.
Edit: File removed - no reply (why do I even bother?)
Last edited by Edgemeal; Aug 21st, 2008 at 01:11 AM.
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
|