I can't say with 100% certainty that you couldn't make the flexgrid actually respond to mouse wheel events, but you can probably pull off a reasonable fake by subclassing your form and adding a handler for the WM_MOUSEWHEEL message.
An alternative would be to subclass the grid itself, and add a handler for the message, but that seems messier to me, because you can get a Timer and Subclassing Assistant component (free, with acknowledgement of the source somewhere in the app) at www.vbaccelerator.com. (SSubTmr6.dll) Using it in your project will pretty much get you an event in the form (conceptually) in which you can respond to the message.
In your mouse wheel handler, you would programmatically scroll the flexgrid, up or down, accordingly...
I'll try to dig up some sample code for you, but now that I've suggested it, I also have to warn you that the version of the code on vbaccelerator.com is prone to a very gradual kernel memory leak, which will KILL the performance of you app if it runs for long periods of time (the length of time depends on how many times you create and destroy the subclassed window - we found the problem in our pharmacy management system, in which a great many controls come from vbaccelerator, most of them using the SSubTmr6, and we estimated that in the course of the day, an instance of our app would create and destroy approximately 2000 instances of subclassed controls/windows). The symptom is that if you drag the mouse pointer across a subclassed window, kernel CPU utilization spikes to 60-80%. Keep running it, and it'll eventually get to 100%. That more or less equates to irate users. To worsen the matter, because the method used to track the original window procs uses kernel memory (via API window properties), this memory is not recovered until the system reboots. My fix was to implement my own property class/collection, and store the pointers locally. The window property method is EXTREMELY prolific in Internet articles on subclassing, but I seriously doubt that anyone's tested it thoroughly enough to discover the problem we had (because people still recommend that method). It would seem that the delete property window won't delete a property with a value of 0 (which makes sense, given that the intent of the API functions is to store a handle to a string - a 0 looks like a null pointer).
I've been meaning to mail our "fix" to Steve McMahon at vbaccelerator, but I haven't had a chance. In any case, with the fixed dll (I can mail you the source for the component with my fixes when I mail Steve if you're interested), I'm of the opinion that there's no better way to get mouse wheel messages (better meaning that if your code breaks, the IDE doesn't die, as it would with subclassing the hard way or hooking the message handler, which are both valid alternatives).
Anyway, I'll dig up that code and get you a sample in a bit. I may have to wait until tomorrow to get the fixed SSubTmr6 source, as I use the public version here at home for development.
Joe Plocki
Sometimes the straightest path is through the mud.
O|||||O
Found it. If you get any undeclared variable errors, I'm hoping their names are self-explanatory enough that you get their meaning. And, if so, sorry - this is from an early proof-of-concept tool I was working on, so most of the code in this project was sort of thrown together in a hurry.
You can get the "production" version of the SSubTmr6 here. Just register it and add a reference in your project. The kernel memory leak I mentioned isn't likely to hose you up in the 100 or so times you end up playing with it... you *really* have to abuse the thing to make the symptoms show up. http://www.vbaccelerator.com/home/VB...Tmr_Binary.asp
I hope this formats well, I've been having problems with the CODE tags. If it's screwed, check the attachment, form1.txt.
Anyway, paste this code into an empty form, add a vertical scroll bar named vs to the form, and it should be ready to go.
Code:
Option Explicit
' With a reference to SSubTmr6, this allows the form to get the
' subclassed WindowProc event
Implements ISubclass
' This is probably unnecessary, used in one of the other ISubclass_
' events
Private m_emr As EMsgResponse
Private Const WM_MOUSEWHEEL = &H20A
' UDT's to simplify DWORD-splitting, with no math via LSet
Private Type tDWORD_SPLIT
LOWORD As Integer
HIWORD As Integer
End Type
Private Type tDWORD
dword As Long
End Type
Private Sub Form_Load()
AttachMessage Me, Me.hWnd, WM_MOUSEWHEEL
End Sub
Private Sub Form_Unload(Cancel As Integer)
DetachMessage Me, Me.hWnd, WM_MOUSEWHEEL
End Sub
Private Property Get ISubclass_MsgResponse() As SSubTimer6.EMsgResponse
'DebugPrint CurrentMessage
m_emr = emrConsume
ISubclass_MsgResponse = m_emr
End Property
Private Property Let ISubclass_MsgResponse(ByVal RHS As SSubTimer6.EMsgResponse)
End Property
Private Function ISubclass_WindowProc(ByVal hWnd As Long, ByVal iMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Dim dword As tDWORD
Dim words As tDWORD_SPLIT
Dim temp As Long
Dim g_lMouseSensitivity As Long ' This was declared globally elsewhere in my app
g_lMouseSensitivity = 3 ' Test Value for this sample
Select Case iMsg
Case WM_MOUSEWHEEL
' Part of wParam has a Delta value, but it's always the same, so just scroll
' for the number of lines in the mouse sensitivity setting in options
' If (m_sCurrentX >= picView.Left And m_sCurrentX <= picView.Left + picView.Width) _
' And (m_sCurrentY >= picView.Top And m_sCurrentY <= picView.Top + picView.Height) Then
dword.dword = wParam
LSet words = dword
If words.HIWORD > 0 Then
' MsgBox "Forward "
temp = vs.Value - g_lMouseSensitivity '(words.LOWORD \ 120)
' Debug.Print words.HIWORD
Else
' MsgBox "Backword "
temp = vs.Value + g_lMouseSensitivity '(words.LOWORD \ 120)
' Debug.Print words.HIWORD
End If
If temp < vs.Min Then
temp = vs.Min
End If
If temp > vs.Max Then
temp = vs.Max
End If
' I was using this to change the value of a scroll bar
vs.Value = temp
' So instead, you would need to implement your own
' method of scrolling the grid based on the value of
' temp (going back up to the first reference to the
' scroll bar, vs). Last time I used a flexgrid, I did have to
' programmatically scroll, so I know there's a method or
' property that will allow you to scroll to a certain row...
' you could just increment or decrement the top row
' value as you see fit.
' End If
End Select
End Function
Hope that helps. I'll try to post the fixed SSubTmr6 code tomorrow sometime, if I don't forget (lots going on at work - I scored a high-profile project this week, with an ASAP deadline, so forgive me if it slips my mind - you can mail me if you don't hear from me at "joeplocki at bellsouth dot net"). Hopefully I didn't leave anything critical out when I hacked up my code here. If you have problems with this, let me know.
Joe Plocki
Sometimes the straightest path is through the mud.
O|||||O
Just add a ' as the first character (to make the line a comment only).
He has a note in there saying that those lines prolly weren't needed.
Looks like this one wasn't. Comment out other lines that don't work, and try again!
If you're getting not recognized on that error, it's because registering the SSubTmr6.dll didn't take, or you didn't set a reference to it in your project. If either or both of those are the case, you'll get other errors, or it just won't work. Make sure you do those things, and it ought to work out - I was able to run it last night before I posted. As it's written, you'll just have a form with a vertical scroll bar that scrolls when you use the wheel.
I'll see if I can find the project with the kernel-leak fix version of the SSubTmr6 project while I'm at work today and post it before I leave.
Joe Plocki
Sometimes the straightest path is through the mud.
O|||||O
Oh, also, missed your other question: the second crappiest place on earth is Berea, South Carolina, USA. It's so pathetic, my mailing address is Greenville, because they're too embarrased to put it on a map.I hope not offend anyone, but the first crappiest place on earth is Birmingham, Alabama. The third is Memphis, Tennessee.
Joe Plocki
Sometimes the straightest path is through the mud.
O|||||O
Hope that helps. I'll try to post the fixed SSubTmr6 code tomorrow sometime, if I don't forget
I know this is a crazy old post, but...
Just curious if up ever uploaded your fixes to SSubTmr6... I have an old VB6 project that has been using this with alot of the vbAccelerator components and it doesn't take very long for the user to have to reboot their computer.
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.