[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 192
  • Last Modified:

Where subclass my list control ?

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
nigro
Asked:
nigro
1 Solution
 
chensuCommented:
Since you are subclassing a dialog item, you should use CWnd::SubclassDlgItem.
0
 
nigroAuthor Commented:
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
 
cnasarreCommented:
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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now