List ctrl blinking items problem
-
Hi, I'm facing an annoying problem while using a list control. In my project,I have a list control which I need to update every 250msec(the list of items is a dynamic list). In order to update the list control, I delete all of the items in the list control and insert the new items to the list. As a result,the list control is blinking. I'm using the following peace of code
m_list.SetRedraw(FALSE);
m_list.deleteAllItems();
for(int nIndex = 0 ; nIndex < ItemsList.GetSize() ; nIndex++)
{
m_list.InsertItem(nIndex , _T(""));
m_list.SetItem(nIndex , 0 , ItemsList.RemoveHead().GetName());
m_list.SetItem(nIndex , 0 , ItemsList.RemoveHead().GetIP());
}
m_list.SetRedraw(TRUE);I tried to pdause LockWindowUpdate() and UnlockWindowUpdate() instead of SetRedraw() but the items continue to blink. Is there a better way to update the list without blinking??? HELP!!!!!:(( With bes regards, Eli
-
Hi, I'm facing an annoying problem while using a list control. In my project,I have a list control which I need to update every 250msec(the list of items is a dynamic list). In order to update the list control, I delete all of the items in the list control and insert the new items to the list. As a result,the list control is blinking. I'm using the following peace of code
m_list.SetRedraw(FALSE);
m_list.deleteAllItems();
for(int nIndex = 0 ; nIndex < ItemsList.GetSize() ; nIndex++)
{
m_list.InsertItem(nIndex , _T(""));
m_list.SetItem(nIndex , 0 , ItemsList.RemoveHead().GetName());
m_list.SetItem(nIndex , 0 , ItemsList.RemoveHead().GetIP());
}
m_list.SetRedraw(TRUE);I tried to pdause LockWindowUpdate() and UnlockWindowUpdate() instead of SetRedraw() but the items continue to blink. Is there a better way to update the list without blinking??? HELP!!!!!:(( With bes regards, Eli
Hello, Maybe you need to create a method that compares and changes only what needs to change. This soluction will gibe you problems if the number of items incrise. populating ListCtrls and ListBoxes are expensive, and will be very slow if the number of item incrise.
-
Hi, I'm facing an annoying problem while using a list control. In my project,I have a list control which I need to update every 250msec(the list of items is a dynamic list). In order to update the list control, I delete all of the items in the list control and insert the new items to the list. As a result,the list control is blinking. I'm using the following peace of code
m_list.SetRedraw(FALSE);
m_list.deleteAllItems();
for(int nIndex = 0 ; nIndex < ItemsList.GetSize() ; nIndex++)
{
m_list.InsertItem(nIndex , _T(""));
m_list.SetItem(nIndex , 0 , ItemsList.RemoveHead().GetName());
m_list.SetItem(nIndex , 0 , ItemsList.RemoveHead().GetIP());
}
m_list.SetRedraw(TRUE);I tried to pdause LockWindowUpdate() and UnlockWindowUpdate() instead of SetRedraw() but the items continue to blink. Is there a better way to update the list without blinking??? HELP!!!!!:(( With bes regards, Eli
As Max mentioned, populating list view controls is expensive. Even more so the way you are adding items - 3 updates for each item. If you use a "virtual list-view" (one that has the LVS_OWNERDATA style) then you can store each item's info in a collection of some kind and do all your processing in the background. The only time the list view has to change is when items are added or removed (so the total number of items in the control is always the same as the number of items in the collection). After each update of the contents, just a repaint of the control would be necessary. Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
-
As Max mentioned, populating list view controls is expensive. Even more so the way you are adding items - 3 updates for each item. If you use a "virtual list-view" (one that has the LVS_OWNERDATA style) then you can store each item's info in a collection of some kind and do all your processing in the background. The only time the list view has to change is when items are added or removed (so the total number of items in the control is always the same as the number of items in the collection). After each update of the contents, just a repaint of the control would be necessary. Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
Hi Mark,
Mark Salsbery wrote:
If you use a "virtual list-view" (one that has the LVS_OWNERDATA style) then you can store each item's info in a collection of some kind and do all your processing in the background.
In order to do so,I need to search if the current items in the collection exists in the list ctrl,and this is not something that we want to do(we don't want that the list control will have to know what kind of items it "holds"...). Anyway,Thanks for your reply, With best regards, Eli
-
Hi Mark,
Mark Salsbery wrote:
If you use a "virtual list-view" (one that has the LVS_OWNERDATA style) then you can store each item's info in a collection of some kind and do all your processing in the background.
In order to do so,I need to search if the current items in the collection exists in the list ctrl,and this is not something that we want to do(we don't want that the list control will have to know what kind of items it "holds"...). Anyway,Thanks for your reply, With best regards, Eli
eli15021979 wrote:
(we don't want that the list control will have to know what kind of items it "holds"...).
I'm not sure you understood what I meant. In a virtual list control, you store everything about the items somewhere else. The control keeps index and state information only. When the control needs to draw it sends a notification requesting the text for each item and subitem. From the looks of your sample code, you already have that information in a list container, so there's no reason to store it in the control as well (like you are doing now). Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder