Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

about the an example code on codeguru

Posted on 1998-01-04
2
Medium Priority
?
441 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 30 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

Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.

Question has a verified solution.

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

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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 tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

661 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