Mousewheel Events Called Twice

Asked 2 years ago, Updated 2 years ago, 46 views

I'm making a program to play video on C#.
I'd like to implement frame-forward playback with mouse wheel, but I'm going to have a case of title.

Immediately after startup, it is called only once, but it is called twice when there is an active control by clicking inside the form.

Events are only available on the main form

this.MouseWheel+=newSystem.Windows.Forms.MouseEventHandler(this.frmMainForm_MouseWheel)

Registering in the form of .

Now

 if (this.ActiveControl!=null)
{
    frameSec = frameMSec/2;
}

If there is an active control like this, I would like to know the fundamental solution rather than this symptomatic solution.

How can I avoid a second call?

Why are they called twice in the first place?

c#

2022-09-30 19:55

1 Answers

I can't say for sure because I don't have much information, but I'm going to add an event handler

this.MouseWheel+=newSystem.Windows.Forms.MouseEventHandler(this.frmMainForm_MouseWheel);

If has been added by coding rather than designer, it may have been added twice for some reason.

What if

this.MouseWheel-=newSystem.Windows.Forms.MouseEventHandler(this.frmMainForm_MouseWheel);
This.MouseWheel+=new System.Windows.Forms.MouseEventHandler(this.frmMainForm_MouseWheel);

If you want to make improvements by deleting and before adding, you can determine the above reasons.


2022-09-30 19:55

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.