05-02-2017 09:42 PM
For non-modal dialogs, I often would like an "auto-update" feature that would be timer-based. For example, refreshing an XTable of SQL results every 10 seconds, for example.
I've cobbled together some EventCustomAction and EventMouseMove events to update at some frequency but it still misses the mark.
I'm open to using ActiveX objects if necessary. Thanks for any ideas you have!
Julia
Solved! Go to Solution.
05-03-2017 04:24 AM - edited 05-03-2017 04:50 AM
Hey Julia,
Find an example attached that shows how to start a worker that's running in the background and periodically updating the dialog.
This might not be the best solution in terms of performance but it runs completely without any external ActiveX object.
You can also use ToCommand object in combination with CmdExecuteSync function from any DIAdem external script.
By calling a user command it should also be possible to update the non modal dialog from external applications.
http://zone.ni.com/reference/de-XX/help/370858K-0113/ole/objects/ole_objects_itocommand/
http://zone.ni.com/reference/en-XX/help/370858M-01/exploff/examples/example_ole/
Regards
05-03-2017 11:03 AM
Thank you! I will try to worker option and see how it affects performance.
Julia
05-03-2017 11:58 AM
I can use (and edit!) your dialog fine, but if I try to transfer things to my dialog I keep getting an "object required" error in the debug view for when I set the object's text in this line:
oEditBox.Text = CurrDateTime
EditBox1 exists in my SUD and I added all the code from your SUD so I'm confused! I must be missing something simple but can't think of it...
05-03-2017 04:08 PM
Hi Julia,
In WorkerScript.vbs it's important that this line includes the correct control name (e.g. "EditBox1") and dialog name (e.g. "Dlg1"):
Set oEditBox = LocalWorker.MasterApplication.SudNonModalDlgLst("Dlg1").Controls("EditBox1")
then you can assign new values like this:
oEditBox.Text = CurrDateTime
oEditBox is just a variable that stores a reference to a control with name "EditBox1", so if your control name changes you just have to modify the first code line above.
If this does not solve the problem let me know.
Regards
05-03-2017 04:56 PM
Yes, the frustrating thing is I can create a new dialog and use different objects (text, editbox, buttons) and things work fine, it's just the (rather large and complex) dialog I'm trying to add this to I continue to get the error. I've tried setting up everything from the beginning many times, so am wondering if there might be something in the dialog that is preventing this?
I'm not sure what version of DIAdem my dialog was created in...
05-03-2017 08:44 PM
Ok I rebuilt my dialog in DIAdem 2017 (the version I'm currently using) and all is well! I'd still like to know why it wouldn't work before but some mysteries remain unsolved 😕
05-03-2017 09:09 PM
I think I figured it out! The controls that weren't working for me were all in a TabPageCtrl object! If I keep the objects outside that everything works. Is there a way to access those objects when I'm setting the object in the worker script?
05-04-2017 10:22 AM
It should work like this:
dim oEditBox, oDlg set oDlg = LocalWorker.MasterApplication.SudNonModalDlgLst("Dlg1") Set oEditBox = oDlg.Controls("TabPageCtrl1").Pages(1).Controls("EditBox1") oEditBox.Text = CurrDateTime call oEditBox.RefreshValue()
Regards
05-04-2017 11:02 AM
perfect, thanks!