[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 525
  • Last Modified:

Need a working virtual CListCtrl solution urgently !

Hi ! Currently I'm working on a module that has to load thousands of record into the list control and display.

Lately I realize that using the normal list control to do that task is not really good. Either the loading time is too long, or the program will hang straight away.

I think virtual list control is the right solution for this task. But I don't have enough time to do try and error kind of stuff, so I need a working virtual list control solution urgently.

Does anybody out there has the solution already ? If yes, please send me (cytay@hotmail.com) an example. I'm truly appreciate that, and thank you in advance. :o)
0
cytay
Asked:
cytay
1 Solution
 
Vinayak KumbarSr Program ManagerCommented:
Hi,

I am sending U the sample.

Hope that helps.
0
 
cytayAuthor Commented:
Thanks ! I will test it out first !
0
 
cytayAuthor Commented:
VinExpert, I'm sorry to let you down here, because I need the solution that is implemented in class instead of function.

Do you have that ?
0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
Vinayak KumbarSr Program ManagerCommented:

Okay, I will try that. I think it is possible by moving some of the functions into some class.

If U get it working, pls send me that code.
Thanks.
0
 
cytayAuthor Commented:
No problem !
0
 
Gandalf32Commented:
The standard CListCtrl supports virtual lists. You can check out:
http://msdn.microsoft.com/library/devprods/vs6/visualc/vccore/_core_virtual_list_controls.htm
0
 
Vinayak KumbarSr Program ManagerCommented:
Hi,

I have sent U the workspace for virtual list control.
unzip it, biuld it and run it.

Try it out.
0
 
cytayAuthor Commented:
Hi,

VinExpert, sorry for the late reply ! It is because lately there is a nation election held in my country. That's why I didn't have time to test the sample you sent me till now.

Anyway, thanks for the effort to put the SDK into class, I do appreciate that. Unfortunately the sample is not working very well. Any idea !?

Thanks !
0
 
Vinayak KumbarSr Program ManagerCommented:
Hi,

I have sent the new workspace.
I think that will satisfy U as it contains everything.

Hope that helps.
VinExpert
0
 
cytayAuthor Commented:
Hi ! Sorry for the delay ! I hope you don't mind and forgive me. This is because I'm busy in solving some other problems recently.

Yes ! I have tried your example. It is good to be true that the list control can contain 10000 items without performance problem ! Thanks !
0
 
darinwCommented:
Hello everyone,

Experts - Remember that a PAQ without a solution is going to be deleted. I understand that an email exchange is necessary at times, but it is always mandatory that you post your solution here. Even if it is only a discription that will let the person buying the PAQ recreate your solution.

VinExpert can you post your code? If not, I'll need to delete this PAQ and the point award.

darinw
Community Support
0
 
cytayAuthor Commented:
Hey ! darinw, please check through the above events ! I had accepted the answer long time ago. :o)
0
 
Vinayak KumbarSr Program ManagerCommented:
Hellooo...

I am posting the code here as it may be required for others to see this.

In the dialog class, in OnInitDialog function create the list control as bellow,

BOOL MyDlg::OnInitDialog()
{
      CDialog::OnInitDialog();
      
      DWORD       dwStyle;      
      dwStyle =   WS_TABSTOP |
                        WS_CHILD |
                        WS_BORDER |
                        WS_VISIBLE |
                        LVS_AUTOARRANGE |
                        LVS_REPORT |
                        LVS_OWNERDATA;
      
      HWND hWndParent   = AfxGetMainWnd()->GetSafeHwnd();
      RECT  rc;
      GetClientRect(&rc);
      RECT rect;
      rect.left = rc.left + 30;
      rect.top  = rc.top + 45;
      rect.bottom = 380;
      rect.right  = 500;

      BOOL bSuccess = m_VirtualLstCtrl.Create(dwStyle,rect,this,1000);
      ListView_SetExtendedListViewStyle(m_VirtualLstCtrl,LVS_EX_GRIDLINES|LVS_EX_FULLROWSELECT);


      LV_COLUMN   lvColumn;
      int         i;
      TCHAR       szString[10][20] = {"Line No", "TimeStamp(┬Ás)", "Channel", "Frame Name", "Frame ID",
                                                "Data","STD/EXT","Tx/Rx","Color","TimeStamp1"};

      //empty the list
      ListView_DeleteAllItems(m_VirtualLstCtrl);

      //initialize the columns
      lvColumn.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
      lvColumn.fmt = LVCFMT_LEFT;
      lvColumn.cx = 120;
      for(i = 0; i < 10; i++)
      {
         lvColumn.pszText = szString[i];
         ListView_InsertColumn(m_VirtualLstCtrl, i, &lvColumn);
      }
      ListView_SetItemCount(m_VirtualLstCtrl, 100);      
      return TRUE;  // return TRUE unless you set the focus to a control
                    // EXCEPTION: OCX Property Pages should return FALSE
}

here the m_VirtualLstCtrl is the object of the CVirtListCtrl class, which is the class derived from the CListCtrl.

Then map the LVN_GETDISPINFO to the CVirtListCtrl and modify the code as

void CVirtListCtrl::OnGetdispinfo(NMHDR* pNMHDR, LRESULT* pResult)
{
      LV_DISPINFO* lpdi = (LV_DISPINFO*)pNMHDR;
      TCHAR szString[MAX_PATH];

      if(lpdi->item.iSubItem)
         {
         if(lpdi->item.mask & LVIF_TEXT)
            {
            wsprintf(szString, "Item %d - Column %d", lpdi->item.iItem + 1, lpdi->item.iSubItem);
            lstrcpy(lpdi->item.pszText, szString);
            }
         }
      else
         {
         if(lpdi->item.mask & LVIF_TEXT)
            {
            wsprintf(szString, "Item %d", lpdi->item.iItem + 1);
            lstrcpy(lpdi->item.pszText, szString);
            }

         if(lpdi->item.mask & LVIF_IMAGE)
            {
            lpdi->item.iImage = 0;
            }
         }
      
      *pResult = 0;
}

There we go...That should give U the virtual list control!!!.

E'Njoy...

VinExpert
0
 
cytayAuthor Commented:
Hey ! I really appreciate your endless help. Hmm... Let me try the above codes first ! :o)
By the way, is there anyway I can contact you ?
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now