I'm trying to utlize the "OpenWindow" functions for the various SOP and RM windows in VS Tools for Dynamics 9 such as:
Dynamics.Forms.SopEntry.Functions.OpenWindow.Invoke...
Dynamics.Forms.SopInquiry.Functions.OpenWindow.Invoke...
Dynamics.Forms.RmCustomerMaintenance.Procedures.OpenWindow.Invoke...
Dynamics.Forms.RmCustomerInquiry.Procedures.Open.Invoke...
I am having 2 problems:
1. The "OpenWindow" function does not pass the focus to the windows once they are opened. How do I force the windows to focus? I'm calling this function from another window (inside Dynamics). I've tried doing a RunValidate() on some of the controls of each window after the "OpenWindow" invocation call but no luck.
2. Hand-in-hand with #1 above - I have added event handlers to the OpenAfterOriginal event for each of these windows. However, when using the "OpenWindow" invocation to open the window, if I try to access any of the window elements in the Open event handler (such as Dynamics.Forms.SopEntry.SopEntry.SopNumber.Value) I get a .NET exception error message in Dynamics as below:
--
Unhandled exception has occurred in a component in your application. If you click Continue, the application will ignore this error and attempt to continue.
Queue empty.
See the end of this message for details on invoking just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.InvalidOperationException: Queue empty.
at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
at System.Collections.Generic.Queue`1.Dequeue()
at Microsoft.Dexterity.Applications.DynamicsDictionary.SopEntryForm.OpenWindowFunction.Invoke(FieldReadOnly`1 inParam1, FieldReadOnly`1 inParam2, FieldReadOnly`1 inOptionalParam3, FieldReadOnly`1 inOptionalParam4, FieldReadOnly`1 inOptionalParam5)
at DHSdynamics.Windows.ActionWindowForm.OnSopDocumentEditButtonClick(Object sender, EventArgs ea)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
--
BTW - if you do click Continue everything seems to work but I don't want my users to have to click through this dialog several dozen times per day.
I feel like I'm missing something or there is something I don't know I have to do. Any help would be much appreciated. Thanks.