| View previous topic :: View next topic |
| Author |
Message |
Analian Guest
|
Posted: Fri May 27, 2005 5:40 pm Post subject: OnMouseWheel triggering too many times |
|
|
Why when I rotate the wheel one step in up direction, the OnMouseWheel event
triggers 4 times instead of 1?
Is it a hardware specification of my mouse or it's something else? Thank
you.
|
|
| Back to top |
|
 |
JD Guest
|
Posted: Sat May 28, 2005 12:26 am Post subject: Re: OnMouseWheel triggering too many times |
|
|
"Analian" <analian (AT) mail (DOT) bg> wrote:
| Quote: |
Why when I rotate the wheel one step in up direction, the
OnMouseWheel event triggers 4 times instead of 1?
|
Because that's how it was designed. It's up to the programmer
(you) to determine how sensitive your handler will be.
Please show your actual code.
~ JD
|
|
| Back to top |
|
 |
Analian Guest
|
Posted: Sat May 28, 2005 7:19 am Post subject: Re: OnMouseWheel triggering too many times |
|
|
So I guess the number of minor wheel turns per one major turn is different
for different mouses.
And is there a variable that tells me what's this number?
What I'm trying to accomplish is zooming with the scroller. All is set but
there is still this minor problem to fix.
I've got a TButton which I've assigned to zoom with 100%. So when I use the
scroller I expect to zoom with the
same percentage. I put the zooming code in the OnMouse WheelUp/Down events
and there are two solutions.
1/ to put a static int count; in the event and on every fourth
event to zoom with 100%
or
2/ to zoom with 100 / 4 = 25% on each minor turn of the wheel
In either case I need to know what's the number of the minor turns per a
major one.
Any suggestions?
|
|
| Back to top |
|
 |
Analian Guest
|
Posted: Sat May 28, 2005 9:56 am Post subject: Re: OnMouseWheel triggering too many times |
|
|
Don't bother answering the question. I found out that the
TMouse->WheelScrollLines is just what I needed.
|
|
| Back to top |
|
 |
Analian Guest
|
Posted: Sat May 28, 2005 11:19 am Post subject: Re: OnMouseWheel triggering too many times |
|
|
"Analian" <analian (AT) mail (DOT) bg> wrote
| Quote: | Don't bother answering the question. I found out that the
TMouse->WheelScrollLines is just what I needed.
|
Nope. I'm totally wrong. the problem still persists.
|
|
| Back to top |
|
 |
JD Guest
|
Posted: Sat May 28, 2005 7:44 pm Post subject: Re: OnMouseWheel triggering too many times |
|
|
"Analian" <analian (AT) mail (DOT) bg> wrote:
| Quote: |
Nope. I'm totally wrong. the problem still persists.
|
Please show your code.
~ JD
|
|
| Back to top |
|
 |
JD Guest
|
Posted: Sun May 29, 2005 9:11 am Post subject: Re: OnMouseWheel triggering too many times |
|
|
"Analian" <analian (AT) mail (DOT) bg> wrote:
| Quote: |
Why when I rotate the wheel one step in up direction, the
OnMouseWheel event triggers 4 times instead of 1?
|
After re-reading the docs, I suspect that you're not checking
the ZDelta parameter (hi word of WParam). You should only act
on the WM_MOUSEWHEEL message when ZDelta is not NULL. If ZDelta
is positive, the wheel was rotated away from the user and if
negative, toward the user.
In all honesty, I have no idea of what events you spoke of in
your other post and I looked for them too. What you need to do
is add an Application::OnMessage event to the application. It
doesn't matter where you add it, just as long as it's before
you need it and the code is available as long as it's assigned
to that event. For example:
//-------------------------------------------------------------
__fastcall TPreview::TPreview(TComponent* Owner) : TForm(Owner)
{
Application->OnMessage = MyApplicationOnMessage;
}
//-------------------------------------------------------------
__fastcall TPreview::~TPreview()
{
Application->OnMessage = NULL;
}
//-------------------------------------------------------------
void __fastcall TPreview::MyApplicationOnMessage( TMsg &Msg, bool &Handled )
{
if( Msg.message == WM_MOUSEWHEEL )
{
if( Screen->ActiveForm == this )
{
short zDelta = HIWORD( Msg.wParam );
if( zDelta > 0 ) ZoomOut();
else if( zDelta < 0 ) ZoomIn();
}
}
}
//-------------------------------------------------------------
~ JD
|
|
| Back to top |
|
 |
|