XWL
asked on
Virtual List Contrl doesn't display Data
Hi there,
I am working on a MFC CListCtrol derived class CVirtualList control. I set its style to LVS_OWNERDATA. According to my understanding, as long as the list control is set to owner data, the LVN_GETDISPINFO message will be sent if CListCtrl’s function SetItemCount(int) is called. However, My virtual list control‘s LVN_GETDISPINFO handler never be called when the CListCtrl::SetItemCount(in t) is called. It is strange to me. Could anyone here tell me if there is something I missed?
Environment: Win2K/SP4/VC6.0.
Thank you very much,
XWL
I am working on a MFC CListCtrol derived class CVirtualList control. I set its style to LVS_OWNERDATA. According to my understanding, as long as the list control is set to owner data, the LVN_GETDISPINFO message will be sent if CListCtrl’s function SetItemCount(int) is called. However, My virtual list control‘s LVN_GETDISPINFO handler never be called when the CListCtrl::SetItemCount(in
Environment: Win2K/SP4/VC6.0.
Thank you very much,
XWL
ASKER
Yes, I do supply the data from the owner window. Also I put a breakpoint in the message handler. This is the way to figure out that the handler is never called.
Please post some code for the LVN_GETDISPINFO message - MessageMap entry
ASKER
Good point! Here it is:
BEGIN_MESSAGE_MAP(CVirtual List, CListCtrl)
ON_NOTIFY_REFLECT ( LVN_GETDISPINFO, OnGetDispInfo )
END_MESSAGE_MAP()
BEGIN_MESSAGE_MAP(CVirtual
ON_NOTIFY_REFLECT ( LVN_GETDISPINFO, OnGetDispInfo )
END_MESSAGE_MAP()
That looks OK.
And there is no handler for the message in the dialog (or wherever you have the list control)?
And there is no handler for the message in the dialog (or wherever you have the list control)?
ASKER
one thing I should mention is that I am using my virtual list control in a CView derived class. in function InitUpdate, I casted the standard CListCtrl to my virtual List control:
// Class declaretions
class CMyListView: public CView
{
......
protected:
CListCtrl m_ctlList;
};
class CVirtualListView: public CMyListView
{
......
protected:
CVirtualListCtrl m_pctlVirtualList;
};
class CVirtualListCtrl : public CListCtrl
{
......
};
// Class implemetation
CVirtualListView::OnInitia lUpdate()
{
CMyListView::OnInitialUpda te();
// Cast "standard" CListCtrl object to CVirtualListCtrl object
if (IsWindow(m_ctlList.m_hWnd ))
{
m_pctlVirtualList = (GCVirtualListCtrl*)&m_ctl List;
ASSERT (m_pctlVirtualList->m_hWnd == m_ctlList.m_hWnd);
m_pctlVirtualList->ModifyS tyle( 0, LVS_REPORT | LVS_OWNERDATA );
}
The problem is that the m_pctlVirtualList works partially and its LVN_GETDISPINFO handler is never been called in the CVirtualListView class. The class CVirtualListCtrl works well in other windows such as in a CDialog-derived classes.
Please help me. Thank you,
XWL
// Class declaretions
class CMyListView: public CView
{
......
protected:
CListCtrl m_ctlList;
};
class CVirtualListView: public CMyListView
{
......
protected:
CVirtualListCtrl m_pctlVirtualList;
};
class CVirtualListCtrl : public CListCtrl
{
......
};
// Class implemetation
CVirtualListView::OnInitia
{
CMyListView::OnInitialUpda
// Cast "standard" CListCtrl object to CVirtualListCtrl object
if (IsWindow(m_ctlList.m_hWnd
{
m_pctlVirtualList = (GCVirtualListCtrl*)&m_ctl
ASSERT (m_pctlVirtualList->m_hWnd
m_pctlVirtualList->ModifyS
}
The problem is that the m_pctlVirtualList works partially and its LVN_GETDISPINFO handler is never been called in the CVirtualListView class. The class CVirtualListCtrl works well in other windows such as in a CDialog-derived classes.
Please help me. Thank you,
XWL
ASKER
I increased the point to 250.
OK. You have modified the style of the list control linked to the view. BUT it is still a CListCtrl, not a window based on your CVirtualListCtrl.
You could trap the LVN_GETDISPINFO message in your view and return the info required from that.
Alternatively it might be simpler to have a standard CView based view and create your virtual list control dynamically (eg. in OnInitialUpdate of the view) and make the list control fill the view (OnSize of the view).
You could trap the LVN_GETDISPINFO message in your view and return the info required from that.
Alternatively it might be simpler to have a standard CView based view and create your virtual list control dynamically (eg. in OnInitialUpdate of the view) and make the list control fill the view (OnSize of the view).
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
There are two points that cause the problem were found as AndyAinscow pointed out:
1) The message map entry should follow derivation relationship of the classes, otherwise the message handler would be called;
2) In my case, m_pctlVirtualList = (GCVirtualListCtrl*)&m_ctl List simply doesn't work. After the casting, m_ctlList still exists and message won't be sent to the casted one. My solution is to destory m_ctlList in CVirtualListView::OnCreate ( LPCREATESTRUCT lpcs )function, and then create a CVirtualListCtrl object. After this, the CVirtualListVieew works well.
Thank you all for great ideas, well done!
XWL
1) The message map entry should follow derivation relationship of the classes, otherwise the message handler would be called;
2) In my case, m_pctlVirtualList = (GCVirtualListCtrl*)&m_ctl
Thank you all for great ideas, well done!
XWL
Have you put a breakpoint in the handler to check it isn't being called - maybe it is but something else is the problem