コード例 #1
0
//=============================================================
// Game Engine General Methods
//=============================================================
BOOL GameEngine::Initialize(int iCmdShow)
{
	WNDCLASSEX		wndclass;

	//Create the window class for the main window
	wndclass.cbSize				= sizeof(wndclass);
	wndclass.style				= CS_HREDRAW | CS_VREDRAW;
	wndclass.lpfnWndProc		= WndProc;
	wndclass.cbClsExtra			= 0;
	wndclass.cbWndExtra			= 0;
	wndclass.hInstance			= m_hInstance;
	wndclass.hIcon				= LoadIcon(m_hInstance,
		MAKEINTRESOURCE(GetIcon()));
	wndclass.hIconSm			= LoadIcon(m_hInstance,
		MAKEINTRESOURCE(GetSmallIcon()));
	wndclass.hCursor			= LoadCursor(NULL, IDC_ARROW);
	wndclass.hbrBackground		= (HBRUSH)(COLOR_WINDOW + 1);
	wndclass.lpszMenuName		= NULL;
	wndclass.lpszClassName		= m_szWindowClass;

	//Register the window class
	if (!RegisterClassEx(&wndclass))
		return FALSE;

	//Calculate the window size and position based upon the game size
	int iWindowWidth = m_iWidth + GetSystemMetrics(SM_CXFIXEDFRAME) * 2,
		iWindowHeight = m_iHeight + GetSystemMetrics(SM_CYFIXEDFRAME) * 2 +
			GetSystemMetrics(SM_CYCAPTION);
	if (wndclass.lpszMenuName != NULL)
		iWindowHeight += GetSystemMetrics(SM_CYMENU);
	int iXWindowPos = (GetSystemMetrics(SM_CXSCREEN) - iWindowWidth) / 2,
		iYWindowPos = (GetSystemMetrics(SM_CYSCREEN) - iWindowHeight) / 2;

	//Create the window
	m_hWindow = CreateWindow(m_szWindowClass, m_szTitle, WS_POPUPWINDOW | 
		WS_CAPTION | WS_MINIMIZEBOX, iXWindowPos, iYWindowPos, iWindowWidth,
		iWindowHeight, NULL, NULL, m_hInstance, NULL);
	if (!m_hWindow)
		return FALSE;

	//Show and update the window
	ShowWindow(m_hWindow, iCmdShow);
	UpdateWindow(m_hWindow);

	return TRUE;
}
コード例 #2
0
ファイル: Winjj.cpp プロジェクト: jaylauffer/loadngo
ATOM Window::Register(HINSTANCE hinst)
{
	WNDCLASSEX wcex;
	wcex.cbSize = sizeof(WNDCLASSEX); 
	wcex.style			= CS_HREDRAW | CS_VREDRAW;
	wcex.lpfnWndProc	= (WNDPROC)Window::s_WinProc;
	wcex.cbClsExtra		= GetClassExtra();
	wcex.cbWndExtra		= GetWinExtra();
	wcex.hInstance		= hinst;
	wcex.hIcon			= GetIcon();
	wcex.hCursor		= GetCursor();
	wcex.hbrBackground	= GetBrush();
	wcex.lpszMenuName	= GetMenu();
	wcex.lpszClassName	= ClassName();
	wcex.hIconSm		= GetSmallIcon();

	return RegisterClassEx(&wcex);	
}