Space entered in a text box of a modeless dialog – causes command to run again (C#)

Issue

I have a custom command that displays a modeless dialog with a textbox. If I enter a space in the textbox the message invokes my custom command so the modeless dialog appears again.  Is there a way to block the key message being sent to the Inevntor message loop when the key is a space?

Solution

To avoid this problem provide Inventor's mainframe window as the owner of the modeless dialog. This code snippet shows the idea:

In C#.Net

oDialog.Show(new InventorMainFrame(m_inventorApplication.MainFrameHWND));
 
And the definition for InventorMainFrame is as below:
 

    internal class InventorMainFrame : System.Windows.Forms.IWin32Window
    {
        public InventorMainFrame(long hWnd) { m_hWnd = hWnd; }
        public System.IntPtr Handle { 
          get { return (System.IntPtr)m_hWnd; } }
        private long m_hWnd;
    }

Comments

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading