NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Sequence editor minimizes on close of modal window

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

0 Kudos
Message 1 of 8
(4,746 Views)
have a look at this
Shreyas Hebbare
Shreyas Technologies
India
0 Kudos
Message 2 of 8
(4,720 Views)

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);

}

 

0 Kudos
Message 3 of 8
(4,712 Views)

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

TestStand 4.2.1, LabVIEW 2009, LabWindows/CVI 2009
0 Kudos
Message 4 of 8
(4,645 Views)

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

Message Edited by Ray Farmer on 01-05-2010 07:10 AM
Regards
Ray Farmer
0 Kudos
Message 5 of 8
(4,635 Views)

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

 

TestStand 4.2.1, LabVIEW 2009, LabWindows/CVI 2009
0 Kudos
Message 6 of 8
(4,623 Views)
You might observe the behavior you describe if you call Engine.NotifyStartOfModalDialogEx method without calling the Engine.NotifyEndOfModalDialog method. You would have to restart the sequence editor to fix the problem.
0 Kudos
Message 7 of 8
(4,617 Views)
Thanks Erik, that's good to know.
Message Edited by Believer on 01-05-2010 11:11 AM
TestStand 4.2.1, LabVIEW 2009, LabWindows/CVI 2009
0 Kudos
Message 8 of 8
(4,613 Views)