12-08-2009 06:28 AM
Hi All,
I'm facing a trivial problem,but is important on Usability point of view.
I'm call a UI dialog(a .NET dll) as step in sequence editor.This dialog is a modal window to sequence editor.
As a close this modal window the sequence editor minimizes.
I'm passing handle of sequnce editor to showdialog method of my UI dialog on invoke of the UI dialog.
//Code begins here
public void ShowUIdialog()
{
Process proc = Process.GetCurrentProcess();
IntPtr hwnd = proc.MainWindowHandle;
TSWindow = new WindowWrapper(hwnd);
this.m_NewConfigRep.ShowDialog(TSWindow);//Pass the handle of sequence ediitor to UI dialog
}
public class WindowWrapper : System.Windows.Forms.IWin32Window
{
public WindowWrapper(IntPtr handle)
{
_hwnd = handle;
}
public IntPtr Handle
{
get { return _hwnd; }
}
private IntPtr _hwnd;
}
//Code ends here
How can i close my UI dialog without minimizing the sequence editor?
Thanks in advance
VDC
12-09-2009 06:28 AM
12-09-2009 09:10 AM
To make your dialog modal to TestStand you need to use the Engine.NotifyStartOfModalDialogEx and Engine.NotifyEndOfModalDialog methods. Here is a simple example of how to use those methods:
public void ShowModalDialog(SequenceContext sequenceContext){
bool shouldAbort;
int modalID = sequenceContext.Engine.NotifyStartOfModalDialogEx(sequenceContext, out shouldAbort);
if (!shouldAbort)
{
this.ShowDialog();
}
sequenceContext.Engine.NotifyEndOfModalDialog(modalID);
}
01-04-2010 07:36 PM
Erik, is there any reason why NotifyStartOfModalDialogEx should not return until the step is aborted from the sequence editor?
The program flow just disappears into the statement and does not return until I abort... (at this point the dialog box is then shown correctly modal).
Here's the simple code.
bool MyBool = new bool();
Engine MyEngine = SeqContext.Engine;
int TSHandle = MyEngine.NotifyStartOfModalDialogEx(SeqContext, out MyBool); <---- Hangs here until abort is clicked in sequence editor
I am beginning to think there is something wrong with this function as I have observed the same thing on the LabVIEW side:
http://forums.ni.com/ni/board/message?board.id=330&message.id=26829#M26829
Thanks,
Ronnie
01-05-2010 01:09 AM - edited 01-05-2010 01:10 AM
Hi,
It should always return with out having to press the abort but check the help;
| Note This method differs from the Engine.NotifyStartOfModalDialog method in that if multiple threads call into this method at the same time, only the first thread proceeds. The rest block until the first thread calls the Engine.NotifyEndOfModalDialog method, at which point the next thread proceeds. Thus, TestStand launches modal dialog boxes one at a time using this method. In order to use this method, you must launch the dialog box within the step of an execution and you must pass the sequence context of the step to this method. In certain environments, dialog boxes might take a parameter that is a parent window handle. For this situation, call this method before creating the dialog box, treat the return value as a window handle (HWND), and pass the return value as the handle for the parent window. For environments such as Microsoft Visual Basic, in which setting the parent window handle of dialog boxes is difficult, use the Engine.RegisterModalWindow method instead. |
Regards
Ray
01-05-2010 10:27 AM
Even though I see no discrepancy in what I am doing compared to the help (for example I only have one thread), I changed the call to Engine.NotifyStartOfModalDialog method and that works without any issues. Thanks,
Ronnie
01-05-2010 11:45 AM
01-05-2010 01:11 PM - edited 01-05-2010 01:11 PM