-
TreeView Style
I've derived a class based on a TreeView. When I actually put the TreeView in a window, it comes up as a generic "style-less" tree control. How do I modify the style of the TreeView? I've tried overriding the "OnCreate" and doing this:
BOOL CArcInfoTree::Create(LPCTSTR lpszClassName,
LPCTSTR lpszWindowName, DWORD dwStyle, const
RECT& rect, CWnd* pParentWnd, UINT nID,
CCreateContext* pContext)
{
dwStyle |= TVS_HASBUTTONS;
return CWnd::Create(lpszClassName,
lpszWindowName, dwStyle, rect, pParentWnd, nID,
pContext);
}
But it doesn't do anything.
-
Re: TreeView Style
I suggest you use ModifyStyle or ModifyStyleEx to change the styles. For example:
ModifyStyle(0, TVS_HASBUTTONS);
The fisrt parameter is the OFF BITS and the second is the ON BITS.
Place that code in the TreeView OnInitialUpdate()
Good luck
Jaime
-
Re: TreeView Style
I tried this, but it doesn't work. I tried both ModifyStyle and ModifyStyleEx.
Does it matter that it is a TreeView in a SplitterWnd?
-
Re: TreeView Style
You must change this style before the TreeView is created. You can do this in the function PreCreateWindow (Overwrite with ClassWizard).
BOOL CMyTreeView::PreCreateWindow(CREATESTRUCT& cs)
{
cs.style |= TVS_HASBUTTONS;
return CTreeView::PreCreateWindow(cs) ;
}
-
Re: TreeView Style
Actually The way to get it to work is the type of styles you implement. THIS is what works.
BOOL CArcInfoTree::Create(LPCTSTR lpszClassName,
LPCTSTR lpszWindowName, DWORD dwStyle, const
RECT& rect, CWnd* pParentWnd, UINT nID,
CCreateContext* pContext)
{
dwStyle |= (TVS_HASLINES | TVS_LINESATROOT | TVS_HASBUTTONS);
return CWnd::Create(lpszClassName,
lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext);
}
Thanks for all the help.