如何知道何时调用CWnd的Create函数? [英] How to know when CWnd's Create function was called?

查看:250
本文介绍了如何知道何时调用CWnd的Create函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一个包装网格控件的类. 我想在通过调用Create函数创建自定义网格类时对其进行初始化.

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.

我有办法赶上活动吗?

推荐答案

是的,如果使用CWnd:Create或Cwd:CreateEx,则可以通过以下方式捕获Win32事件:

Yes, if CWnd:Create or Cwd:CreateEx is used, it is possible to catch the Win32 event with:

afx_msg int OnCreate(
   LPCREATESTRUCT lpCreateStruct 
);

请参见 CWnd :: OnCreate

具有相应的映射:

BEGIN_MESSAGE_MAP(MyGrid, CWnd)
ON_WM_CREATE()
END_MESSAGE_MAP()

注意:如果设计者将控件直接添加到对话框模板上(即使用DDX),则不会调用CWnd:.OnCreate()函数.

Attention: If your control is directly added on a dialog template by the designer (ie, using DDX), the function CWnd:.OnCreate() is not called.

在所有情况下,初始化Hwnd(窗口的句柄)后,都会在创建时调用以下函数:

In all cases, the following function is called at creation, after the Hwnd (handle of window) is initialized:

virtual void PreSubclassWindow( );

请参见 PreSubclassWindow

最诚挚的问候, 阿兰

这篇关于如何知道何时调用CWnd的Create函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆