About CFont type member variable M_font is using M_font. ASSERT (M_hobject = = NULL) Assertion when CreatePointFont

Source: Internet
Author: User
Tags assert

Background:

When the landlord is doing the project,

1, a dialog Class A uses the CFont type of member variable M_font,

2, in the dialog box Class A OnInitDialog () member function to use the M_font. CreatePointFont (160, _t ("The Chinese Cloud")) and GetDlgItem (idc_xxx)->setfont (&m_font),

3. The destructor of dialog Class A is M_font. DeleteObject ().


The problems that arise:

Click on a button in the main interface to Generate dialog box Class A modal dialog box, the first time you click the button will not be a problem, the second click on the button will appear assert (M_hobject = = NULL) assertion.


Workaround:

Put M_font. CreatePointFont (160, _t ("The Chinese Cloud") moved to the constructor of dialog Class A, and the other code is unchanged. This allows a modal dialog to be generated successfully when the second click button is clicked.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.