02-19-2016 11:48 AM
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?
02-19-2016 12:17 PM
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
02-19-2016 12:42 PM
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 ()?
02-19-2016 01:03 PM
I see
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,...?
02-19-2016 01:15 PM
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.
02-19-2016 01:36 PM
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.
02-19-2016 02:11 PM
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.
02-19-2016 05:40 PM
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.
02-20-2016 05:53 AM
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
02-20-2016 07:46 PM
Actually, I did check the result of SetCtrlVal at one point and it returned zero which I think is success.