1 /* $Id: MainFrm.cpp,v 5.0 2001/04/07 20:00:59 dik Exp $
2 *
3 * XPilot, a multiplayer gravity war game. Copyright (C) 1991-2001 by
4 *
5 * Bj�rn Stabell <bjoern@xpilot.org>
6 * Ken Ronny Schouten <ken@xpilot.org>
7 * Bert Gijsbers <bert@xpilot.org>
8 * Dick Balaska <dick@xpilot.org>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 */
24
25 // MainFrm.cpp : implementation of the CMainFrame class
26 //
27
28 #include "stdafx.h"
29 #include "XPilotNT.h"
30
31 #include "MainFrm.h"
32 #include "Splash.h"
33
34 #define _XPDOC
35 #include "winXXPilot.h"
36
37 #ifdef _DEBUG
38 #define new DEBUG_NEW
39 #undef THIS_FILE
40 static char THIS_FILE[] = __FILE__;
41 #endif
42
43 /////////////////////////////////////////////////////////////////////////////
44 // CMainFrame
45
46 IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
47
48 BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
49 //{{AFX_MSG_MAP(CMainFrame)
50 // NOTE - the ClassWizard will add and remove mapping macros here.
51 // DO NOT EDIT what you see in these blocks of generated code !
52 ON_WM_CREATE()
53 //}}AFX_MSG_MAP
54 // Global help commands
55 ON_COMMAND(ID_HELP_FINDER, CFrameWnd::OnHelpFinder)
56 ON_COMMAND(ID_HELP, CFrameWnd::OnHelp)
57 ON_COMMAND(ID_CONTEXT_HELP, CFrameWnd::OnContextHelp)
58 ON_COMMAND(ID_DEFAULT_HELP, CFrameWnd::OnHelpFinder)
59 ON_WM_PALETTECHANGED()
60 ON_WM_QUERYNEWPALETTE()
61 END_MESSAGE_MAP()
62
63 static UINT indicators[] =
64 {
65 ID_SEPARATOR, // status line indicator
66 ID_INDICATOR_CAPS,
67 ID_INDICATOR_NUM,
68 ID_INDICATOR_SCRL,
69 };
70
71 /////////////////////////////////////////////////////////////////////////////
72 // CMainFrame construction/destruction
73
CMainFrame()74 CMainFrame::CMainFrame()
75 {
76 // TODO: add member initialization code here
77
78 }
79
~CMainFrame()80 CMainFrame::~CMainFrame()
81 {
82 }
83
OnCreate(LPCREATESTRUCT lpCreateStruct)84 int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
85 {
86 if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
87 return -1;
88
89 #if 0
90 if (!m_wndToolBar.Create(this) ||
91 !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
92 {
93 TRACE0("Failed to create toolbar\n");
94 return -1; // fail to create
95 }
96
97 if (!m_wndStatusBar.Create(this) ||
98 !m_wndStatusBar.SetIndicators(indicators,
99 sizeof(indicators)/sizeof(UINT)))
100 {
101 TRACE0("Failed to create status bar\n");
102 return -1; // fail to create
103 }
104 // TODO: Remove this if you don't want tool tips or a resizeable toolbar
105 m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
106 CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
107
108 // TODO: Delete these three lines if you don't want the toolbar to
109 // be dockable
110 m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
111 EnableDocking(CBRS_ALIGN_ANY);
112 DockControlBar(&m_wndToolBar);
113 #endif
114
115 // CG: The following line was added by the Splash Screen component.
116 CSplashWnd::ShowSplashScreen(this);
117 return 0;
118 }
119
OnPaletteChanged(CWnd * pFocusWnd)120 void CMainFrame::OnPaletteChanged(CWnd* pFocusWnd)
121 {
122 CFrameWnd::OnPaletteChanged(pFocusWnd);
123
124 if (pFocusWnd != this)
125 OnQueryNewPalette();
126 }
127
OnQueryNewPalette()128 BOOL CMainFrame::OnQueryNewPalette()
129 {
130 ChangePalette(HWND(*this));
131
132 //return CFrameWnd::OnQueryNewPalette();
133 return(TRUE);
134 }
135
PreCreateWindow(CREATESTRUCT & cs)136 BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
137 {
138 // TODO: Modify the Window class or styles here by modifying
139 // the CREATESTRUCT cs
140
141 if(cs.hMenu!=NULL)
142 {
143 ::DestroyMenu(cs.hMenu); // delete menu if loaded
144 cs.hMenu = NULL; // no menu for this window
145 }
146
147 return CFrameWnd::PreCreateWindow(cs);
148 }
149
150 /////////////////////////////////////////////////////////////////////////////
151 // CMainFrame diagnostics
152
153 #ifdef _DEBUG
AssertValid() const154 void CMainFrame::AssertValid() const
155 {
156 CFrameWnd::AssertValid();
157 }
158
Dump(CDumpContext & dc) const159 void CMainFrame::Dump(CDumpContext& dc) const
160 {
161 CFrameWnd::Dump(dc);
162 }
163
164 #endif //_DEBUG
165
166 /////////////////////////////////////////////////////////////////////////////
167 // CMainFrame message handlers
168
PreTranslateMessage(MSG * pMsg)169 BOOL CMainFrame::PreTranslateMessage(MSG* pMsg)
170 {
171 // TODO: Add your specialized code here and/or call the base class
172
173 if (pMsg->message == WM_SYSKEYUP)
174 return(1);
175 return CFrameWnd::PreTranslateMessage(pMsg);
176 }
177