Mouse Wheel

(Ricardo) #1

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.


(Ricardo) #3

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

can you please post some simple example?



hi @ricardo.eira

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 



(Ricardo) #5

Thank you

(Ricardo) #6

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


(Dale Fugier) #7

Hi @ricardo.eira,

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

– Dale

(Ricardo) #8

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

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

Any Idea?

(Dale Fugier) #9

No, I’ve got nothing, sorry.

– Dale

(Ricardo) #10

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:

There is any to check is rhino is focus?

If (Rhino.IsFocusMainWindow()??


(Menno Deij - van Rijswijk) #11

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

GetWindowThreadProcessId(foregroundWindow, out uint processID);

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

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

private static extern IntPtr GetForegroundWindow();

static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId);

static extern uint GetCurrentProcessId();

(Ricardo) #12

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.

(Menno Deij - van Rijswijk) #13

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