Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

SubclassDlgItem on Property Page: failing on ASSERT

Posted on 2001-08-02
2
Medium Priority
?
1,029 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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 this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

597 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