[Learning] Win32 API differences and connections between the HWND and CWnd

 

HWND is a Windows system to one identifies all the windows, that window handle. This is a SDK concept. CWnd is MFC library window base class for all classes. Microsoft MFC general procedure will all windows are encapsulated into this class, such as: the ShowWindow like, but it also encapsulates the window handle i.e. m_hWnd members. 1. by the HWnd get CWnd * :   CWnd wnd;   HWnd hWnd;   wnd.Attach (hWnd); usually has a window and a resource CWnd object class associates, since in general this class is to create their own, so naturally know how to get a pointer to the class. If you have not created a CWnd object, the object window resources hWnd associate handle. (Such as the top of the statement). If you use   static CWnd CWnd :: * FromHandle (HWND hWnd) ; the return value is a temporary CWnd object, and we make sure that the return value is non-empty, that is








hWnd is valid.   * the CWnd FromHandlePermanent the CWnd :: static (the HWND the hWnd) ; returns a permanent object. Only returned CWnd already exists in the category list is a non-null value is returned. 2. the CWnd get HWnd much easier, because it's a member of the m_hWnd is the window handle correspondence.   wnd-> m_hWnd .




 

Reproduced in: https: //www.cnblogs.com/Vicky-Lee/archive/2011/09/15/2177807.html

Guess you like

Origin blog.csdn.net/weixin_34128411/article/details/93251531