// OverFrame.cpp : implementation file // #include "stdafx.h" #include "mw4gameed2.h" #include "OverFrame.h" class ObjectManager; static UINT indicators[] = { ID_SEPARATOR // status line indicator }; ///////////////////////////////////////////////////////////////////////////// // COverFrame //IMPLEMENT_DYNCREATE(COverFrame, CFrameWnd) COverFrame::COverFrame(ObjectManager *objman,CWnd *parent): m_wndView(objman,this) { LoadFrame(IDR_OVERVIEW,WS_OVERLAPPED|WS_THICKFRAME|WS_CAPTION|WS_MAXIMIZEBOX|WS_MINIMIZEBOX|WS_SYSMENU,parent); } COverFrame::~COverFrame() { } BEGIN_MESSAGE_MAP(COverFrame, CFrameWnd) //{{AFX_MSG_MAP(COverFrame) ON_WM_CREATE() ON_WM_SETFOCUS() ON_WM_SIZING() ON_WM_SIZE() ON_WM_CLOSE() ON_WM_SHOWWINDOW() ON_WM_PAINT() //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // COverFrame message handlers int COverFrame::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, NULL, 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 } m_wndStatusBar.ShowWindow(SW_HIDE); // 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; } void COverFrame::OnSetFocus(CWnd* pOldWnd) { CFrameWnd::OnSetFocus(pOldWnd); m_wndView.SetFocus(); } BOOL COverFrame::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo) { if (m_wndView.OnCmdMsg(nID, nCode, pExtra, pHandlerInfo)) return TRUE; return CFrameWnd::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo); } void COverFrame::OnSizing(UINT fwSide, LPRECT pRect) { CFrameWnd::OnSizing(fwSide, pRect); // TODO: Add your message handler code here } void COverFrame::OnSize(UINT nType, int cx, int cy) { CFrameWnd::OnSize(nType, cx, cy); m_wndToolBar.ShowWindow( IsIconic()?SW_HIDE:SW_SHOW); RecalcLayout(); } void COverFrame::SaveToReg() { int tdat; CRect rct; CString wintitle; GetWindowText(wintitle); GetWindowRect(&rct); gos_SaveDataToRegistry((char *)(LPCSTR)(wintitle+"Rect"),&rct,sizeof(rct)); tdat=IsWindowVisible(); gos_SaveDataToRegistry((char *)(LPCSTR)(wintitle+"Visible"),&tdat,sizeof(tdat)); m_wndView.SaveToReg(); } void COverFrame::LoadFromReg() { int tdat; unsigned long size; CRect rct; CString wintitle; GetWindowText(wintitle); m_wndView.LoadFromReg(); 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); size=sizeof(tdat); gos_LoadDataFromRegistry((char *)(LPCSTR)(wintitle+"Visible"),&tdat,&size); if(size && tdat==0) ShowWindow(SW_HIDE); else ShowWindow(SW_SHOW); } void COverFrame::OnClose() { ShowWindow(SW_HIDE); // CWnd::OnClose(); } void COverFrame::OnShowWindow(BOOL bShow, UINT nStatus) { CFrameWnd::OnShowWindow(bShow, nStatus); if(nStatus==SW_PARENTCLOSING) { DockControlBar(&m_wndToolBar); // m_wndToolBar.ShowWindow(SW_HIDE); } if(nStatus==SW_PARENTOPENING) { m_wndToolBar.ShowWindow(SW_SHOW); } RecalcLayout(); // TODO: Add your message handler code here } void COverFrame::OnPaint() { CPaintDC dc(this); // device context for painting // TODO: Add your message handler code here // Do not call CFrameWnd::OnPaint() for painting messages }