Repainting a List Control
-
Hello I have this list control in a dialog class: CListCtrl m_LIST1; One of the class methods launches a modal dialog after the user selects some items on the list. The problem is when it returns, the selected items in the list control are not painted any more, although the selection is preserved. To repaint i did what F1 said (see code) but it won't work. What am i doing wrong?
void CxwApp::OnWrite() { CWriteDlg writeDlg; writeDlg.DoModal();// //repaint the selected items m_LIST1.RedrawItems(start, end); m_LIST1.Invalidate(); m_LIST1.UpdateWindow(); m_LIST1.RedrawWindow(); ..... }
alex 'Architecture is music frozen in space.' -
Hello I have this list control in a dialog class: CListCtrl m_LIST1; One of the class methods launches a modal dialog after the user selects some items on the list. The problem is when it returns, the selected items in the list control are not painted any more, although the selection is preserved. To repaint i did what F1 said (see code) but it won't work. What am i doing wrong?
void CxwApp::OnWrite() { CWriteDlg writeDlg; writeDlg.DoModal();// //repaint the selected items m_LIST1.RedrawItems(start, end); m_LIST1.Invalidate(); m_LIST1.UpdateWindow(); m_LIST1.RedrawWindow(); ..... }
alex 'Architecture is music frozen in space.'When you return from dialog use the following code for list box
int numberSelected = GetSelCount();
if (numberSelected>0)
{
int *selIndex = new int[numberSelected];
GetSelItems( numberSelected, selIndex );
for (int i=0; i < numberSelected; i++)
{
//blah....your code for deselection of item} }
:) Knock out "T" from CAN'T You 'CAN' if you think you 'CAN' :cool:
-
Hello I have this list control in a dialog class: CListCtrl m_LIST1; One of the class methods launches a modal dialog after the user selects some items on the list. The problem is when it returns, the selected items in the list control are not painted any more, although the selection is preserved. To repaint i did what F1 said (see code) but it won't work. What am i doing wrong?
void CxwApp::OnWrite() { CWriteDlg writeDlg; writeDlg.DoModal();// //repaint the selected items m_LIST1.RedrawItems(start, end); m_LIST1.Invalidate(); m_LIST1.UpdateWindow(); m_LIST1.RedrawWindow(); ..... }
alex 'Architecture is music frozen in space.'That code is going to redraw the list 3 times. All you need is one call to
RedrawWindow()
.--Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | NEW!! PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
-
When you return from dialog use the following code for list box
int numberSelected = GetSelCount();
if (numberSelected>0)
{
int *selIndex = new int[numberSelected];
GetSelItems( numberSelected, selIndex );
for (int i=0; i < numberSelected; i++)
{
//blah....your code for deselection of item} }
:) Knock out "T" from CAN'T You 'CAN' if you think you 'CAN' :cool:
-
That code is going to redraw the list 3 times. All you need is one call to
RedrawWindow()
.--Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | NEW!! PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
-
Hello I have this list control in a dialog class: CListCtrl m_LIST1; One of the class methods launches a modal dialog after the user selects some items on the list. The problem is when it returns, the selected items in the list control are not painted any more, although the selection is preserved. To repaint i did what F1 said (see code) but it won't work. What am i doing wrong?
void CxwApp::OnWrite() { CWriteDlg writeDlg; writeDlg.DoModal();// //repaint the selected items m_LIST1.RedrawItems(start, end); m_LIST1.Invalidate(); m_LIST1.UpdateWindow(); m_LIST1.RedrawWindow(); ..... }
alex 'Architecture is music frozen in space.'