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.