[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

CListView with my CListCtrl object

Posted on 2001-09-13
5
Medium Priority
?
477 Views
Last Modified: 2013-11-20
I have a class derived from CListView and I want the embedded CListCtrl object to be of my own class derived from CListCtrl. How can I accomplish this?
0
Comment
Question by:MFCRich
[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
5 Comments
 
LVL 7

Accepted Solution

by:
peterchen092700 earned 150 total points
ID: 6481788
You can't directly replace the List Control.

The safe way would be to create your own View class, and create the custom list control as child window of it.
(For some issues with this, see http://buerger.metropolis.de/bitbucket/howto/wndview.html, and sorry for the popup)


Reasons:
MFC does very dirty tricks here. It relies solely on the fact that bol CListCtrl and CListView inherit from CWnd, and that CListCtrl does not have more data members than CWnd, and the List Control does not override any method of CWnd except perhaps message handlers.

CListView::GetListCtrl() actually returns a reference to the CListView itself, cast to CListCtrl.
(be aware that there's no safe cast beetween them, and MFC heavily relies on implementational details of the classes here, and the code would break with "weird but ANSI-compliant" compilers).

Another option would be to dereive your own CMyListView class from CCtrlView, but you would have to find a way to register a Window Class (Win32) and tell MFC to associate it with your CMyListCtrl class - which I don't know how to do...

Peter
0
 
LVL 2

Expert Comment

by:shilpa_Jb
ID: 6482300
Hi,
U can have ur own view class derived from the CView and oncreate of this class create the ur own CListControl which is derive from CListCtrl.
that should help u.
For more help see for listcontrol examples under shell programming or under listcontrol section in www.codeguru.com.
-shilpa  
0
 
LVL 7

Expert Comment

by:peterchen092700
ID: 6482422
shilpa_Jb: Isn't this exactly what I described in greater detail?

Peter puzzled
0
 
LVL 1

Expert Comment

by:MRNMurthy
ID: 6482857
Hi,

I want some time.

From

MRN Murthy
0
 
LVL 4

Author Comment

by:MFCRich
ID: 6483551
I'm trying peterchen's suggestion so time may be short :-)
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
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.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

649 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