Hey All ... (I'm going mad here .. ) ... I've been trying to get this to work for the last 4 hours but I don't know a whole lot about subclassing so here is my situation ..
I've made a usercontrol (I pass a form name to the control and it paints the form into a PictureBox, and scrollbars in the usercontrol allow the user to scroll about) ... but I want the user to be able to scroll the form with a wheel mouse, so earlier on I searched the forums and came up with two different peices of cone, one which is very basic other highly complex with all sorts of error detection / os detection ect ... in anycase the WM_MOUSESCROLL message isn't being fired as far as I can't tell. (I am debug.printing all the messages being sent to the specified function) ... I see it being called when I move the mouse from control area control area / mouse clicking ect ...
I've tried using this in a seperate project (just a scrollbar and the form) and it works just fine. So because I used SetParent() to paint the form into a picturebox cause a problem somehow ? ...
sorry .. I am using WM_MOUSEWHEEL, and i have gotten it to work in a test project .. it just won't work in my app ..
(module I'm using for mouse scroll)
VB Code:
Option Explicit
Declare Function SetWindowLong& Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long)
Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Const GWL_WNDPROC = (-4)
'These are the messages
Const WM_MOUSEWHEEL = &H20A
Global WndProcOld As Long
Public Function WindProc(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
'checks the messages
Debug.Print "wMsg Is : " & wMsg
Debug.Print "Mwheel : " & WM_MOUSEWHEEL
If wMsg = WM_MOUSEWHEEL Then
If wParam < 0 Then
'If Form1.VScroll1.Value <> Form1.VScroll1.Max Then Form1.VScroll1.Value = Form1.VScroll1.Value + 1
Form1.FormScroll.vs_Change
Else
'If Form1.VScroll1.Value <> Form1.VScroll1.Min Then Form1.VScroll1.Value = Form1.VScroll1.Value - 1
hummm .. I've said serveral times that I've gotten it working (in a new project) ... it does not work in my main app
Picture having a usercontrol with a picturebox and two scrollbars (VS and HS) ...
(Scrollform control is say on Form1 ... I call ...
VB Code:
ScrollForm.Form_Draw Form3
which calls the above procedure ...
That procedure uses SetParent() to place the form inside of the picturebox (so that Form3 more or less becomes part of Form1, not really sure how to explain it - the title of the main form won't loose focus, although I'm not sure that Form3 can actually gain focus anymore *shrug*)
Here is a screen to give you a better idea .. Form3 is the one that displays all the information...
1 Form
1 Vertical Scrollbar
No Custom Usercontrol
No Use Of SetParent() (as there is only one form)
Works Fine ...
Using it in my main app shown in the screenshot above, it doesn't work .. No mouse wheel events are sent .. I'm not sure if it's because the form can't get proper focus or what but it's really annoying and bothering me to no end. *Tears hair out*