CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: TreeView Style

  1. #1
    Join Date
    Jul 1999
    Posts
    16

    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.


  2. #2
    Join Date
    Aug 1999
    Location
    Chile
    Posts
    177

    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


  3. #3
    Join Date
    Jul 1999
    Posts
    16

    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?


  4. #4
    Join Date
    Sep 1999
    Location
    Europe / Austria / Innsbruck
    Posts
    442

    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) ;
    }





  5. #5
    Join Date
    Jul 1999
    Posts
    16

    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.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured