Maxscript Throws Exception when Escape key pressed in DataGridView ( in MaxForm)


#1

Hi everyone,
This problem was asked by @sergo-pogosyan 8 years before on this link: [MXS and DotNet] KeyDown throws error. And I might discover a “dirty” solution for this.

Problem description:
In MaxForm, if You use dotnet datagridView and press escape key -> Following error is throwed (this error blocks whole max and you must restart application):

System.Runtime.InteropServices.SEHException (0x80004005): External component has thrown an exception.
at _CxxThrowException(Void* , _s__ThrowInfo* )
at MXS_dotNet.DotNetObjectWrapper.ProcessEvent(DotNetObjectWrapper* , String eventName, Object delegateArgs)
at MXS_dotNet.DotNetObjectManaged.delegate_proxy_type.ProcessEvent(String eventName, Object delegateArgs)
at System.Windows.Forms.Timer.OnTick(EventArgs e)
at System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

My dirty solution:

  1. Create new rollout, may look like this:
    rollout myDirtyRollout “Untitled” width:50height:50
    (
    dotNetControl ‘lbxLoadedMaterials’ “System.Windows.Forms.DataGridView” pos:[8,24] width:184 height:152 align:#left
    )

  2. Run the rollout:
    createDialog myDirtyRollout

  3. You can close your “myDirtyRollout” ( for me worked when “myDirtyDialog” was opened or closed)

4.Run your wanted rollout.

  1. Your problem should be fixed now.

I am not sure why this is needed, but it works for me.

Hope this helps you.