1 Attachment(s)
Detect when a user clicks on a listview scrollbar code problem?
HI everyone again.
I have made some changes to the project posted in http://vbnet.mvps.org/index.html?cod...api/index.html.
For my attached project i just want to display a message when the user move down the list or drag the thumb control (I think
thats the name for the little list position indicator?) down/up to scroll at a
faster rate.
The problem here is when the user drags the Thumb control of the listview scrollbar,
what is happening is that the message box is posted several times and i dont know how to make it appear only one time.(i'm a novice in the API).
Thanks for your help.
Re: Detect when a user clicks on a listview scrollbar code problem?
Can someone give-me some help on this API code?
Thanks
Re: Detect when a user clicks on a listview scrollbar code problem?
Every time the user moves the scrollbar you're going to get a message. That's what it's supposed to be doing.
Re: Detect when a user clicks on a listview scrollbar code problem?
add a module level boolean.
Once you've shown your message once (use Debug.Print for testing - not a MsgBox) set the boolean to True. Now three messages are sent after the scrolling has finished (and not during), they are WM_NCHITTEST, WM_NCMOUSEMOVE and WM_SETCURSOR. Listen for one of those and set the Boolean back to false.
Re: Detect when a user clicks on a listview scrollbar code problem?
Hi Al42.
What i want is:
- when the user drags the thumbnail of the listview scrollbar i only want to make appear the msgbox one time.
And this is not happening , because when i drag the thumbnail that message is displayed over and over, did you tryed this?
Re: Detect when a user clicks on a listview scrollbar code problem?
Hi bushmobile.
I didnt understand. i'm a API novice.
Re: Detect when a user clicks on a listview scrollbar code problem?
add a module level boolean, now in the WndProc listen for one of the messages i suggested:
Code:
Case WM_VSCROLL
Debug.Print "Fired"
bBoolean = True
Case WM_NCMOUSEMOVE
bBoolean = False
you'll have to look up the definition for WM_MOUSEMOVE
Re: Detect when a user clicks on a listview scrollbar code problem?
How can i add a module boolean?
Is this just like adding a module?
look up the definition for WM_MOUSEMOVE, why this?
I'm not understand, this?
Re: Detect when a user clicks on a listview scrollbar code problem?
by module-level variable I mean one that can be accessed anywhere in the module.
regarding WM_NCMOUSEMOVE - in the same way that you have WM_VSCROLL declared at the top of the form, you will also have to find out what WM_NCMOUSEMOVE should be declared as.
Re: Detect when a user clicks on a listview scrollbar code problem?
Ok ,and why i have to look up the definition for WM_MOUSEMOVE?
Re: Detect when a user clicks on a listview scrollbar code problem?
because the window messages that WndProc receives are just numbers - WM_VSCROLL doesn't mean anything to the computer - it only means something because you've declared it as &H115.
Re: Detect when a user clicks on a listview scrollbar code problem?
Hi again bushmobile.
i'm confused. For what reason do i have to declare a boolean variable, to skip a part of the code?
Re: Detect when a user clicks on a listview scrollbar code problem?
whoops, my bad - I forgot to make use of it:
Code:
Case WM_VSCROLL
If Not bBoolean Then
Debug.Print "Fired"
bBoolean = True
End If
1 Attachment(s)
Re: Detect when a user clicks on a listview scrollbar code problem?
Quote:
Originally Posted by bushmobile
whoops, my bad - I forgot to make use of it:
Code:
Case WM_VSCROLL
If Not bBoolean Then
Debug.Print "Fired"
bBoolean = True
End If
Hi again Bushmobile.
I have tried and i cant make the code to work.
I have attached the project, take a look and please make it work.
Thanks a lot.
Re: Detect when a user clicks on a listview scrollbar code problem?
a) you've got a glaring syntax error
b) you haven't included any code for WM_NCMOUSEMOVE (or defined it)
subclassing is a nightmare to debug because it'll fall over if you make any mistakes. When in the IDE run the project using Ctrl+F5, not F5 - so that it'll get checked for any silly compilation errors (which will show you a) immediately)
Re: Detect when a user clicks on a listview scrollbar code problem?
Do i have to define the WM_NCMOUSEMOVE as a hexadecimal constante if yes why?
Re: Detect when a user clicks on a listview scrollbar code problem?
no it doesn't make a difference, Hex is just a way of representing a number - the computer sees only binary
Re: Detect when a user clicks on a listview scrollbar code problem?
Ok it´s working, But i think I didn't explain the problem in the correct way.
What the code is doing now is that the msgbox is displayed one time and then
if i click again in the listview scrollbar nothing happens.
But what i want is to display the message every time the user clicks or drags the thumnail of the scrollbar.
I think that i have to reset the boolean variable some here in the code, right?
Re: Detect when a user clicks on a listview scrollbar code problem?
I think what you want is to show the last value when the user lets go of the button.
Off the top of my head, save the value (in the same variable) every time you get a WM_VSCROLL message and,when you get the WM_NCMOUSEMOVE message, display the msgbox with the saved value.
Re: Detect when a user clicks on a listview scrollbar code problem?
your WndProc should look like:
Code:
Friend Function WindowProc(hwnd As Long, msg As Long, wParam As Long, lParam As Long) As Long
If hwnd = ListView1.hwnd Then
Select Case msg
Case WM_VSCROLL
If Not bBoolean Then
Debug.Print "Fired"
bBoolean = True
End If
Case WM_NCMOUSEMOVE
bBoolean = False
End Select
End If
WindowProc = CallWindowProc(GetProp(hwnd, "OldWindowProc"), hwnd, msg, wParam, lParam)
End Function
Re: Detect when a user clicks on a listview scrollbar code problem?
Thanks a lot Bushmobile for your precious help.