00001
00002
00003
00004 #include "stdafx.h"
00005 #include "Viewer.h"
00006 #include "MainFrm.h"
00007 #include "ChildFrm.h"
00008 #include "Common/Console.h"
00009
00010 #include "ViewerDoc.h"
00011 #include "ViewerView.h"
00012 #include "LogoDialog.h"
00013 #include "LeftView.h"
00014
00015 #ifdef _DEBUG
00016 #define new DEBUG_NEW
00017 #endif
00018
00019
00020
00021
00022 BEGIN_MESSAGE_MAP(CViewerApp, CWinApp)
00023 ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
00024
00025 ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
00026 ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
00027 END_MESSAGE_MAP()
00028
00029
00030
00031
00032 CViewerApp::CViewerApp()
00033 {
00034 m_pDocTemplate = NULL;
00035 }
00036
00037
00038
00039
00040 CViewerApp theApp;
00041
00042
00043
00044 BOOL CViewerApp::InitInstance()
00045 {
00046 GetCurrentDirectory( sizeof( m_pCurrentDirectory ), m_pCurrentDirectory );
00047
00048
00049
00050
00051 InitCommonControls();
00052
00053 CWinApp::InitInstance();
00054
00055
00056 if (!AfxOleInit())
00057 {
00058 AfxMessageBox(IDP_OLE_INIT_FAILED);
00059 return FALSE;
00060 }
00061 AfxEnableControlContainer();
00062
00063
00064 CLogoDialog LogoDlg;
00065
00066 LogoDlg.DoModal();
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076 SetRegistryKey(_T("Applications locales générées par AppWizard"));
00077 LoadStdProfileSettings(8);
00078
00079
00080 m_pDocTemplate = new CMultiDocTemplate(
00081 IDR_ViewerTYPE,
00082 RUNTIME_CLASS(CViewerDoc),
00083 RUNTIME_CLASS(CChildFrame),
00084 RUNTIME_CLASS(CLeftView));
00085 AddDocTemplate(m_pDocTemplate);
00086
00087 CMainFrame* pMainFrame = new CMainFrame;
00088 if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
00089 return FALSE;
00090 m_pMainWnd = pMainFrame;
00091
00092
00093
00094 CCommandLineInfo cmdInfo;
00095 cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing;
00096 ParseCommandLine(cmdInfo);
00097
00098
00099 if (!ProcessShellCommand(cmdInfo))
00100 return FALSE;
00101
00102 pMainFrame->ShowWindow(m_nCmdShow);
00103 pMainFrame->UpdateWindow();
00104
00105
00106 g_Console.Create( "Viewer console", true, m_hInstance, pMainFrame->GetSafeHwnd() );
00107
00108
00109 return TRUE;
00110 }
00111
00112 void CViewerApp::ResetCurrentDirectory()
00113 {
00114 SetCurrentDirectory( m_pCurrentDirectory );
00115 }
00116
00117
00118
00119
00120 int CViewerApp::ExitInstance()
00121 {
00122
00123 g_Console.Close();
00124
00125
00126 return CWinApp::ExitInstance();
00127 }
00128
00129 BOOL CViewerApp::OnIdle(LONG lCount)
00130 {
00131 if( !m_pMainWnd->IsIconic() )
00132 {
00133 CChildFrame* pChild = (CChildFrame*)((CMDIFrameWnd*)m_pMainWnd)->MDIGetActive();
00134 if( pChild )
00135 if( pChild->GetpGameViewer() )
00136 pChild->GetpGameViewer()->Run();
00137 }
00138 else
00139 Sleep( 100 );
00140
00141 return TRUE;
00142 }
00143
00144
00145
00146 class CAboutDlg : public CDialog
00147 {
00148 public:
00149 CAboutDlg();
00150
00151
00152 enum { IDD = IDD_ABOUTBOX };
00153
00154 protected:
00155 virtual void DoDataExchange(CDataExchange* pDX);
00156
00157
00158 protected:
00159 DECLARE_MESSAGE_MAP()
00160 };
00161
00162 CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
00163 {
00164 }
00165
00166 void CAboutDlg::DoDataExchange(CDataExchange* pDX)
00167 {
00168 CDialog::DoDataExchange(pDX);
00169 }
00170
00171 BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
00172 END_MESSAGE_MAP()
00173
00174
00175 void CViewerApp::OnAppAbout()
00176 {
00177 CAboutDlg aboutDlg;
00178 aboutDlg.DoModal();
00179 }
00180