0 Replies Latest reply on Jun 1, 2017 8:15 AM by Tony Van De Velde

    PMP UserControl and keypresses not seen (C#)

    Tony Van De Velde

      Hi,

       

      I am creating .NET usercontrols to be used within SolidWorks Property Manager Pages. One of these usercontrols contains a Developer Express LookupEdit control. This control has a textbox with an embedded  dropdown window. Users can type text into the textbox part of the control and items in the dropdown list are automatically selected. This can be seen in the picture below.

      LookupEdit Control.PNG

      There is a problem however when we type characters into the text editor part of the control. None of the keypresses are seen by the control. Other controls such as a Microsoft ComboBox or a Developer Express ComboBoxEdit do see the characters being typed. I have already tried several ways to solve this and I am fairly sure the problem does not lie with the LookupEdit control itself.

       

      In the SolidWorks API help following topics describe this problem:

           "Keystrokes and Accelerator Keys in ActiveX Modeless Dialogs and PropertyManager Pages"

           "Connect to SOLIDWORKS Message Pump to Handle Keystrokes and Accelerator Keys (C#)"

      I tried to implement this C# solution using hooks into the message loop to solve this issue. When debugging the application, I can see all messages being trapped by the hook procedure. This is the code for the hook procedure as seen in the example:

       

      // Default filter function
              public int CoreHookProc(int code, IntPtr wParam, IntPtr lParam)
              {
                  if (code < 0)
                      return CallNextHookEx(m_hhook, code, wParam, lParam);
                  // Let clients determine what to do
                  HookEventArgs e = new HookEventArgs();
                  e.HookCode = code;
                  e.wParam = wParam;
                  e.lParam = lParam;
                  OnHookInvoked(e); // WHAT TO DO IN OnHookInvoked EVENT HANDLER???
                  // Yield to the next hook in the chain
                  return CallNextHookEx(m_hhook, code, wParam, lParam);
      
      
      
      
      }
      

       

      In this example, the OnHookInvoked(e) event is called. I'm unsure what to do in this event handler. I have searched the internet extensively for solutions and found some articles in which the PreTranslateMessage is being used like this one. I cannot get it to work in c#.

      Any ideas are greatly appreciated since I'm currently stuck at this point.

       

      Kind regards,

      Tony Van De Velde