LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

SetCtrlVal not updating control

I am developing with CVI after a few years away. I have a string control that I want to update and call SetCtrlVal() but it does not update the control text until after the GUI window x is clicked. Actually, none of the code after RunUserInterface () runs until that point. I  do not remember this from the past but I checked my version at home and saw the same behavior.

 

So, how do you get code to run after RunUserInterface? For instance how would a textbox that continually gets status information, such as "Interface opened,  DUT not responding, etc be implemented?

0 Kudos
Message 1 of 12
(5,304 Views)

Hello,

 

without more detailed information about your code it is a bit speculative, but did you try calling ProcessDrawEvents () right after SetCtrlVal () ? If it helps, you may have one of the issues described here

0 Kudos
Message 2 of 12
(5,301 Views)

Hi Wolfgang,

 

I did try ProcessDrawEvents () and it did not cause the string control to update.

 

My code looks like:

/* display the panel and run the user interface */
    errChk (DisplayPanel (panelHandle));
    errChk (RunUserInterface ());
   
    SetCtrlVal (PANEL, PANEL_NI8452_SPI_Host, name);   //ni8452Name
    
   do something();

 

   do somethingelse();

 

and none of it runs until I click on the panel red x and the panel starts to close. I see the string update just before it close. It would update if I moved SetCtrlVal () to before the /* display the panel and run the user interface */ lines but that still leaves how do I update it after RunUserInterface ()?
 
    
  

0 Kudos
Message 3 of 12
(5,300 Views)

I see Smiley Happy

 

The lines after RunUserInterface are not called because RunUserInterface starts processing events until QuitUserInterface is called, so, as you described, your code SetCtrlVal () and 'do something' will be called only when your program terminates. You will need to have some callback...

say by a timer control.

 

How does your code know that you want to update the string control? When receiving some user input, some data on a serial port,...?

0 Kudos
Message 4 of 12
(5,293 Views)

Hi Wolfgang,

 

The real question for me is how do I  do anything after the run UI. In this case I want to update the text control with the resource string of an instrument that as been opened, I think I am not familiar enough with the callback model.  I want to open a piece of hardware and update the string control with the resource nane. Send and receive some data from a DUT and display some of that data. All of tha may be upon running the program with no user events having occurred.

0 Kudos
Message 5 of 12
(5,289 Views)

Hi,

 

As mentioned before the code after RunUserInterface () is called only when QuitUserInterface () is called.... So as long as you want to display information only once you can do this before calling RunUserInterface (), otherwise you need to react to events. These do not have to be user interface events. For example, serial ports also can generate events, see here.

 

Here is a brief introduction to the event / callback function concept.

0 Kudos
Message 6 of 12
(5,284 Views)

Thank you for the callback link. I do want to use a textbox as a status indicator during program execution so I will need to update it after UI run. I am more used to Visual c# where you can update the controls easily from the program.

0 Kudos
Message 7 of 12
(5,278 Views)

As a side note,  the first parameter to SetCtrlVal must be the handle returned from LoadPanel (panel Handle in your case),   while you are passing the panel resource name instead. 



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 8 of 12
(5,264 Views)

Smiley Happy I also have a side note (related to Roberto's comment): whereas you check your function calls DisplayPanel () and RunUserInterface () for errors, you don't do so with SetCtrlVal (); you should and probably it will tell what Roberto already mentioned Smiley Happy

0 Kudos
Message 9 of 12
(5,252 Views)

Actually, I did check the result of SetCtrlVal at one point and it returned zero which I think is success.

0 Kudos
Message 10 of 12
(5,240 Views)