Relationship between CWnd object and window

Source: Internet
Author: User

Many people think that the CWnd object in MFC is a window. Otherwise, it only has a twist band associated with the window, that is, a window handle.

You can simulate the CWnd object:

Class CWnd
{
Public:
BOOL CreateWindow (.....);
BOOL ShowWindow (int cmdShow );
BOOL UpdateWindow ();
Void DestroyWindow ();
Private:
HWND m_hwnd;
}

BOOL CWnd: CreateWindow (.....)
{
// Note: The Window handle is saved.
M_hwnd =: createmediawex (.....);
}

BOOL CWnd: ShowWindow (int cmdShow)
{
// Directly call global functions
Return: ShowWindow (m_hwnd, cmdShow );
}

BOOL CWnd: UpdateWindow ()
{
// Directly call global functions
Return: UpdateWindow (m_hwnd );
}

Void CWnd: DestroyWindow ()
{
// Empty window handle
M_hwnd = NULL;
}

 

Once the window is destroyed, it does not mean that the CWnd object is destroyed. In fact, only the window handle is set to NULL. On the contrary, if the CWnd object is destroyed, the window must be destroyed.

 

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.