我从CStatic继承了新类CMyStatic,同时处理CMyStatic的WM_CREATE消息OnCreate,
但是为什么OnCreate处理函数不进入执行?如何使OnCreate中的代码自动触发?
但是为什么OnCreate处理函数不进入执行?如何使OnCreate中的代码自动触发?
解决方案 »
- 单文档 用CSplitterWnd 分割后,拖拉边框视图闪烁
- 拖动的时候的界面刷新问题
- 如果我要用一个程序库,他本身有调试版的和Release版的,我怎么在vc里设置?
- 对话框程序中,已执行到OnInitDialog中了,怎样不显示对话框结束程序。
- COM组件有一个方法HRESULT test([in]byte* aaa);请问能不能用VBScript调用?如何调用?
- CFile中如何插入删除特定数据?
- 使用hp SNMP++开发网管软件时遇到的效率问题
- 如何退出程序的时候自动保存文件?
- 请高手帮帮我!!!
- 项目里多线程的问题
- 想学网络编程,不知该看什么书入门,高手给指点些好的专业的书籍,谢谢!
- 请问能否向com传递自定义类的指针??能否让com与主程序共享全局变量??
全部代码如下:执行时,PreSubclassWindow()可以执行到,但OnCreate偏偏就是不行。
但我的代码一定要在OnCreate函数中执行的。哪位大虾遇到过同样问题,请指点。class CMyStatic : public CStatic
{
public:
CMyStatic();
virtual ~CMyStatic(); //{{AFX_VIRTUAL(CMyStatic)
protected:
virtual void PreSubclassWindow();
//}}AFX_VIRTUALprotected:
//{{AFX_MSG(CMyStatic)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
//}}AFX_MSG DECLARE_MESSAGE_MAP()
};CMyStatic::CMyStatic()
{
}CMyStatic::~CMyStatic()
{
}
BEGIN_MESSAGE_MAP(CMyStatic, CStatic)
//{{AFX_MSG_MAP(CMyStatic)
ON_WM_CREATE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////
// CMyStatic message handlersvoid CMyStatic::PreSubclassWindow()
{
CStatic::PreSubclassWindow();
AfxMessageBox("PreSubclassWindow");
}int CMyStatic::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CStatic::OnCreate(lpCreateStruct) == -1)
return -1;
AfxMessageBox("OnCreate"); return 0;
}
This method is called by the framework when an application requests that the Windows CE window be created by calling the Create or CreateEx method. The CWnd object receives this call after the window is created but before it becomes visible. OnCreate is called before the Create or CreateEx method returns.
可是我想让CStatic的WM_CREATE的CStatic::OnCreate也自动进入。我之所以用CStatic而不用CWnd,是因为CStatic用起来方便,不需要写代码来Create.
This method is called by the framework when an application requests that the Windows CE window be created by calling the Create or CreateEx method. The CWnd object receives this call after the window is created but before it becomes visible. OnCreate is called before the Create or CreateEx method returns.
我是动态生成,然后create的才能处理wm_create,但是如果是资源里面就生成得就不能处理wm_create
关注解决办法
You can initialize your static control object in overrided PresubclassWIndow function.your static control is initialized during dialog initialization ,then is attached to your static control object during the first updatedata call in CDialog::OnInitDialog
LTEXT "Static",IDC_fan,251,106,52,38
可能这个就是初始化,代替了类中的
m_MyStatic.Create(_T("my static"), WS_CHILD|WS_VISIBLE|SS_CENTER,
CRect(10,10,150,50), this);