How to add a mouse event handler in source project and then using the dll file in another project and to be able to create event of the handler ?

Chocolade 516 Reputation points
2022-02-06T00:01:05.983+00:00

I have two projects.

The first project is not my own one it's a custom trackBar from this link https://www.codeproject.com/Articles/14378/Advanced-TrackBar-Slider-Control-with-MAC-Style-C
I downloaded the source and built it and then used the dll file on my second project.

Added the dll file to the toolbox and then dragged the control to my form1 in my project.
This screenshot show the control.

On the control there is this blue small ball this is the tracker.

171653-mac3.jpg

I can use the trackBar in my project without a problem.

What I want to add is a double click mouse event but on the small blue ball the tracker not the trackBar control !
There is already an event for the control mouse double click I want to add a double click event for the small blue ball.

In this screenshot I marked with red circle the blue ball that I want to add a mouse double click event so when I click double click on the small blue ball something will happens.

171632-mac4.jpg

The source code is a bit long so I uploaded it to pastebin.com at this link : https://pastebin.com/yD21F4am

The relevant part of code from the source project is this : at line 213 :

public MACTrackBar()  
		{  
			base.MouseDown += new MouseEventHandler (OnMouseDownSlider);  
			base.MouseUp += new MouseEventHandler (OnMouseUpSlider);  
			base.MouseMove += new MouseEventHandler (OnMouseMoveSlider);  
                 }  

Now if I will add my own MouseEventHander at this part for example :

base.MouseDoubleClick += new MouseEventHandler(OnMouseDoubleClick);  

and then

private void OnMouseDoubleClick(object sender, MouseEventArgs e)  
        {  
            MessageBox.Show("Working ?");  
        }  

Then I compiled it and added the dll file again to my project to the toolbox dragged the control to form1 designer then when running my project and while I make double click on the blue ball
it will show the message "Working ?"

The problem is that I want to add this part to be in form1 in my project not in the source project :

private void OnMouseDoubleClick(object sender, MouseEventArgs e)  
            {  
                MessageBox.Show("Working ?");  
            }  

The problem is that the event handler must be inside the MACTrackBar() method in the source project to be affect on the blue small ball the tracker and since it's starting with base and it's not public the event can be exist only in the source project not in my project.

I want it to be in my project because I want to make some stuff like change colors and other stuff in my project when I make double click with the mouse on the small blue ball.

Windows Forms
Windows Forms
A set of .NET Framework managed libraries for developing graphical user interfaces.
1,824 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,218 questions
{count} votes