MFC CPropertySheet crashes when WM_CREATE returns -1 and PostNcDestroy() will delete this-pointer - by Marc_75

Status : 

  Fixed<br /><br />
		This item has been fixed in the current or upcoming version of this product.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 696791 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 10/26/2011 6:26:03 AM
Access Restriction Public


The MFC implementation of CPropertySheet relies on the 'this'-pointer to be available, even when the property sheet constructions fails!

When a property sheet cannot be constructed it is common practice to return -1 when handling the message WM_CREATE/OnCreate(). And it is also common practice to perform a 'delete this'-construction in PostNcDestroy to clean up the CWnd-derivative window object for a modeless window.

When this construction is used for a modeless CPropertySheet, the MFC will crash in the function:
BOOL CPropertySheet::Create(CWnd* pParentWnd, DWORD dwStyle, DWORD dwExStyle)
at the position:

OK, meanwhile I'm using PostMessage(WM_CLOSE) in order to avoid opening the sheet. However, the property sheet still becomes visible for a second, as can be seen when a breakpoint is set in the function CPropertySheet::Create(CWnd* pParentWnd, DWORD dwStyle, DWORD dwExStyle
at the position:
// cleanup on failure, otherwise return TRUE
if (!AfxUnhookWindowCreate())
  PostNcDestroy();    // cleanup if Create fails
Sign in to post a comment.
Posted by Microsoft on 10/31/2011 at 11:33 AM

Thanks for the report. This issue has been fixed in MFC for the next major release of Visual Studio.

Pat Brenner
Visual C++ Libraries Development
Posted by Marc_75 on 10/28/2011 at 1:44 AM

why is it that I don't get any email notification when somone of 'MS-Moderator' posts a comment?
I do receive email notications when someone like Pat Brenner posts a comment.

thank you,
Posted by MS-Moderator08 [Feedback Moderator] on 10/26/2011 at 6:54 PM
Thank you for submitting feedback on Visual Studio 2010 and .NET Framework. Your issue has been routed to the appropriate VS development team for investigation. We will contact you if we require any additional information.
Posted by MS-Moderator01 on 10/26/2011 at 6:48 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(