Owner Data ListView Ctrl failing to insert column in Vista
"arasakumaran" <arasakumaran-/[email protected]>
| Newsgroups | gmane.comp.windows.wtl |
|---|---|
| Message-ID | <[email protected]> |
I am having a problem with a listview control. It works fine in XP (the development machine), but fails in a Vista machine (where I do not have the development environment).
It is a report style listview control and is Owner data. It is an SDI application where the Main window creates the listview. The step to insert column fails in the vista computer. I have included the code where the styles etc. is defined (omitted rest of the class). Any help is appreciated.
..
typedef CWinTraits<
WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN |LVS_OWNERDATA|
LVS_REPORT | LVS_SHAREIMAGELISTS | LVS_NOCOLUMNHEADER,WS_EX_CLIENTEDGE|
LVS_EX_DOUBLEBUFFER|LVS_EX_FLATSB|LVS_EX_FULLROWSELECT> CMyListViewWinTraits;
template< class T, class TBase = CListViewCtrl, class TWinTraits = CMyListViewWinTraits >
class CMyListCtrlT : public CWindowImpl<T, TBase,TWinTraits>
{
public:
DECLARE_WND_SUPERCLASS(NULL, TBase::GetWndClassName())
typedef CWindowImpl<T, TBase,TWinTraits> baseClass;
typedef CMyListCtrlT<T, TBase,TWinTraits> thisClass;
CMyListCtrlT(): m_bMiniVersion(false)
{
}
void _Init(bool bMini = false)
{
T* pT = static_cast<T*>(this);
m_bMiniVersion = bMini;
_ASSERTE(pT->GetWindowLong(GWL_STYLE) & LVS_REPORT);
_ASSERTE(pT->GetWindowLong(GWL_STYLE) & LVS_OWNERDATA);
_ASSERTE(pT->GetWindowLong(GWL_STYLE) & LVS_NOCOLUMNHEADER);
pT->SetExtendedListViewStyle(GetExtendedListViewStyle()| LVS_EX_FLATSB | LVS_EX_FULLROWSELECT );
pT->ModifyStyle(0,LVS_NOCOLUMNHEADER,TRUE);
SetColumns();
ATLTRACE(_T("After CNotesListCtrlT::_Init \n"));
}
BOOL SubclassWindow(HWND hWnd)
{
ATLASSERT(m_hWnd==NULL);
ATLASSERT(::IsWindow(hWnd));
#ifdef _DEBUG
// Check class
TCHAR szBuffer[32] = { 0 };
if( ::GetClassName(hWnd, szBuffer, (sizeof(szBuffer)/sizeof(TCHAR))-1) ) {
ATLASSERT(::lstrcmpi(szBuffer, CListViewCtrl::GetWndClassName()) == 0);
}
#endif // _DEBUG
BOOL bRet = baseClass::SubclassWindow(hWnd);
if( bRet ) _Init();
return bRet;
}
bool SetColumns() /// InsertColumn fails in Vista
{
T* pT = static_cast<T*>(this);
if (pT->InsertColumn(0,_T("ID"),LVCFMT_LEFT,20) == -1) return false;
if (pT->InsertColumn(1,_T("Title"),LVCFMT_LEFT,220) == -1) return false;
return true;
}
};
class CMyListView : public CMyListCtrlT<CMyListView>
{
public:
DECLARE_WND_SUPERCLASS(_T("MyListView"), CListViewCtrl::GetWndClassName())
typedef CMyListCtrlT<CMyListView> baseClass;
BOOL PreTranslateMessage(MSG* pMsg);
BEGIN_MSG_MAP(CMyListView)
CHAIN_MSG_MAP(baseClass)
END_MSG_MAP()
protected:
CFilterPanelDlg m_panel;
public:
};
------------------------------------
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/wtl/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/wtl/join
(Yahoo! ID required)
<*> To change settings via email:
[email protected]
[email protected]
<*> To unsubscribe from this group, send an email to:
[email protected]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/