c++菜鸟 求助一个cbutton问题

#include<afxwin.h>
#define IDB_BUTTON 100

class CButtonApp : public CWinApp
{
public:
virtual int InitInstance();
};

CButtonApp ButtonApp;
class CButtonWindow : public CFrameWnd
{
CButton *button;//
public:
CButtonWindow();
afx_msg void HandleButton();
DECLARE_MESSAGE_MAP()
};

void CButtonWindow::HandleButton()
{
AfxMessageBox("Hello, Your Clicked Button!");
}

BENGIN_MESSAGE_MAP(CButtonWindow,CFrameWnd)
ON_BN_CLICKED(IDB_BUTTON,HandleButton)
END_MESSAGE_MAP()

int CButtonApp::InitInstance()
{
m_pMainWnd=new CButtonWindow();
m_pMainWnd->ShowWindow(m_nCmdShow);
m_pMainWnd->UpdateWindow();
return 1;
}

CButtonWindow::CButtonWindow()
{
CRect r;
Create(NULL,"CButton Tests!",WS_OVERLAPPEDWINDOW,CRect(0,0,200,200));
GetClientRect(&r);
r.InflateRect(-20,-20);
button=new Button();
button->Create("push me",WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON,r,this,IDB_BUTTON);
}
我是菜鸟 希望哪位大哥 帮忙看哈上面的程序有什么问题 怎么解决 我是照书上敲得
还是没解决 算了 还是送人吧 不然不白费

第1个回答  2009-06-30
定义button类,可以使用mfc的类向导,不容易出错!CButton是一个MFC的类.不知道你是怎么定义你的Button类,手动写的话,一定要注意声明.
第2个回答  2009-06-29
afx_msg void HandleButton();
上面的没有定义,
需要用下面的方式进行定义
//{{AFX_MSG(your class or thread)
// NOTE - the ClassWizard will add and remove member functions here.

//}}AFX_MSG本回答被提问者采纳
第3个回答  2009-06-29
看的有点晕,你说的不是太清楚了

比如:你工程怎么创建的,想要实现什么效果,结果在哪步出现问题无法解决

要不别人还真不好懂
第4个回答  2009-07-08
这个程序时用MFC编的,你这个程序不完整。我也正在学MFC,不大明白。
第5个回答  2009-06-28
把错误代码贴出来啊。
0分还想帮你看整个程序呢
相似回答