Alientech 0.01
An extendable game engine
C:/Alientech/AlienPlanets/AlienPlanets.cpp
Go to the documentation of this file.
00001 
00002 // AlienPlanets.cpp : Defines the class behaviors for the application.
00003 //
00004 
00005 #include "stdafx.h"
00006 #include "afxwinappex.h"
00007 #include "afxdialogex.h"
00008 #include "AlienPlanets.h"
00009 #include "MainFrm.h"
00010 
00011 #include "ChildFrm.h"
00012 #include "AlienPlanetsDoc.h"
00013 #include "AlienPlanetsView.h"
00014 #include "MaterialEditor.h"
00015 
00016 #ifdef _DEBUG
00017 #define new DEBUG_NEW
00018 #endif
00019 
00020 
00021 // CAlienPlanetsApp
00022 
00023 BEGIN_MESSAGE_MAP(CAlienPlanetsApp, CWinAppEx)
00024         ON_COMMAND(ID_APP_ABOUT, &CAlienPlanetsApp::OnAppAbout)
00025         // Standard file based document commands
00026         ON_COMMAND(ID_FILE_NEW, &CWinAppEx::OnFileNew)
00027         ON_COMMAND(ID_FILE_OPEN, &CWinAppEx::OnFileOpen)
00028         // Standard print setup command
00029         ON_COMMAND(ID_FILE_PRINT_SETUP, &CWinAppEx::OnFilePrintSetup)
00030 END_MESSAGE_MAP()
00031 
00032 
00033 // CAlienPlanetsApp construction
00034 
00035 CAlienPlanetsApp::CAlienPlanetsApp()
00036 {
00037         m_bHiColorIcons = TRUE;
00038 
00039         // support Restart Manager
00040         m_dwRestartManagerSupportFlags = AFX_RESTART_MANAGER_SUPPORT_ALL_ASPECTS;
00041 #ifdef _MANAGED
00042         // If the application is built using Common Language Runtime support (/clr):
00043         //     1) This additional setting is needed for Restart Manager support to work properly.
00044         //     2) In your project, you must add a reference to System.Windows.Forms in order to build.
00045         System::Windows::Forms::Application::SetUnhandledExceptionMode(System::Windows::Forms::UnhandledExceptionMode::ThrowException);
00046 #endif
00047 
00048         // TODO: replace application ID string below with unique ID string; recommended
00049         // format for string is CompanyName.ProductName.SubProduct.VersionInformation
00050         SetAppID(_T("AlienPlanets.AppID.NoVersion"));
00051 
00052         // TODO: add construction code here,
00053         // Place all significant initialization in InitInstance
00054 }
00055 
00056 // The one and only CAlienPlanetsApp object
00057 
00058 CAlienPlanetsApp theApp;
00059 // This identifier was generated to be statistically unique for your app
00060 // You may change it if you prefer to choose a specific identifier
00061 
00062 // {F3915C0F-1EB0-4783-9BDE-4DFCDD75EDB6}
00063 static const CLSID clsid =
00064 { 0xF3915C0F, 0x1EB0, 0x4783, { 0x9B, 0xDE, 0x4D, 0xFC, 0xDD, 0x75, 0xED, 0xB6 } };
00065 
00066 const GUID CDECL _tlid = { 0x9314CC56, 0x8B4F, 0x4CCB, { 0x83, 0x4C, 0xD8, 0x1A, 0x19, 0x1D, 0x6D, 0xFD } };
00067 const WORD _wVerMajor = 1;
00068 const WORD _wVerMinor = 0;
00069 
00070 
00071 // CAlienPlanetsApp initialization
00072 
00073 BOOL CAlienPlanetsApp::InitInstance()
00074 {
00075         // InitCommonControlsEx() is required on Windows XP if an application
00076         // manifest specifies use of ComCtl32.dll version 6 or later to enable
00077         // visual styles.  Otherwise, any window creation will fail.
00078         INITCOMMONCONTROLSEX InitCtrls;
00079         InitCtrls.dwSize = sizeof(InitCtrls);
00080         // Set this to include all the common control classes you want to use
00081         // in your application.
00082         InitCtrls.dwICC = ICC_WIN95_CLASSES;
00083         InitCommonControlsEx(&InitCtrls);
00084 
00085         CWinAppEx::InitInstance();
00086 
00087 
00088         // Initialize OLE libraries
00089         if (!AfxOleInit())
00090         {
00091                 AfxMessageBox(IDP_OLE_INIT_FAILED);
00092                 return FALSE;
00093         }
00094 
00095         AfxEnableControlContainer();
00096 
00097         EnableTaskbarInteraction();
00098 
00099         // AfxInitRichEdit2() is required to use RichEdit control       
00100         // AfxInitRichEdit2();
00101 
00102         // Standard initialization
00103         // If you are not using these features and wish to reduce the size
00104         // of your final executable, you should remove from the following
00105         // the specific initialization routines you do not need
00106         // Change the registry key under which our settings are stored
00107         // TODO: You should modify this string to be something appropriate
00108         // such as the name of your company or organization
00109         SetRegistryKey(_T("Local AppWizard-Generated Applications"));
00110         LoadStdProfileSettings(10);  // Load standard INI file options (including MRU)
00111 
00112 
00113         InitContextMenuManager();
00114 
00115         InitKeyboardManager();
00116 
00117         InitTooltipManager();
00118         CMFCToolTipInfo ttParams;
00119         ttParams.m_bVislManagerTheme = TRUE;
00120         theApp.GetTooltipManager()->SetTooltipParams(AFX_TOOLTIP_TYPE_ALL,
00121                 RUNTIME_CLASS(CMFCToolTipCtrl), &ttParams);
00122 
00123         // Register the application's document templates.  Document templates
00124         //  serve as the connection between documents, frame windows and views
00125         CMultiDocTemplate* pDocTemplate;
00126         pDocTemplate = new CMultiDocTemplate(IDR_AlienPlanetFileTYPE,
00127                 RUNTIME_CLASS(CAlienPlanetsDoc),
00128                 RUNTIME_CLASS(CChildFrame), // custom MDI child frame
00129                 RUNTIME_CLASS(CAlienPlanetsView));
00130         if (!pDocTemplate)
00131                 return FALSE;
00132         pDocTemplate->SetContainerInfo(IDR_AlienPlanetFileTYPE_CNTR_IP);
00133         AddDocTemplate(pDocTemplate);
00134 
00135         pDocTemplate = new CMultiDocTemplate(IDR_MATERIAL_FILE_TYPE,
00136                 RUNTIME_CLASS(CMaterialEditor),
00137                 RUNTIME_CLASS(CChildFrame),
00138                 RUNTIME_CLASS(CAlienPlanetsView));
00139         if (!pDocTemplate)
00140                 return FALSE;
00141         pDocTemplate->SetContainerInfo(IDR_MATERIAL_EDITOR_TYPE_CNTR_IP);
00142         AddDocTemplate(pDocTemplate);
00143         // Connect the COleTemplateServer to the document template
00144         //  The COleTemplateServer creates new documents on behalf
00145         //  of requesting OLE containers by using information
00146         //  specified in the document template
00147         m_server.ConnectTemplate(clsid, pDocTemplate, FALSE);
00148         // Register all OLE server factories as running.  This enables the
00149         //  OLE libraries to create objects from other applications
00150         COleTemplateServer::RegisterAll();
00151                 // Note: MDI applications register all server objects without regard
00152                 //  to the /Embedding or /Automation on the command line
00153 
00154         // create main MDI Frame window
00155         CMainFrame* pMainFrame = new CMainFrame;
00156         if (!pMainFrame || !pMainFrame->LoadFrame(IDR_MAINFRAME))
00157         {
00158                 delete pMainFrame;
00159                 return FALSE;
00160         }
00161         m_pMainWnd = pMainFrame;
00162         // call DragAcceptFiles only if there's a suffix
00163         //  In an MDI app, this should occur immediately after setting m_pMainWnd
00164         // Enable drag/drop open
00165         m_pMainWnd->DragAcceptFiles();
00166 
00167         // Parse command line for standard shell commands, DDE, file open
00168         CCommandLineInfo cmdInfo;
00169         ParseCommandLine(cmdInfo);
00170 
00171         // Enable DDE Execute open
00172         EnableShellOpen();
00173         RegisterShellFileTypes(TRUE);
00174 
00175         // App was launched with /Embedding or /Automation switch.
00176         // Run app as automation server.
00177         if (cmdInfo.m_bRunEmbedded || cmdInfo.m_bRunAutomated)
00178         {
00179                 // Don't show the main window
00180                 return TRUE;
00181         }
00182         // App was launched with /Unregserver or /Unregister switch.  Unregister
00183         // typelibrary.  Other unregistration occurs in ProcessShellCommand().
00184         else if (cmdInfo.m_nShellCommand == CCommandLineInfo::AppUnregister)
00185         {
00186                 UnregisterShellFileTypes();
00187                 m_server.UpdateRegistry(OAT_DISPATCH_OBJECT, NULL, NULL, FALSE);
00188                 AfxOleUnregisterTypeLib(_tlid, _wVerMajor, _wVerMinor);
00189         }
00190         // App was launched standalone or with other switches (e.g. /Register
00191         // or /Regserver).  Update registry entries, including typelibrary.
00192         else
00193         {
00194                 m_server.UpdateRegistry(OAT_DISPATCH_OBJECT);
00195                 COleObjectFactory::UpdateRegistryAll();
00196                 AfxOleRegisterTypeLib(AfxGetInstanceHandle(), _tlid);
00197         }
00198 
00199         // Dispatch commands specified on the command line.  Will return FALSE if
00200         // app was launched with /RegServer, /Register, /Unregserver or /Unregister.
00201         if (!ProcessShellCommand(cmdInfo))
00202                 return FALSE;
00203         // The main window has been initialized, so show and update it
00204         pMainFrame->ShowWindow(m_nCmdShow);
00205         pMainFrame->UpdateWindow();
00206 
00207         return TRUE;
00208 }
00209 
00210 int CAlienPlanetsApp::ExitInstance()
00211 {
00212         //TODO: handle additional resources you may have added
00213         AfxOleTerm(FALSE);
00214 
00215         return CWinAppEx::ExitInstance();
00216 }
00217 
00218 // CAlienPlanetsApp message handlers
00219 
00220 
00221 // CAboutDlg dialog used for App About
00222 
00223 class CAboutDlg : public CDialogEx
00224 {
00225 public:
00226         CAboutDlg();
00227 
00228 // Dialog Data
00229         enum { IDD = IDD_ABOUTBOX };
00230 
00231 protected:
00232         virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
00233 
00234 // Implementation
00235 protected:
00236         DECLARE_MESSAGE_MAP()
00237 };
00238 
00239 CAboutDlg::CAboutDlg() : CDialogEx(CAboutDlg::IDD)
00240 {
00241 }
00242 
00243 void CAboutDlg::DoDataExchange(CDataExchange* pDX)
00244 {
00245         CDialogEx::DoDataExchange(pDX);
00246 }
00247 
00248 BEGIN_MESSAGE_MAP(CAboutDlg, CDialogEx)
00249 END_MESSAGE_MAP()
00250 
00251 // App command to run the dialog
00252 void CAlienPlanetsApp::OnAppAbout()
00253 {
00254         CAboutDlg aboutDlg;
00255         aboutDlg.DoModal();
00256 }
00257 
00258 // CAlienPlanetsApp customization load/save methods
00259 
00260 void CAlienPlanetsApp::PreLoadState()
00261 {
00262         BOOL bNameValid;
00263         CString strName;
00264         bNameValid = strName.LoadString(IDS_EDIT_MENU);
00265         ASSERT(bNameValid);
00266         GetContextMenuManager()->AddMenu(strName, IDR_POPUP_EDIT);
00267         bNameValid = strName.LoadString(IDS_EXPLORER);
00268         ASSERT(bNameValid);
00269         GetContextMenuManager()->AddMenu(strName, IDR_POPUP_EXPLORER);
00270 }
00271 
00272 void CAlienPlanetsApp::LoadCustomState()
00273 {
00274 }
00275 
00276 void CAlienPlanetsApp::SaveCustomState()
00277 {
00278 }
00279 
00280 // CAlienPlanetsApp message handlers
00281 
00282 
00283