Solved

Where subclass my list control ?

Posted on 1997-07-04
3
171 Views
Last Modified: 2013-11-20
I try subclass my list control from a list control created with resource editor , and in the OnInitDialog method I put the following:

...
MyListCtrl.SubclassWindow ( ListCtrl.m_hWnd );
...

In this line I receive a trap in the wincore.cpp ( Attach method ) .
What's wrong ?
0
Comment
Question by:nigro
[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
3 Comments
 
LVL 23

Accepted Solution

by:
chensu earned 50 total points
ID: 1302456
Since you are subclassing a dialog item, you should use CWnd::SubclassDlgItem.
0
 

Author Comment

by:nigro
ID: 1302457
Apparently the problem  was resolved commenting the line in DoDataExchange method that was relationing the list control ID with the list control data member (which was created with the Class Wizard).
0
 
LVL 1

Expert Comment

by:cnasarre
ID: 1302458
As far as I can see, you are subclassing twice your listbox...

If you have associated a CListBox(or derivated) member
MyListCtrl to the listbox control with the Member tab in
the Class Wizard, you have to do nothing by yourself :
just call CDialog::OnInitDialog() BEFORE using MyListCtrl
in your overloaded OnInitDialog()

That's the way is it supposed to work : thanks to MFC to do
the work
CDialog::OnInitDialog()
--> UpdateData()
   --> DoDataExchange()
      --> DDX_Control()
         --> SubclassWindow()  // that's it


I hope this help to understand

   cnasarre
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

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 …
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
Suggested Courses

734 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