Click to See Complete Forum and Search --> : TreeView Style


kronski
September 9th, 1999, 03:40 PM
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.

Jaime
September 9th, 1999, 10:33 PM
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

kronski
September 10th, 1999, 09:41 AM
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?

Thomas Ascher
September 10th, 1999, 09:47 AM
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) ;
}

kronski
September 10th, 1999, 09:51 AM
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.