unexpected end of file found

本文展示了一个使用Microsoft Foundation Classes (MFC) 创建简单按钮并处理其点击事件的示例。该示例代码中定义了一个窗口类Cbutton3Window,其中包含一个按钮,当调整窗口大小或点击按钮时,会触发相应的消息处理函数。

 #include <afxwin.h>
#define IDB_BUTTON 100
class Cbutton3App:public CWinApp
{
public:
 virtual BOOL InitInstance();
};
Cbutton3App button3App;
class Cbutton3Window:public CFrameWnd
{
 CButton* button;
public:
 Cbutton3Window();
 afx_msg void HandleButton();
 afx_msg void OnSize(UINT ,int ,int );
 DECLARE_MESSAGE_MAP()
};
void Cbutton3Window::HandleButton()
{
 MessageBeep(-1);
}
void Cbutton3Window::OnSize(UINT nType,int cx,int cy)
{
 CRect r;
 GetClientRect(&r);
 r.InflateRect(-20,-20);
 button->MoveWindow(r);
}
BEGIN_MESSAGE_MAP(Cbutton3Window,CFrameWnd)
ON_BN_CLICKED(IDB_BUTTON,HandleButton)
ON_WM_SIZE()
END_MESSAGE_MAP()
BOOL Cbutton3App::InitInstance()
{
 m_pMainWnd=new Cbutton3Window();
 m_pMainWnd->ShowWindow(m_nCmdShow);
 m_pMainWnd->UpdateWindow();
 return true;
}
class Cbutton3Window::Cbutton3Window()
{
 CRect r;
 Create(NULL,"Cbutton test",WS_OVERLAPPEDWINDOW,CRect(0,0,200,200);
 GetClientRect(&r);
 r.InflateRect(-20,-20);
 button=new CButton();
 button->Create("Push me",WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON,r,this,IDB_BUTTON);

}
编译后提示unexpected end of file found

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

静水流深_0321

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值