SubclassDlgItem on Property Page: failing on ASSERT

Posted on 2001-08-02
Medium Priority
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()
    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?
Question by:hansenk
  • 2
LVL 49

Accepted Solution

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.

   CMyPropertyPage();   // standard constructor

   // added here, subclassed in OnInitDialog
   CMyEditHandler m_myedithandler;

-- Dan
LVL 49

Expert Comment

ID: 6352350
yore welcum
-- Dan

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
In the video, one can understand the process of resizing images in single or bulk. Kernel Bulk Image Resizer is an easy to use tool for resizing large number of images. One can add and resize multiple images with this tool in single go. The video sh…

622 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