?
Solved

SubclassDlgItem on Property Page: failing on ASSERT

Posted on 2001-08-02
2
Medium Priority
?
1,006 Views
Last Modified: 2013-11-20
I'm trying to dynamically subclass a field on a property page.  The code looks like this:

  BOOL CMyPropertyPage::OnInitDialog()
  {
    CPropertyPage::OnInitDialog();
    m_myedithandler.SubclassDlgItem(IDC_MYEDIT,this);
    return TRUE;  
  }

The SubclassDlgItem() fails on an ASSERT in

  BOOL CWnd::Attach(HWND hWndNew)
  {
    ASSERT(m_hWnd == NULL);                       //OK
    ASSERT(FromHandlePermanent(hWndNew) == NULL); //fails
    ...

FromHandlePermanent returns a non-NULL pWnd, presumbably because the control in question is already in the permanent map.

I've used the same override logic on an edit field in a regular dialog (derived from CDialog rather than CPropertyPage) without any problem.  Is there something special about subclassing on a property page?  Or can someone point me to something else I am doing wrong?
0
Comment
Question by:hansenk
[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
2 Comments
 
LVL 49

Accepted Solution

by:
DanRollins earned 1200 total points
ID: 6347355
The ClassWizard has created a variable (presumeably named m_myedithandler and presumably of a class derived from CEdit).  

CPropertyPage::OnInitDialog() during its DDX phase has already subclassed that control.

What you need to do is use the ClassWizard to remove that variable (that will remove the DDX_Control() call), then add it back manually in the CMyPropertyPage .h file.

public:
   CMyPropertyPage();   // standard constructor
   ~CMyPropertyPage();

   // added here, subclassed in OnInitDialog
   CMyEditHandler m_myedithandler;

-- Dan
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 6352350
yore welcum
-- Dan
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses

771 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