How to avoid flickering in CListCtrl
-
Hi, I have list control whose property is set to "List1",IDC_CmdResp,"SysListView32",LVS_REPORT | WS_BORDER | WS_TABSTOP,293,37,146,214, WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE | WS_EX_RIGHT | WS_EX_STATICEDGE Am displaying the data read from the serial port in the list control but there is lot of filckering.Below is the code to display the data in list control.Is there any thing am missing in the code.Why there is flickering?More flickering starts when i start deleting the data.If i don't delete i get assert error that maybe due to memory overflow of the list control.Plz help me out. void CNgpptDialog::ReadSerialData(CString sIn) { CString pressure_data; ptrCmdResp->SetRedraw(false); pressure_data=sIn; int counter = ptrCmdResp->GetItemCount(); ptrCmdResp->InsertItem(counter, "");// to insert a row ptrCmdResp->SetItemText(counter, 0, pressure_data);// column0 ptrCmdResp->EnsureVisible(counter, FALSE); // Scrolls downwords. if(counter > 150)// I start deleting first data when the number of items in the list control is > 150 { ptrCmdResp->DeleteItem(0); } ptrCmdResp->SetRedraw(true); int nIndex = ptrCmdResp->GetItemCount(); ptrCmdResp->RedrawItems(nIndex,nIndex); } } Thanks in advance
-
Hi, I have list control whose property is set to "List1",IDC_CmdResp,"SysListView32",LVS_REPORT | WS_BORDER | WS_TABSTOP,293,37,146,214, WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE | WS_EX_RIGHT | WS_EX_STATICEDGE Am displaying the data read from the serial port in the list control but there is lot of filckering.Below is the code to display the data in list control.Is there any thing am missing in the code.Why there is flickering?More flickering starts when i start deleting the data.If i don't delete i get assert error that maybe due to memory overflow of the list control.Plz help me out. void CNgpptDialog::ReadSerialData(CString sIn) { CString pressure_data; ptrCmdResp->SetRedraw(false); pressure_data=sIn; int counter = ptrCmdResp->GetItemCount(); ptrCmdResp->InsertItem(counter, "");// to insert a row ptrCmdResp->SetItemText(counter, 0, pressure_data);// column0 ptrCmdResp->EnsureVisible(counter, FALSE); // Scrolls downwords. if(counter > 150)// I start deleting first data when the number of items in the list control is > 150 { ptrCmdResp->DeleteItem(0); } ptrCmdResp->SetRedraw(true); int nIndex = ptrCmdResp->GetItemCount(); ptrCmdResp->RedrawItems(nIndex,nIndex); } } Thanks in advance
With one post is enough... at least you could change your text and explain yourself in another way. Maybe is not clear what you mind (i.e. I don't know the word flickering)
Greetings. -------- M.D.V. If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you ;)
-
Hi, I have list control whose property is set to "List1",IDC_CmdResp,"SysListView32",LVS_REPORT | WS_BORDER | WS_TABSTOP,293,37,146,214, WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE | WS_EX_RIGHT | WS_EX_STATICEDGE Am displaying the data read from the serial port in the list control but there is lot of filckering.Below is the code to display the data in list control.Is there any thing am missing in the code.Why there is flickering?More flickering starts when i start deleting the data.If i don't delete i get assert error that maybe due to memory overflow of the list control.Plz help me out. void CNgpptDialog::ReadSerialData(CString sIn) { CString pressure_data; ptrCmdResp->SetRedraw(false); pressure_data=sIn; int counter = ptrCmdResp->GetItemCount(); ptrCmdResp->InsertItem(counter, "");// to insert a row ptrCmdResp->SetItemText(counter, 0, pressure_data);// column0 ptrCmdResp->EnsureVisible(counter, FALSE); // Scrolls downwords. if(counter > 150)// I start deleting first data when the number of items in the list control is > 150 { ptrCmdResp->DeleteItem(0); } ptrCmdResp->SetRedraw(true); int nIndex = ptrCmdResp->GetItemCount(); ptrCmdResp->RedrawItems(nIndex,nIndex); } } Thanks in advance
shir_k wrote:
int nIndex = ptrCmdResp->GetItemCount(); ptrCmdResp->RedrawItems(nIndex,nIndex);
Comment out these two statements and see what happens.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
shir_k wrote:
int nIndex = ptrCmdResp->GetItemCount(); ptrCmdResp->RedrawItems(nIndex,nIndex);
Comment out these two statements and see what happens.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
With one post is enough... at least you could change your text and explain yourself in another way. Maybe is not clear what you mind (i.e. I don't know the word flickering)
Greetings. -------- M.D.V. If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you ;)
K Got it. The actual issue is When i place the data in List Ctrl the data is unsteady.As am placing data continuously(120 samples/ sec)and i have run the s/w for many days continuously, i need to delete the data in List Ctrl otherwise buffer of the List Ctrl will overflow.After displaying 150 samples in Ctrllist am starting to delete at this moment data is unsteady. Thanks
-
K Got it. The actual issue is When i place the data in List Ctrl the data is unsteady.As am placing data continuously(120 samples/ sec)and i have run the s/w for many days continuously, i need to delete the data in List Ctrl otherwise buffer of the List Ctrl will overflow.After displaying 150 samples in Ctrllist am starting to delete at this moment data is unsteady. Thanks
Well, I reset tmy ListCttrlView everytime the OnDraw is called to empty all datas and then I write the newest values.
void CMyTabView::OnDraw(CDC* pDC)
{ if (m_bJustOpened)
InitializeView ();
if (m_bListRedraw)
DrawViewElements ();
return;
}In initialize views I configure the number of columns (may be variable from 8 up to 32). Write the name of columns and so on... By DrawViewElements (); my FIRST line is:
m_clcRuleList.DeleteAllItems ();
and then I write them down another time. And with that you can call the OnDraw easily with anpDoc->UpdateAllViews (NULL);
in a Timer with the interval you desireGreetings. -------- M.D.V. If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you ;)
-
So if all you are ever going to show is 150 items, why not store those in a fast container of some sort, and populate the list control from that container instead. Doing I/O on such a container would be way faster than the same I/O on a UI control. Make sense?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne