Solved

about the an example code on codeguru

Posted on 1998-01-04
2
420 Views
Last Modified: 2013-11-20
On www.codeguru.com,there is a topic concerned on changing the background color of treeview.In the example code,it does something on the OnPaint of CTreeCtrl.(http://www.codeguru.com/treeview/ctrl_color.shtml)But I really don't know how can I handle the CTreeCtrl's OnPaint()in CTreeView,what I can handle is only the OnPaint() os CTreeView,but that does nothing usefull.any one who have already read the topic in codeguru can give me some advice?How can I handle the OnPaint() of CTreeCtrl in a CTreeView?

thanks
0
Comment
Question by:yuqiang
2 Comments
 
LVL 1

Accepted Solution

by:
richhxb earned 10 total points
ID: 1313423
Use CTreeView::GetTreeCtrl to get a reference of the tree
control associated with the view, then create your own
CTreeCtrl class, and in your own CMyTreeCtrl, use
SubclassWindow(m_MyTreeView.GetTreeCtrl()->m_hWnd) to
subclass it.

Now you can handle the OnPaint() of CTreeCtrl in your
CTreeView.



0
 

Author Comment

by:yuqiang
ID: 1313424
hi,richhxb,

thank you for your kindly answer.But when I tried under your diction,I got an ASSERT failure in wincore.cpp line 315.It seem that the treectrl has already been attach to the treeview(treeview.m_hWnd == treectrl.m_hWnd),so the treectrl can not be attach to the CMyTreeCtrl.

Since the CTreeView and the CTreeCtrl has the same m_hWnd,does all the message sent to the CTreeCtrl is sent to the CTreeView? If it is true,the CTreeView's OnPaint() is equal to CTreeCtrl's OnPaint(),But why I can not get the desired result by handle the CTreeView's OnPaint()? Would you so kind have a look at http://www.codeguru.com/treeview/ctrl_color.shtml and give me some advice?I can not contact with the author of that URL.

If you like ,you can  give me email directly.(yuq@wayx.com)

thank you again.

0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Strange date stored 22 156
matchUp  challenge 6 70
mapBully challenge 6 156
Sed question 2 104
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question