我创建了一个VC的工程。划分2个客户区,一个客户区继承CFrameWnd类,在这个客户区动态创建一个CButton ,创建出来了,但是不能响应我的消息函数。为什么?BEGIN_MESSAGE_MAP(CMFMUBindView, CFrameWnd)
//{{AFX_MSG_MAP(CMFMUBindView)
ON_WM_CREATE()
ON_WM_SIZE()
ON_CONTROL_REFLECT(5667,OnBnCl)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////
// CMFMUBindView message handlersint CMFMUBindView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
b.Create("hehe",WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON, CRect(10,10,100,100), this, 5667);// b.ShowWindow(SW_SHOWNORMAL); return 0;
}void CMFMUBindView::OnSize(UINT nType, int cx, int cy)
{
CFrameWnd::OnSize(nType, cx, cy);
// TODO: Add your message handler code here
}
void CMFMUBindView::OnBnCl()
{ AfxMessageBox("11");
// TODO: Add your message handler code here
}
class CMFMUBindView : public CFrameWnd
{
DECLARE_DYNCREATE(CMFMUBindView)
protected:
CMFMUBindView(); // protected constructor used by dynamic creation// Attributes
public:
CMFButton b;
// Operations
public:// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMFMUBindView)
//}}AFX_VIRTUAL// Implementation
protected:
virtual ~CMFMUBindView(); // Generated message map functions
//{{AFX_MSG(CMFMUBindView)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnBnCl();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_MSG_MAP(CMFMUBindView)
ON_WM_CREATE()
ON_WM_SIZE()
ON_CONTROL_REFLECT(5667,OnBnCl)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////
// CMFMUBindView message handlersint CMFMUBindView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
b.Create("hehe",WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON, CRect(10,10,100,100), this, 5667);// b.ShowWindow(SW_SHOWNORMAL); return 0;
}void CMFMUBindView::OnSize(UINT nType, int cx, int cy)
{
CFrameWnd::OnSize(nType, cx, cy);
// TODO: Add your message handler code here
}
void CMFMUBindView::OnBnCl()
{ AfxMessageBox("11");
// TODO: Add your message handler code here
}
class CMFMUBindView : public CFrameWnd
{
DECLARE_DYNCREATE(CMFMUBindView)
protected:
CMFMUBindView(); // protected constructor used by dynamic creation// Attributes
public:
CMFButton b;
// Operations
public:// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMFMUBindView)
//}}AFX_VIRTUAL// Implementation
protected:
virtual ~CMFMUBindView(); // Generated message map functions
//{{AFX_MSG(CMFMUBindView)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnBnCl();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
解决方案 »
- VC2005 使用ADO读取Excel 的详细过程?
- 定义好一个类,在用它的成员函数时提示:error C2228: left of '.WriteErrLog' must have class/struct/un
- 如何将GIF图片复制到剪贴板,能在其它程序的RichEdit中粘贴?
- 望大家指点!!!
- 按纽有一部分透明,怎样让透明部分是对话框背景色(图片),而不是按纽默认的颜色啊~
- 谁有通讯录管理程序(VC)的源程序,我给100分
- 注册COM组件失败,错误为0x80070716
- 新建一对话框,编译出错!
- AppWizard自动生成代码的问题?
- 在对话框的菜单上加底图,怎么做?
- 有关空函数延迟的问题
- brushExisting.GetLogBrush( &logbrush );是什么!!
ON_WM_CREATE()
ON_WM_SIZE()
ON_CONTROL_REFLECT(5667,OnBnCl)
//}}AFX_MSG_MAP
动态创建的哪来的这个?