用MFC编写的推箱子游戏
BOOL CSkyblue_BoxManApp::InitInstance()
{
// 定义和注册窗口
m_pBoxManWnd = new CBoxManWnd();
WNDCLASS wc;
ZeroMemory(&wc, sizeof(wc));
wc.hInstance = AfxGetInstanceHandle();
wc.lpfnWndProc = ::DefWindowProc;
wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
wc.hCursor = LoadCursor(IDC_ARROW);
wc.hIcon = LoadIcon(IDR_MAINFRAME);
wc.lpszClassName = className;
wc.lpszMenuName = MAKEINTRESOURCE(IDR_MAINFRAME);
// 注册主窗口类
if (!AfxRegisterClass(&wc))
{
AfxMessageBox("注册窗口类失败!!!");
return FALSE;
}
UINT uWidth = 550;
UINT uHeight = 550;
UINT uXPos = GetSystemMetrics(SM_CXSCREEN)/2 - uWidth/2 ;
UINT uYPos = GetSystemMetrics(SM_CYSCREEN)/2 - uHeight/2 ;
//创建,显示窗口
if ( !m_pBoxManWnd->CreateEx( NULL, className, _T("推箱子"),
WS_SYSMENU | WS_CAPTION | WS_MINIMIZEBOX,
uXPos, uYPos, uWidth, uHeight,
NULL, NULL) )
{
AfxMessageBox("创建主窗口失败!!!");
return FALSE;
}
m_pBoxManWnd->ShowWindow(SW_NORMAL);
// 绑定窗口为主窗口
m_pMainWnd = m_pBoxManWnd;
return TRUE;
}
2022-06-20 21:02:36
1.44MB
MFC
推箱子
1