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).
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.
The most difficult part of developing a program is understanding the problem.
The second most difficult part is deciding how you're going to solve the problem.
Actually writing the program (translating your solution into some computer language) is the easiest part.
Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read. Please Help Us To Save Ana
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?
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?
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?
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?
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.
The most difficult part of developing a program is understanding the problem.
The second most difficult part is deciding how you're going to solve the problem.
Actually writing the program (translating your solution into some computer language) is the easiest part.
Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read. Please Help Us To Save Ana
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