Solved

about the an example code on codeguru

Posted on 1998-01-04
2
431 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Suggested Courses

617 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