06-08-2017 10:10 AM
Hi,
I am trying to prepare example how to use modal VIs in TestStand. But I myself do not know how to do it correctly 😄 Actually everything works well until I launch message box with method TS_EngineDisplayMessageBox. I found that this hang is somehow expected: http://digital.ni.com/public.nsf/allkb/621F0957FAC5EA72862579A5006CC001.
The proposed solution is to make VI non-modal, but my VI must be modal! Setting "Always run in the LabVIEW Run-Time Engine" option also does not work...
Any idea how to fix it?
I have attached the example which I am preparing.
You can launch Modal Window Test.seq. PreBatch will show TestStand Example.vi modal front panel, and then you will see Modal Window.vi (also modal). If you will try to enter empty serial number you should see error message box. After you click ok in error, you will not be able to do enything more - it will be hanged.
06-09-2017 07:13 AM
Without looking into your attachement: Did you include the "Start Modal" and "End Modal" methods in your popup?
06-12-2017 03:33 AM
Yes, I did. In both windows. Unfortunately there is no way to control this with Message Box method. I think I will need to use User32.dll to reproduce the functionality, because there's a possibility to set proper caller window reference.
https://msdn.microsoft.com/pl-pl/library/windows/desktop/ms645505(v=vs.85).aspx
Alternatively, I'll try to explicitly set caller window handler with Engine.AppMainHwnd.
06-13-2017 03:33 AM - edited 06-13-2017 03:33 AM
I reviewed your example and obviously, you cannot "stack" a 'Display Message Box' on top of a modal popup (Start Modal Dialog).
That being said, there are two options:
1. End Modal Dialog before checking the SN. After check was done (Validate Serial Number.vi) 'Re-Start' Modal Dialog.
As a result, the SN entry dialog will disappear for the time the SN is validated. Which, as a benefit, enables the error message box to display properly. However, if no error popus up, the dialog flashes which might confuse the user.
2. Do not use the Display Message Box function from the TS API. Implement a custom LV based popup and show this one instead. (not tested, but should work)
06-14-2017 04:25 PM
Thank you Norbert for your response.
I would like to refer to your suggestions.
Ad.1. It looks like bad UX.
Ad.2. It looks like lot of work (User32 message box functionality replication in LabVIEW is like reinventing the wheel) and bad style. Better idea is to use this: https://msdn.microsoft.com/pl-pl/library/windows/desktop/ms645505(v=vs.85).aspx
I updated my example with user32 message box, with caller window handler and MB_SYSTEMMODAL flag, and now it works as charm.
IMO NI should add possibility to point caller window reference in TS API message box.
PS While I'm writing this I came out with the idea to try MB_SYSTEMMODAL flag with TS API. Since TS is using user32 message box in its API it might work also, provided that Engine.AppMainHwnd is properly updated and is used as a hWnd in user32 MessageBox function. I will try this tomorrow, because now is bed time 🙂
05-27-2020 04:32 PM
05-28-2020 02:23 AM
@CsBihacker wrote:
Hello bienieck,
I wanted to check your example, but cannot, I have LV18 only.
Could you update the LVproject file?
Thank you in advance.
Strange. The project from the first post is saved in LV2013, I'm opening it in LV2019, and you cannot open it in LV2018?
I'm attaching LV project saved to LV2018 (opened in LV2019).
05-28-2020 06:38 AM