Solved

SubclassDlgItem on Property Page: failing on ASSERT

Posted on 2001-08-02
2
991 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 300 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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

688 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