Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

change mouse cursor on mouse hover

Hi, I am using custom implementation for zooming & panning to fit our needs, so I am not using the InteractionMode /InteractionModeDefault (they are always none)

 

However, I would like to be able to change the mouse cursor according to my own current mode.

 

Is there a way I can tell the graph to change it's cursor on the plot area?

 

Thanks in advance!

0 Kudos
Message 1 of 10
(6,603 Views)

Marvin,

 

The graph should have a property called cursor that you set equal to any of the available cursors on the system.  These can be accessed by typing "Cursors." after the equal sign and allowing IntelliSense to pop-up and list the cursors available to you.  As such, the line of code becomes WaveformGraphName.Cursor = Cursors.DesiredCursor.  I placed this line within the MouseEnter event for the Waveform Graph and sure enough, the cursor changed to whatever I indicated in the code when I moused over the graph.  Let me know what versions of Visual Studio and Measurement Studio you are using, and I'd be glad to create a small example for you that exhibits this functionality.

0 Kudos
Message 2 of 10
(6,586 Views)

Hi Gist,

 

Thank you four your response.

 

I have already tried you solution. However, I need the cursor to change when I hover the Plot area only. With your solution, the cursor is changed wherever I am in the graph, including the axes. I would need to reproduce the same behavior as when using the InteractionModeDefault (the cursor only changes in the plot area)

 

I tried to move the code on the PlotAreaMouseHover event but this doesn't work. 

 

I include an image to clarify. Notice the mouse cursor in the y axis, it is a zoom cursor. That is my problem...

 

For your information, I am using VS 2005 and Measurement studio 8.6.20.465 

 

Thank you very much.

 

2010-01-21_104512.jpg

0 Kudos
Message 3 of 10
(6,581 Views)

Hello Marvin,

 

If that is the case, use the MouseMove event of the Waveform Graph in conjunction with the parameter called "e" that it automatically provides for you in order to detect the location of the mouse.  That is, identify a rectangle that constitutes the plot area and if the mouse is in that area change the cursor to your desired cursor.  If it is outside of that area, revert to the original cursor.  I have attached an example exhibiting this approach that has been created with Visual Studio 2005 and Measurement Studio 8.5.

0 Kudos
Message 4 of 10
(6,575 Views)
Adding to Matt's solution, you can use the HitTest method on WaveformGraph to find out if the mouse is in the Plot Area rather than finding the exact co-ordinates of the plot area and comparing it.
Thanks,
Mohammed Haseeb|Measurement Studio|National Instruments
0 Kudos
Message 5 of 10
(6,516 Views)

Hi, I am using Measurement Studio 2010 (V9.0.0.292). I would like to change cursor when mouse enters the Knob object.

The code below does not work although it works with the e.g Switch object:

 

private void knob1_MouseEnter(object sender, EventArgs e)

{

 knob1.Cursor=Cursors.Arrow;//This code DOES NOT change hand cursor to arrow cursor

}

 

private void switch1_MouseEnter(object sender, EventArgs e)

{

 switch1.Cursor=Cursors.Arrow;//This code WORKS properly

}

 

Thank you very much.

Laseno.

Laseno
0 Kudos
Message 6 of 10
(5,422 Views)

Laseno,

 

The cursor property is not a valid property in the knob property. Switch inherits the property from the 'controlbase' class while knob does not, unfortunately. 

 

In the help file, it shows the inheritance heirarcy to be :

knob vs switch.png

You may be able to find a workaround using some of the other properties, such as innerbounds or just by using the physical location (and height/width) of the knob. 

 

Regards,

 

Kyle Mozdzyn

Applications Engineering

National Instruments

 

Regards,

Kyle M.
Applications Engineering
National Instruments
0 Kudos
Message 7 of 10
(5,412 Views)

Laseno,

 

My mistake, I looked up the WebControls version of the Knob class instead of the WindowsFroms version. It seems that the windowsforms version does have the cursor property, and we have successfuly reproduced the issue here. Were currently looking into why this behavior happens. 

 

Regards,

 

Kyle Mozdzyn

Applications Engineering

National Instruments

Regards,

Kyle M.
Applications Engineering
National Instruments
0 Kudos
Message 8 of 10
(5,402 Views)

Laseno,

 

I think I have found a better solution to the issue. Instead of using the knob.cursor property, you can set the default behavior using the InteractionMouseCursors property, which can be seen here for an arbitrary control. I think this will use less overhead and be a more robust solution.

Mouse over.png

 

Regards,

 

Kyle Mozdzyn

Applications Engineering

National Instruments

Regards,

Kyle M.
Applications Engineering
National Instruments
0 Kudos
Message 9 of 10
(5,392 Views)

Hi, Kyle.

 

Thank you very much for your information.

I could try some workarounds.

I think I am going to that direction. I have tried to cover the knob by a text label

and define some events on it...

 

Sincerely,

Laseno

Laseno
0 Kudos
Message 10 of 10
(5,384 Views)