问题
I've wrote a class wrapping a grid controls. I want to init the custom grid class when it is created by calling Create function.
Is there a way that i can catch the event?
回答1:
Yes, if CWnd:Create or Cwd:CreateEx is used, it is possible to catch the Win32 event with:
afx_msg int OnCreate(
LPCREATESTRUCT lpCreateStruct
);
See CWnd::OnCreate
With the corresponding mapping:
BEGIN_MESSAGE_MAP(MyGrid, CWnd)
ON_WM_CREATE()
END_MESSAGE_MAP()
Attention: If your control is directly added on a dialog template by the designer (ie, using DDX), the function CWnd:.OnCreate() is not called.
In all cases, the following function is called at creation, after the Hwnd (handle of window) is initialized:
virtual void PreSubclassWindow( );
See PreSubclassWindow
Best regards, Alain
来源:https://stackoverflow.com/questions/8484861/how-to-know-when-cwnds-create-function-was-called