Windows objects are typically represented by various HANDLE objects The MFC classes wrap Windows object handles with C++ objects. The handle wrapping functions of the MFC class library let you find the C++ object that is wrapping the Windows object that has a particular handle. However, sometimes an object does not have a C++ wrapper object and at these times the system creates a temporary object to act as the C++ wrapper.
The Windows objects that use handle maps are as follows:
Given a handle to any one of these objects, you can find the MFC object that wraps the handle by calling the static method FromHandle. For example, given an HWND called hWnd, the following line will return a pointer to the CWnd that wraps hWnd:
If hWnd does not have a specific wrapper object, a temporary CWnd is created to wrap hWnd. This makes it possible to obtain a valid C++ object from any handle.
After you have a wrapper object, you can retrieve its handle from a public member variable of the wrapper class. In the case of a CWnd, m_hWnd contains the HWND for that object.