📄 hello.cpp
字号:
#include<afxwin.h>
#include<string.h>
#define IDB_BUTTON 100
class CButtonApp:public CWinApp
{
public:
virtual BOOL InitInstance();
};
CButtonApp ButtonApp;
class CButtonWindow:public CFrameWnd
{
CButton*button;
public:
CButtonWindow();
afx_msg void HandleButton();
DECLARE_MESSAGE_MAP();
};
void CButtonWindow::HandleButton()
{
char a[20];
char str[20];
gets(str);
strcpy(a,"str");
AfxMessageBox(a);
}
BEGIN_MESSAGE_MAP(CButtonWindow,CFrameWnd)//创建消息映射宏
ON_BN_CLICKED(IDB_BUTTON,HandleButton)//将鼠标单击按钮IDB_BUTTON事件与此消息的成员函数HandleButton联系在一起
END_MESSAGE_MAP()
BOOL CButtonApp::InitInstance()
{
m_pMainWnd=new CButtonWindow();
m_pMainWnd->ShowWindow(m_nCmdShow);
m_pMainWnd->UpdateWindow();
return TRUE;
}
CButtonWindow::CButtonWindow()
{
CRect r;
//创建窗口
Create(NULL,"CButton Tests",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);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -