Solved

Where subclass my list control ?

Posted on 1997-07-04
3
148 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
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

746 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now