DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Dialog SetFocus not working on first call

Solved!
Go to solution

I have a dialog box that I call during the beginning of my script.

 

In the Dialog script, I have this code that is supposed to run when the Dialog box is called.

Sub Dialog_EventInitialize(ByRef This)
  Call ebTestNo.SetFocus   
End Sub

 

I am trying to set the cursor focus on a text box (ebTestNo) so the user can enter text without needing to click the box first.

 

I am getting some strange behavior when I run my script.

 

I have it set to run as a file shortcut that launches Diadem and calls the script. When this happens, the Dialog does not set the focus on the text box. My script runs in a loop that returns to the dialog box call to prompt for another text entry. The second and every subsequent call to the Dialog box sets the focus correctly on the text box.

 

When I run my script by first loading it into Diadem then using the script debugging tools, the Dialog box sets the focus correctly the first time.

0 Kudos
Message 1 of 5
(2,222 Views)

Hi sirwin,

 

I agree that the Dialog_EventInitialize() Sub is designed to make initial assignments like this, and I'm surprised that this is not working for you.  Would it be possible for you to post your calling VBScript and the SUDialog to this Discussion Forum post?  Or you could email it to me at brad.turpin@ni.com.

 

If neither is possible, please clarify if you're calling the SUDialog from your VBScript each time, or if the scripted loop you mention is inside the *.SUD file.

 

Brad Turpin

Senior Technical Support Engineer

National Instruments

0 Kudos
Message 2 of 5
(2,144 Views)

Hi Brad,

I attached my data import script and the dialog box. The data import script relies on a couple data plugins that are proprietary and I can’t share them. However, the script should run up to the call to the dialog box and return the user input.

 

My main script calls this data import script at the beginning of each loop so the user can enter a new test number. I launch my main script using the /cscriptstart parameter from this article:

https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z000000kKOUSA2&l=en-US

When I use that method, the dialog box doesn’t set the focus on the text box on the first iteration of the main script. When it loops for the next user input, it sets the focus correctly.

 

When I open Diadem first, load my main script in the Script panel, and click Run, it calls the dialog box and sets the focus correctly.

0 Kudos
Message 3 of 5
(2,134 Views)
Solution
Accepted by topic author sirwin

Hi sirwin,

 

I can reproduce the lack of focus on the "Test Number" control when running the script as part of the DIAdem startup routine.  I can also reproduce that the focus is there when running the script from the Script panel.  That gave me an idea.  I added a line to the script to programmatically open up the SCRIPT panel before calling the SUDialog, and voila', the focus is there on startup:

 

Call WndShow("SCRIPT", "OPEN")

 

Brad Turpin

Senior Technical Support Engineer

National Instruments

Message 4 of 5
(2,092 Views)

Excellent, that worked for me too, tested the entire script and the focus sets correctly.

0 Kudos
Message 5 of 5
(2,076 Views)