Today, I saw the original code of MFC and wrote a little experience.
Take the instructions for hwnd and cwnd * as an example:
There is a Static function CWnd * from FromHandle (HWND) in the CWND class
Its implementation is passed by pstate = afxgetmoduLethreadState ();
And store some chandlemap * (is a dictionary pointer) in PState
So each time you query hWnd in the dictionary to get the CWND * pointer.
Of course, each time the CWND object is generated, attach () ----- it is in the dictionary, if CWnd * is HWND
The upper side is the Handle dictionary implemented by the MFC, but the other handle is similar, but the system object handle has a handle table in the system itself. It is not an MFC implementation, but the system is generated, through this table to access the corresponding object, For example: file handle, mutual exclusion handle, process, and thread sessions, etc.