LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I defer the commit of InsertTextBoxLine?

Hi,
I'm using InsertTextBoxLine to insert lines into a text box.
My code calls this function in a loop,inserting lines into
the same text box.
My problem is that this causes screen flashing, depending upon
the number of times it is called in the loop.
Is there a way to have InsertTextBoxLine commit and show data
at the end of the loop?
Thanks, all help is appreciated.
0 Kudos
Message 1 of 4
(3,474 Views)
Hello swati505,

I didn't see the blinking behavior you saw, but I might be using a different version of CVI. Which version are you using?

Either way, I would suggest putting a call to ProcessDrawEvents() or ProcessSystemEvents() function in your loop. InsertTextBoxLine doesn't include a forced redraw of the control in the function, instead it places a redraw event in the queue to have the control redraw after the current callback. So you have to process the draw event and then continue the callback to see the update immediately.
Wendy L
LabWindows/CVI Developer Newsletter
0 Kudos
Message 2 of 4
(3,457 Views)
Hi swati505.

You could change your code so that the text box is not updated with each line. You could, for example, do it in a timer callback. You will need to embed newline characters in your buffer.

// Get the number of visible lines for the text box
GetCtrlAttribute (panel, control, ATTR_VISIBLE_LINES, &visible);
...
// This goes in your loop
strcat (textBuffer, "%s\n", newText);
...
// Periodically update the text box and clear the buffer
SetCtrlAttribute (panel, control, ATTR_CTRL_VAL, textBuffer);
textBuffer[0] = 0;
// Check how many lines are now in the box
GetNumTextBoxLines (panel, control, &lines);
// Scroll to the last line of text
SetCtrlAttribute (panel, control, ATTR_FIRST_VISIBLE_LINE,
lines > (visible - 1)? lines - visible + 2: 0);

Regards,
Colin.
0 Kudos
Message 3 of 4
(3,450 Views)
I'm running CVI ver 6.0. The timer solution took care of my problem. Thanks!
0 Kudos
Message 4 of 4
(3,424 Views)