CWnd中PreCreateWindow、PreSubclassWindow、SubclassWindow

  Original link: http://blog.chinaunix.net/uid-14607221-id-2794642.html

 

  1、

  PreCreateWindow:
  Called by the framework before the creation of the Windows window 
  attached to this CWnd object.
  PreSubclassWindow
  :
  This member function is called by the framework to allow other necessary 
  subclassing to occur before the window is
  subclassed
. And the subclass of the window for a simple explanation! To understand attach, we must know the difference between a C++ CWnd object and a window: window is a real window, and CWnd is a C++ encapsulation of window by MFC classes. attach is to attach the window to the CWnd object. The CWnd object is not associated with the window until the attach is completed. A subclass of a window refers to an operation that modifies a window procedure, not a derived subclass in object orientation .

  2、

  Also called PreSubclassWindow before calling the function SetWindowLong for window subclass.
  Usually the window is created by the user CWnd::Create(..) 
  In this process, MFC provides an opportunity "PreCreateWindow() for the user to do something before creating 
  and for dialog boxes, etc., the window is communicated through subclasses.
  Read the dialog template  to the user's 
system, create each sub-window,   and then replace the message-handling function of each sub-window with the corresponding C++ object's message-handling function (Subclass: subclassing, or "take over"), then, this The sub-window will act according to the way defined in the class. 
  In this process, the call is CWnd:SubclassWindow( HWND hWnd ); 
  ●In this process, MFC provides an opportunity "PreSubclassWindow" for the user to do something before the association 
  Specifically, if you define a window (such as CButton derived class CMyButton), and then use dialog data exchange to associate a button with its own derived class object, at this time, some "pre-build" processing should be written in "PreSubclassWindow" "Medium. 
  If you are not using "dialog data association", but create m_mybtn.Create(...) yourself in OnInitDialg At 
  this time, some "pre-create" processing should be written in "PreCreateWindow".

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324979742&siteId=291194637