How to know when CWnd's Create function was called?

瘦欲@ 提交于 2019-12-24 08:39:14

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!