08-17-2005 04:02 PM - edited 08-17-2005 04:02 PM
Message Edited by vishianand on 08-17-2005 04:04 PM
08-17-2005 04:14 PM
08-18-2005 09:11 AM
08-18-2005 09:23 AM
05-03-2007 05:08 AM
HI,
any update on the problem?
I'm interested because I'm having the same problem, which is updating a List Box from another thread different from the one in which I run RunUserInterface().
I'm updating a whole List Box Control, first doing a ClearListCtrl() and then performing the necessary InsertListItem()'s to put on the list the actual items.
The problem seems to be that the control doesn't update until you make a call from the thread that controls de CVI. I have tried calling ProcessDrawEvents() and it doesn't work. I have also tried to put a Sleep() after updating the control but it doesn't work either.
What I have done finally is to create a function that puts the control invisible and then visible again, and when it becomes visible again it has the new values correctly updated. The problem with this solution is that the control blinks and it has a very very bad effect on the application.
void RefreshControl(int panel, int control)
{
SetCtrlAttribute(panel, control, ATTR_VISIBLE, false);
SetCtrlAttribute(panel, control, ATTR_VISIBLE, true);
}
Is there any function that can force a control to update (or repaint)??
I'm working with Labwindows/CVI 8.1 and Microsoft Visual C++
Regards,
Daniel
05-03-2007 12:20 PM
05-04-2007 02:35 AM
Hello,
I understand there's this limitation to Labwindows, but wouldn't it make sense to have a function (like mine RefreshControl) that would repaint a control on programmer's desire, without having to wait for the scheduled repainting of a panel or control from the main thread?
To simplify my app, it has 2 threads. One thread (CVI_Thread) just starts and runs RunUserInterface() and is responsible for handling the user interaction with all panel and buttons. The other thread (LAN_Thread) starts a socket and handles LAN messages. Then I have a List Box Control with some items. I can 'add' or 'delete' items manually as a user and it works properly (I have buttons for that and they generate events that are treated by CVI_Thread as usual).
But I can also receive a list of these items through a LAN message, so when it arrives, I update my List Box Control, and this is done by the LAN_Thread, and not the CVI_Thread.
The code would be like this:
CVI_Thread::MessageReceived (ItemList)
{
SaveToDataBase(ItemList);
ClearListCtrl(panel, listControl);
for all items in ItemList
IsertListItem(panel, listControl, item);
//RefreshControl(panel, listControl);
}
Without the call to RefreshControl(), the changes on the ItemList don't appear on screen. If I make a call to my 'RefreshControl' function (which just makes the control invisible and visible again, see above), my listControl blinks and when it comes back it has all the new items
Note that if I receive an empty list of items, I would just clear my listControl. This also fails.
I don't know what else to try. Thanks for your help
Regards,
Daniel
05-04-2007 09:06 AM
05-04-2007 09:51 AM
05-04-2007 02:00 PM