Discussion:
Problem with WM_NOTIFY from a ClistViewCtrl
uo2000
2002-01-22 07:57:30 UTC
Permalink
I have an application that handles the LVN_GETDISPINFO notification
from a view ClistViewCtrl. The listview contents is in an array so I
just call m_view.SetItemCountEx( m_Count, 0 ); to tell the listview
how many rows I have and then handle all the icons and text when the
listview sends a LVN_GETDISPINFO notification.

I wanted to go further and also store the state information in my
array as well so the LVN_SETDISPINFO would be a great help there.
When I add the LVN_SETDISPINFO and LVN_ODSTATECHANGED notifications
they never come up in the message map of the mainfram window. Is
there anyone that knows why this is or have any tips on how to get
information on how it should be done to make it work?
All input will be very appreciated.

I put some trace code in the message map but there is nothing about
either the ANSI or UNICODE notification showing up. No message comes
up in Spy++ either. There is probably something missing but I can not
figure out what. I have not seen a working example of the
LVN_SETDISPINFO so I have no reference.

When I try m_view.SetCallbackMask( LVIS_FOCUSED ); It seams to
understand this because the focus has disappeared from the list, and
if I also add the LVIS_SELECTED the selections also disappears unless
I set the state my self in LVN_GETDISPINFO.

I have followed this group, searched the internet and been to MSDN
and read in the help for CListViewCtrl, the only thing I found was
about WM_NOTIFYFORMAT that I also put in.

Below is excerpts from the source.

Thanks in advance
Ulf


In the _tWinMain:
iccx.dwSize = sizeof(iccx);
iccx.dwICC = ICC_WIN95_CLASSES;
//iccx.dwICC = ICC_COOL_CLASSES | ICC_BAR_CLASSES |
ICC_LISTVIEW_CLASSES;
BOOL bRet = ::InitCommonControlsEx(&iccx);



The definition of the ClistViewCtrl as follows:
typedef CWinTraits<WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS |
WS_CLIPCHILDREN |WS_VSCROLL | LVS_REPORT | LVS_SHOWSELALWAYS |
LVS_SINGLESEL | LVS_SHAREIMAGELISTS |LVS_OWNERDATA, WS_EX_CLIENTEDGE>
LexinUpdateTraits;

class CLexinUpdateView : public CWindowImpl<CLexinUpdateView,
CListViewCtrl, LexinUpdateTraits>, public
CCustomDraw<CLexinUpdateView>
{
public:
DECLARE_WND_SUPERCLASS(NULL, ListViewCtrl::GetWndClassName())
typedef CWindowImpl<CLexinUpdateView, CListViewCtrl>
winbaseClass;

BEGIN_MSG_MAP(CLexinUpdateView)
MESSAGE_HANDLER(WM_CREATE, OnCreate)
NOTIFY_CODE_HANDLER(HDN_ITEMCLICKA, OnHeaderClicked)
NOTIFY_CODE_HANDLER(HDN_ITEMCLICKW, OnHeaderClicked)
//CHAIN_MSG_MAP(winbaseClass)
END_MSG_MAP()

BOOL PreTranslateMessage(MSG* pMsg)
{
pMsg;
return FALSE;
}


The definition of the mainframe is as follows:
class CMainFrame : public CFrameWindowImpl<CMainFrame>,public
CUpdateUI<CMainFrame>, public CMessageFilter, public CIdleHandler
{
public:
DECLARE_FRAME_WND_CLASS(NULL, IDR_MAINFRAME)

typedef CFrameWindowImpl<CMainFrame> winbaseClass;


virtual BOOL PreTranslateMessage(MSG* pMsg)
{
if(CFrameWindowImpl<CMainFrame>::PreTranslateMessage
(pMsg))
return TRUE;

return m_view.PreTranslateMessage(pMsg);

}

public:
BEGIN_MSG_MAP(CMainFrame)
MESSAGE_HANDLER(WM_CREATE, OnCreate)
MESSAGE_HANDLER(WM_CLOSE, OnClose)
MESSAGE_HANDLER(WM_NOTIFYFORMAT, OnNotifyFormat)

NOTIFY_HANDLER
(IDC_LISTVIEW,LVN_SETDISPINFO,OnSetdispinfoLexinview)
NOTIFY_HANDLER
(IDC_LISTVIEW,LVN_GETDISPINFO,OnGetdispinfoLexinview)
NOTIFY_HANDLER
(IDC_LISTVIEW,LVN_ODSTATECHANGED,OnODStateChangedLexinview)

CHAIN_MSG_MAP(CUpdateUI<CMainFrame>)
CHAIN_MSG_MAP(winbaseClass)
END_MSG_MAP()


// Message handlers
LRESULT OnCreate( UINT, WPARAM, LPARAM, BOOL& );
LRESULT OnClose( UINT, WPARAM, LPARAM, BOOL& );
LRESULT OnNotifyFormat( UINT, WPARAM, LPARAM, BOOL& );

LRESULT OnSetdispinfoLexinview(int idCtrl, LPNMHDR pnmh,
BOOL& bHandled);
LRESULT OnGetdispinfoLexinview(int idCtrl, LPNMHDR pnmh,
BOOL& bHandled);
LRESULT OnODStateChangedLexinview(int idCtrl, LPNMHDR pnmh,
BOOL& bHandled);



The list view is initialised as follows in the mainframe OnCreate():
m_hWndClient = m_view.Create(m_hWnd, rcDefault, NULL, 0, 0,
IDC_LISTVIEW);
ATLASSERT(::IsWindow(m_hWndClient));

// Style must be set for edit labels and ownerdraw
m_view.SetExtendedListViewStyle(
LVS_EX_FULLROWSELECT|LVS_EX_HEADERDRAGDROP|LVS_EX_INFOTIP );

m_view.InitImageList( IDB_LIST_STATES );
//m_view.SetCallbackMask( LVIS_FOCUSED|LVIS_SELECTED );
m_view.SetCallbackMask( LVIS_FOCUSED );
uo2000
2002-01-18 11:52:39 UTC
Permalink
I have an application that handles LVN_GETDISPINFO from a view
ClistCtrl.
When I add LVN_SETDISPINFO, LVN_ODSTATECHANGED they never get
recogniced by the mainframe. Is there anyone that knows why this is?
No message comes up in Spy++ either.


Thanks in advance
Ulf

The definition of the ClistViewCtrl as follows:
typedef CWinTraits<WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS |
WS_CLIPCHILDREN |
WS_VSCROLL | LVS_REPORT |
LVS_SHOWSELALWAYS | LVS_SINGLESEL | LVS_SHAREIMAGELISTS |
LVS_OWNERDATA,
WS_EX_CLIENTEDGE>
LexinUpdateTraits;

class CLexinUpdateView : public CWindowImpl<CLexinUpdateView,
CListViewCtrl, LexinUpdateTraits>,
public
CCustomDraw<CLexinUpdateView>
{
public:
DECLARE_WND_SUPERCLASS(NULL, CListViewCtrl::GetWndClassName())
typedef CWindowImpl<CLexinUpdateView, CListViewCtrl>
winbaseClass;

BEGIN_MSG_MAP(CLexinUpdateView)
MESSAGE_HANDLER(WM_CREATE, OnCreate)
NOTIFY_CODE_HANDLER(HDN_ITEMCLICKA, OnHeaderClicked)
NOTIFY_CODE_HANDLER(HDN_ITEMCLICKW, OnHeaderClicked)
//CHAIN_MSG_MAP(winbaseClass)
END_MSG_MAP()


The definition of the mainframe is as follows:
class CMainFrame : public CFrameWindowImpl<CMainFrame>,
public CUpdateUI<CMainFrame>,
public CMessageFilter,
public CIdleHandler
{
public:
DECLARE_FRAME_WND_CLASS(NULL, IDR_MAINFRAME)

typedef CFrameWindowImpl<CMainFrame> winbaseClass;


virtual BOOL PreTranslateMessage(MSG* pMsg)
{
if(CFrameWindowImpl<CMainFrame>::PreTranslateMessage
(pMsg))
return TRUE;

return m_view.PreTranslateMessage(pMsg);

}

virtual BOOL OnIdle()
{
UIUpdateToolBar();
return FALSE;
}

public:
BEGIN_MSG_MAP(CMainFrame)
MESSAGE_HANDLER(WM_CREATE, OnCreate)
MESSAGE_HANDLER(WM_CLOSE, OnClose)
MESSAGE_HANDLER(WM_NOTIFYFORMAT, OnNotifyFormat)

NOTIFY_HANDLER
(IDC_LISTVIEW,LVN_SETDISPINFO,OnSetdispinfoLexinview)
NOTIFY_HANDLER
(IDC_LISTVIEW,LVN_GETDISPINFO,OnGetdispinfoLexinview)
NOTIFY_HANDLER
(IDC_LISTVIEW,LVN_ODSTATECHANGED,OnODStateChangedLexinview)

CHAIN_MSG_MAP(CUpdateUI<CMainFrame>)
CHAIN_MSG_MAP(winbaseClass)
END_MSG_MAP()

BEGIN_UPDATE_UI_MAP(CMainFrame)
UPDATE_ELEMENT(ID_VIEW_TOOLBAR,
UPDUI_MENUPOPUP)
UPDATE_ELEMENT(ID_VIEW_STATUS_BAR,
UPDUI_MENUPOPUP)
END_UPDATE_UI_MAP()


// Message handlers
LRESULT OnCreate( UINT, WPARAM, LPARAM, BOOL& );
LRESULT OnClose( UINT, WPARAM, LPARAM, BOOL& );
LRESULT OnNotifyFormat( UINT, WPARAM, LPARAM, BOOL& );

LRESULT OnSetdispinfoLexinview(int idCtrl, LPNMHDR pnmh,
BOOL& bHandled);
LRESULT OnGetdispinfoLexinview(int idCtrl, LPNMHDR pnmh,
BOOL& bHandled);
LRESULT OnODStateChangedLexinview(int idCtrl, LPNMHDR pnmh,
BOOL& bHandled);

The list view is initialised as follows in the mainframe:
m_hWndClient = m_view.Create(m_hWnd, rcDefault, NULL, 0, 0,
IDC_LISTVIEW);
ATLASSERT(::IsWindow(m_hWndClient));

// Style must be set for edit labels and ownerdraw
m_view.SetExtendedListViewStyle(
LVS_EX_FULLROWSELECT|LVS_EX_HEADERDRAGDROP|LVS_EX_INFOTIP );

m_view.InitImageList( IDB_LIST_STATES );
//m_view.SetCallbackMask( LVIS_FOCUSED|LVIS_SELECTED );
m_view.SetCallbackMask( LVIS_FOCUSED );
uo2000
2002-01-19 19:40:41 UTC
Permalink
I have an application that handles LVN_GETDISPINFO from a view
ClistCtrl.
When I add LVN_SETDISPINFO, LVN_ODSTATECHANGED they never get
recogniced by the mainframe. Is there anyone that knows why this is?
No message comes up in Spy++ either.


Thanks in advance
Ulf

The definition of the ClistViewCtrl as follows:
typedef CWinTraits<WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS |
WS_CLIPCHILDREN |
WS_VSCROLL | LVS_REPORT |
LVS_SHOWSELALWAYS | LVS_SINGLESEL | LVS_SHAREIMAGELISTS |
LVS_OWNERDATA,
WS_EX_CLIENTEDGE>
LexinUpdateTraits;

class CLexinUpdateView : public CWindowImpl<CLexinUpdateView,
CListViewCtrl, LexinUpdateTraits>,
public
CCustomDraw<CLexinUpdateView>
{
public:
DECLARE_WND_SUPERCLASS(NULL, CListViewCtrl::GetWndClassName())
typedef CWindowImpl<CLexinUpdateView, CListViewCtrl>
winbaseClass;

BEGIN_MSG_MAP(CLexinUpdateView)
MESSAGE_HANDLER(WM_CREATE, OnCreate)
NOTIFY_CODE_HANDLER(HDN_ITEMCLICKA, OnHeaderClicked)
NOTIFY_CODE_HANDLER(HDN_ITEMCLICKW, OnHeaderClicked)
//CHAIN_MSG_MAP(winbaseClass)
END_MSG_MAP()


The definition of the mainframe is as follows:
class CMainFrame : public CFrameWindowImpl<CMainFrame>,
public CUpdateUI<CMainFrame>,
public CMessageFilter,
public CIdleHandler
{
public:
DECLARE_FRAME_WND_CLASS(NULL, IDR_MAINFRAME)

typedef CFrameWindowImpl<CMainFrame> winbaseClass;


virtual BOOL PreTranslateMessage(MSG* pMsg)
{
if(CFrameWindowImpl<CMainFrame>::PreTranslateMessage
(pMsg))
return TRUE;

return m_view.PreTranslateMessage(pMsg);

}

virtual BOOL OnIdle()
{
UIUpdateToolBar();
return FALSE;
}

public:
BEGIN_MSG_MAP(CMainFrame)
MESSAGE_HANDLER(WM_CREATE, OnCreate)
MESSAGE_HANDLER(WM_CLOSE, OnClose)
MESSAGE_HANDLER(WM_NOTIFYFORMAT, OnNotifyFormat)

NOTIFY_HANDLER
(IDC_LISTVIEW,LVN_SETDISPINFO,OnSetdispinfoLexinview)
NOTIFY_HANDLER
(IDC_LISTVIEW,LVN_GETDISPINFO,OnGetdispinfoLexinview)
NOTIFY_HANDLER
(IDC_LISTVIEW,LVN_ODSTATECHANGED,OnODStateChangedLexinview)

CHAIN_MSG_MAP(CUpdateUI<CMainFrame>)
CHAIN_MSG_MAP(winbaseClass)
END_MSG_MAP()

BEGIN_UPDATE_UI_MAP(CMainFrame)
UPDATE_ELEMENT(ID_VIEW_TOOLBAR,
UPDUI_MENUPOPUP)
UPDATE_ELEMENT(ID_VIEW_STATUS_BAR,
UPDUI_MENUPOPUP)
END_UPDATE_UI_MAP()


// Message handlers
LRESULT OnCreate( UINT, WPARAM, LPARAM, BOOL& );
LRESULT OnClose( UINT, WPARAM, LPARAM, BOOL& );
LRESULT OnNotifyFormat( UINT, WPARAM, LPARAM, BOOL& );

LRESULT OnSetdispinfoLexinview(int idCtrl, LPNMHDR pnmh,
BOOL& bHandled);
LRESULT OnGetdispinfoLexinview(int idCtrl, LPNMHDR pnmh,
BOOL& bHandled);
LRESULT OnODStateChangedLexinview(int idCtrl, LPNMHDR pnmh,
BOOL& bHandled);

The list view is initialised as follows in the mainframe:
m_hWndClient = m_view.Create(m_hWnd, rcDefault, NULL, 0, 0,
IDC_LISTVIEW);
ATLASSERT(::IsWindow(m_hWndClient));

// Style must be set for edit labels and ownerdraw
m_view.SetExtendedListViewStyle(
LVS_EX_FULLROWSELECT|LVS_EX_HEADERDRAGDROP|LVS_EX_INFOTIP );

m_view.InitImageList( IDB_LIST_STATES );
//m_view.SetCallbackMask( LVIS_FOCUSED|LVIS_SELECTED );
uo2000
2002-01-20 13:16:09 UTC
Permalink
I have an application that handles LVN_GETDISPINFO from a view
ClistCtrl.
When I add LVN_SETDISPINFO, LVN_ODSTATECHANGED they never get
recogniced by the mainframe. Is there anyone that knows why this is?
No message comes up in Spy++ either.


Thanks in advance
Ulf

The definition of the ClistViewCtrl as follows:
typedef CWinTraits<WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS |
WS_CLIPCHILDREN |
WS_VSCROLL | LVS_REPORT |
LVS_SHOWSELALWAYS | LVS_SINGLESEL | LVS_SHAREIMAGELISTS |
LVS_OWNERDATA,
WS_EX_CLIENTEDGE>
LexinUpdateTraits;

class CLexinUpdateView : public CWindowImpl<CLexinUpdateView,
CListViewCtrl, LexinUpdateTraits>,
public
CCustomDraw<CLexinUpdateView>
{
public:
DECLARE_WND_SUPERCLASS(NULL, CListViewCtrl::GetWndClassName())
typedef CWindowImpl<CLexinUpdateView, CListViewCtrl>
winbaseClass;

BEGIN_MSG_MAP(CLexinUpdateView)
MESSAGE_HANDLER(WM_CREATE, OnCreate)
NOTIFY_CODE_HANDLER(HDN_ITEMCLICKA, OnHeaderClicked)
NOTIFY_CODE_HANDLER(HDN_ITEMCLICKW, OnHeaderClicked)
//CHAIN_MSG_MAP(winbaseClass)
END_MSG_MAP()


The definition of the mainframe is as follows:
class CMainFrame : public CFrameWindowImpl<CMainFrame>,
public CUpdateUI<CMainFrame>,
public CMessageFilter,
public CIdleHandler
{
public:
DECLARE_FRAME_WND_CLASS(NULL, IDR_MAINFRAME)

typedef CFrameWindowImpl<CMainFrame> winbaseClass;


virtual BOOL PreTranslateMessage(MSG* pMsg)
{
if(CFrameWindowImpl<CMainFrame>::PreTranslateMessage
(pMsg))
return TRUE;

return m_view.PreTranslateMessage(pMsg);

}

virtual BOOL OnIdle()
{
UIUpdateToolBar();
return FALSE;
}

public:
BEGIN_MSG_MAP(CMainFrame)
MESSAGE_HANDLER(WM_CREATE, OnCreate)
MESSAGE_HANDLER(WM_CLOSE, OnClose)
MESSAGE_HANDLER(WM_NOTIFYFORMAT, OnNotifyFormat)

NOTIFY_HANDLER
(IDC_LISTVIEW,LVN_SETDISPINFO,OnSetdispinfoLexinview)
NOTIFY_HANDLER
(IDC_LISTVIEW,LVN_GETDISPINFO,OnGetdispinfoLexinview)
NOTIFY_HANDLER
(IDC_LISTVIEW,LVN_ODSTATECHANGED,OnODStateChangedLexinview)

CHAIN_MSG_MAP(CUpdateUI<CMainFrame>)
CHAIN_MSG_MAP(winbaseClass)
END_MSG_MAP()

BEGIN_UPDATE_UI_MAP(CMainFrame)
UPDATE_ELEMENT(ID_VIEW_TOOLBAR,
UPDUI_MENUPOPUP)
UPDATE_ELEMENT(ID_VIEW_STATUS_BAR,
UPDUI_MENUPOPUP)
END_UPDATE_UI_MAP()


// Message handlers
LRESULT OnCreate( UINT, WPARAM, LPARAM, BOOL& );
LRESULT OnClose( UINT, WPARAM, LPARAM, BOOL& );
LRESULT OnNotifyFormat( UINT, WPARAM, LPARAM, BOOL& );

LRESULT OnSetdispinfoLexinview(int idCtrl, LPNMHDR pnmh,
BOOL& bHandled);
LRESULT OnGetdispinfoLexinview(int idCtrl, LPNMHDR pnmh,
BOOL& bHandled);
LRESULT OnODStateChangedLexinview(int idCtrl, LPNMHDR pnmh,
BOOL& bHandled);

The list view is initialised as follows in the mainframe:
m_hWndClient = m_view.Create(m_hWnd, rcDefault, NULL, 0, 0,
IDC_LISTVIEW);
ATLASSERT(::IsWindow(m_hWndClient));

// Style must be set for edit labels and ownerdraw
m_view.SetExtendedListViewStyle(
LVS_EX_FULLROWSELECT|LVS_EX_HEADERDRAGDROP|LVS_EX_INFOTIP );

m_view.InitImageList( IDB_LIST_STATES );
//m_view.SetCallbackMask( LVIS_FOCUSED|LVIS_SELECTED );
m_view.SetCallbackMask( LVIS_FOCUSED );

Loading...