DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Looking for reliable method to "auto update" object on SUD dialog

Solved!
Go to solution

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

0 Kudos
Message 1 of 10
(3,429 Views)
Solution
Accepted by topic author JuliaDawkins

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

Christian
CLA, CTA, CLED
0 Kudos
Message 2 of 10
(3,383 Views)

Thank you! I will try to worker option and see how it affects performance.

 

Julia

0 Kudos
Message 3 of 10
(3,359 Views)

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...

0 Kudos
Message 4 of 10
(3,354 Views)

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

Christian
CLA, CTA, CLED
0 Kudos
Message 5 of 10
(3,348 Views)

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...

0 Kudos
Message 6 of 10
(3,345 Views)

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 😕

0 Kudos
Message 7 of 10
(3,339 Views)

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?  

0 Kudos
Message 8 of 10
(3,325 Views)
Solution
Accepted by topic author JuliaDawkins

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

Christian
CLA, CTA, CLED
0 Kudos
Message 9 of 10
(3,306 Views)

perfect, thanks!

0 Kudos
Message 10 of 10
(3,303 Views)