Link to home
Start Free TrialLog in
Avatar of jordan_p
jordan_p

asked on

How to add a custom title bar to CTreeView

I have a program that I want to look similar to windows explorer with a tree view and then a box in that same view that says "Folders".  It's not the application title but looks more like a button or a custom title bar.

Does anyone have a suggestion?  I would like to use CTreeView and override the Paint method.  Right now I can override the Paint method and draw the box but I cannot get the tree control to draw.

Thanks,

Jordan
ASKER CERTIFIED SOLUTION
Avatar of chensu
chensu
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jordan_p
jordan_p

ASKER

Can I do it without using Windows Explorer rebars?  I don't want to have to rely on Microsoft Internet Explorer 3.0 or above being installed on the machine.
You can create a parent window which hosts the tree view control and a static control. A static control with some extended styles looks like what you want.
I actually already did that already and it worked fine.  But it didn't behave like a CTreeView.  I was unable to catch the messages from the CTreeCtrl in my new view class.  I guess I can catch the messages in a new class that derived from CTreeCtrl but than I'm unable to have the code I need at the View level.

Any suggestions?
Yeah, that's because the parent window of CTreeCtrl is the window that hosts it instead of the view. You may either try to create the static control from the view or let the parent window of CTreeCtrl forward all the messages to the view.
Can I override the OnPaint() method in a derived CTreeView class and draw both the TreeCtrl and the title box?
Can I also use this same method of overriding the OnPaint() method to create a title box on a CEditView or a CFormView?
That's not practical because you occupy some part of the control and you have to draw it yourself.
I ended up using a CView with a derived CEditCtrl.  I overrode the Paint method to draw a title box on the top and the CEditCtrl on the bottom.