Mouse Wheel

Hello ,

I need disable the zoom, any way to disable the zoom wheel function on c# ?

Or set the viewport to fixed size (zoom)?

Thank you

You can use RhinoCommon to access set/get the Zoom Scale Factor from Options, if set to 1, zoom is disabled.
Not sure if there is a cleaner way.

–jarek

Thank you @Jarek, I think that can work fine, but, I dont find the rhinocomon command
example.

can you please post some simple example?

thanks

hi @MatrixRatrix

I don’t speak C#, but in Python via RhinoCommon you can do it like this:

    import scriptcontext as sc
    import Rhino.ApplicationSettings as appsettings
    #get zoomscale
    dbZoomScale = appsettings.ViewSettings.ZoomScale
    #set zoomscale
    appsettings.ViewSettings.ZoomScale = 1 

hth,

–jarek

Thank you

@dale, I need acess to delta mouse wheel event, there is any way? Any callback for the whell mouse?

Thanks

Hi @MatrixRatrix,

There isn’t anything in RhinoCommon that will provide this. Why do you need it?

– Dale

Hi @dale, I need use the delta wheel to rotate a selected object.

I set the same funcion (rotate) with a keyboard Key, but I now I whant use the mouse
wheel.

I already set the zoomscale to 1, so, I think the zoom is not go be a problem.

Any Idea?

No, I’ve got nothing, sorry.

– Dale

Hello @dale ,

After some searching work I found the solution:

Now I have a small problem, which I have already solved,
but I think there may be a more efficient way.

This method runs with the focus on rhino or without the focus on rhino,
I want the method to be run only when the rhino is focus

There is this function to set the rhino focus:
Rhino.RhinoApp.SetFocusToMainWindow()

There is any to check is rhino is focus?

If (Rhino.IsFocusMainWindow()??

Thanks

Yes this can be done using P/Invoke calling native windows functions like so:

IntPtr foregroundWindow = GetForegroundWindow();
IntPtr undefined = (IntPtr)(-1);
if (foregroundWindow == undefined)
{
  // unable to find any foreground window
  return;
}

GetWindowThreadProcessId(foregroundWindow, out uint processID);

uint currentProcessID = GetCurrentProcessId();
if (processID == currentProcessID) 
{
  // Rhino has focus
}
else
{
  // Rhino does not have focus
}

You have to define the following P/Invoke extern functions:

[DllImport("user32.dll")]
private static extern IntPtr GetForegroundWindow();

[DllImport("user32.dll")]
static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId);

[DllImport("kernel32.dll")]
static extern uint GetCurrentProcessId();
1 Like

Thank you for your answer, this was also the way I thought to solve it, I thought there could be a simpler way with rhinocommom.

thank you.

Not that I know of. If there is I’m interested as well :slight_smile: