// GameFrame.cpp : implementation file // #include "stdafx.h" #include "mw4gameed2.h" #include "GameFrame.h" #include ///////////////////////////////////////////////////////////////////////////// // CGameFrame //IMPLEMENT_DYNCREATE(CGameFrame, CFrameWnd) CGameFrame::CGameFrame(ObjectManager *objman,CWnd *parent):m_wndView(objman,parent) { LoadFrame(IDR_GAMEFRAME,WS_OVERLAPPED|WS_THICKFRAME|WS_CAPTION|WS_MAXIMIZEBOX|WS_MINIMIZEBOX|WS_SYSMENU,parent); } CGameFrame::~CGameFrame() { } BEGIN_MESSAGE_MAP(CGameFrame, CFrameWnd) //{{AFX_MSG_MAP(CGameFrame) ON_WM_CREATE() ON_WM_CLOSE() ON_WM_SIZE() ON_WM_SETFOCUS() ON_COMMAND(ID_HELP, OnHelp) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CGameFrame message handlers int CGameFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CFrameWnd::OnCreate(lpCreateStruct) == -1) return -1; // create a view to occupy the client area of the frame if (!m_wndView.Create(NULL, "Game View Window", AFX_WS_DEFAULT_VIEW, CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST, NULL)) { TRACE0("Failed to create view window\n"); return -1; } /* if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || !m_wndToolBar.LoadToolBar(IDR_OVERVIEW)) { TRACE0("Failed to create toolbar\n"); return -1; // fail to create } if (!m_wndStatusBar.Create(this) || !m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT))) { TRACE0("Failed to create status bar\n"); return -1; // fail to create } */ // TODO: Delete these three lines if you don't want the toolbar to // be dockable // m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); // EnableDocking(CBRS_ALIGN_ANY); // DockControlBar(&m_wndToolBar); // m_wndView.InitWindow(); return 0; return 0; } void CGameFrame::OnClose() { // TODO: Add your message handler code here and/or call default ShowWindow(SW_HIDE); // CFrameWnd::OnClose(); } void CGameFrame::OnSize(UINT nType, int cx, int cy) { CFrameWnd::OnSize(nType, cx, cy); // TODO: Add your message handler code here } void CGameFrame::OnSetFocus(CWnd* pOldWnd) { CFrameWnd::OnSetFocus(pOldWnd); m_wndView.SetFocus(); // TODO: Add your message handler code here } void CGameFrame::LoadFromReg() { CRect rct; CString wintitle; GetWindowText(wintitle); unsigned long size; size=sizeof(rct); gos_LoadDataFromRegistry((char *)(LPCSTR)(wintitle+"Rect"),&rct,&size); if(size) SetWindowPos(NULL,rct.left,rct.top,rct.Width(),rct.Height(),SWP_NOZORDER); int tdat; size=sizeof(tdat); gos_LoadDataFromRegistry((char *)(LPCSTR)(wintitle+"Visible"),&tdat,&size); if(size && tdat==0) ShowWindow(SW_HIDE); else ShowWindow(SW_SHOW); } void CGameFrame::SaveToReg() { CRect rct; GetWindowRect(&rct); CString wintitle; int tdat; GetWindowText(wintitle); gos_SaveDataToRegistry((char *)(LPCSTR)(wintitle+"Rect"),&rct,sizeof(rct)); tdat=IsWindowVisible(); gos_SaveDataToRegistry((char *)(LPCSTR)(wintitle+"Visible"),&tdat,sizeof(tdat)); } extern bool gActive; extern bool gGotFocus; LRESULT CGameFrame::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) { gActive = true; gGotFocus= true; switch(message) { case WM_PAINT: case WM_ACTIVATE: case WM_CHAR: case WM_SETFOCUS: case WM_KEYDOWN: case WM_MOVE: case WM_LBUTTONDOWN: case WM_LBUTTONUP: case WM_RBUTTONDOWN: case WM_RBUTTONUP: GameOSWinProc(m_hWnd, message, wParam, lParam); break; return CFrameWnd::WindowProc(message, wParam, lParam); } return CWnd::WindowProc(message, wParam, lParam); } void CGameFrame::OnHelp() { CAboutDlg aboutDlg; aboutDlg.DoModal(); }