Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Capturing wheel mouse event in C++ builder 3

Status
Not open for further replies.

ed0

Programmer
Jul 30, 2003
4
US
For some reason the wheel mouse works on some components (treeviews) but not on my forms. I'm not sure which windows message to trap to catch the wheel mouse.

I'm also trying to then scroll the form, I've tried using

this->Perform(EM_SCROLL,SB_LINEDOWN,0);
and
ScrollWindowEx(this->Handle,0,10,NULL,NULL,NULL,NULL,SW_ERASE);
and
this->ScrollBy(0,10);

None of these seem to work correctly.

P.S. I'm using C++ Builder 3.

Thanks,
Ed
 
When I tried my wheel mouse on a form with a vertical scroll bar, it worked fine. If the mouse pointer was on a component like a combo box however, the form will not scroll. Thus, it may be a function of what you have on the form. You might try putting the mouse pointer on the form name at the top (if you have one) and see if it will scroll.
 
The mousewheel event is probably only going to trigger on the focused item. That is difficult for forms, since their "focus" is not real obvious, i.e. no flashing cursor or selection rectangle to make it obvious. You should catch the scroll wheel event in all of your components on the form, and run one function. That should do the trick.

Have you noticed, for example, that when you are typing in a box like this one I'm typing in right now, and you make the text long enough that a scroll bar appears, if you use the mouse wheel in this box, it will scroll to the bottom of the text box, but then start scrolling the main window after that. It's supposed to be a "smarter" technique, but mostly annoying. But the point is, as you can see, the mouse wheel scrolling event is sent to the text box, then the code determines "Am I at the beginning or end of the text box? Yes? Well scroll the whole form then". You would just say "Scroll the whole form then" in your code. Anyway, good luck!

Chris
 
Even if I click the top of the form it won't scroll with the wheel mouse.
I'm currently on NT could that have anything to do with it?

The issue i'm having is a little earlier in the chain.
C++ Builder 3 simply does not have an OnMouseWheel event, I need to figure out a way
to intercept the Mousewheel message. I know how do intercept a windows message, I just don't know
about the mouse wheel message. What is the message number?

Thanks for the help!
-Ed
 
When I run winsite32 and do a mouse wheel down this is the resulting message stream

00295.775 000113:000102C0 {TDBMemo} WM_USER+0xB938 Sent wp=01010043 lp=000102C0
00296.656 000114:000102C0 {TDBMemo} WM_0x20A Dispatched wp=FF880000 lp=00E501B4
00296.686 000115:000102C0 {TDBMemo} WM_0x20A Dispatched wp=FF880000 lp=00E501B4

So I'm guessing that WM_USER+0xB938 initiates a mouse wheel event, and WM_0x20A is a mouse wheel down event.

Anyone know if i'm right?

-Ed
 
I don't know if this will help, but here's some additional info.

You can make a window capture all mouse events by using the SetCapture() function.

You might be able to do this...
Capture the message MOUSEEVENTF_MOVE.
Call the function
VOID mouse_event(
DWORD dwFlags, // flags specifying various motion/click variants
DWORD dx, // horizontal mouse position or position change
DWORD dy, // vertical mouse position or position change
DWORD dwData, // amount of wheel movement
DWORD dwExtraInfo // 32 bits of application-defined information
);

dwFlags:
MOUSEEVENTF_WHEEL Windows NT only: Specifies that the wheel has been moved, if the mouse has a wheel. The amount of movement is given in dwData

Dunno if it will do any good. It's a starting point maybe :)

Good luck,
Chris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top