#include "stdafx.h" #include "MapEditorApp.h" #include "MainFrame.h" #include "MapEditorView.h" #include "Engine/Application.h" #ifdef _DEBUG #define new DEBUG_NEW #endif cMapEditorApp theApp; BEGIN_MESSAGE_MAP(cMapEditorApp, CWinApp) ON_COMMAND(ID_APP_ABOUT, OnAppAbout) END_MESSAGE_MAP() cMapEditorApp::cMapEditorApp() { } BOOL cMapEditorApp::InitInstance() { /// ÇÁ·Î±×·¥ Áߺ¹ ½ÇÇà ¹æÁö // if( CheckMutex() == false ) // { // return FALSE; // } /// ½ÇÇà ÆÄÀÏÀÇ °æ·Î¸¦ ±â¹Ý µð·ºÅ丮·Î ¼³Á¤ TCHAR exePathName[MAX_PATH]; ::GetModuleFileName( AfxGetApp()->m_hInstance, exePathName, MAX_PATH ); cString exePath = exePathName; GetFilePath( &exePath, exePath ); SetCurrentDirectory( exePath.Cstr() ); mBaseDir = exePath; // ÀÀ¿ë ÇÁ·Î±×·¥ ¸Å´ÏÆä½ºÆ®°¡ ComCtl32.dll ¹öÀü 6 ÀÌ»óÀ» »ç¿ëÇÏ¿© ºñÁÖ¾ó ½ºÅ¸ÀÏÀ» // »ç¿ëÇϵµ·Ï ÁöÁ¤ÇÏ´Â °æ¿ì, Windows XP »ó¿¡¼­ ¹Ýµå½Ã InitCommonControls()°¡ ÇÊ¿äÇÕ´Ï´Ù. // InitCommonControls()¸¦ »ç¿ëÇÏÁö ¾ÊÀ¸¸é âÀ» ¸¸µé ¼ö ¾ø½À´Ï´Ù. InitCommonControls(); if( CWinApp::InitInstance() == FALSE ) return FALSE; // OLE ¶óÀ̺귯¸®¸¦ ÃʱâÈ­ if(!AfxOleInit()) { AfxMessageBox(IDP_OLE_INIT_FAILED); return FALSE; } AfxEnableControlContainer(); // ŸÀÌ¸Ó ÃʱâÈ­: ¸ÖƼ¹Ìµð¾î ŸÀÌ¸Ó ÇØ»óµµ¸¦ 1000ºÐÀÇ 1·Î Á¶Á¤ timeBeginPeriod(1); /// ÇÁ·¹ÀÓ »ý¼º cMainFrame* frame = new cMainFrame; if( frame == 0) return FALSE; m_pMainWnd = frame; // ÇÁ·¹ÀÓÀ» ¸¸µé¾î ¸®¼Ò½º¿Í ÇÔ²² ·ÎµåÇÕ´Ï´Ù. if( frame->LoadFrame( IDR_MAINFRAME ) == 0 ) return FALSE; // â Çϳª¸¸ ÃʱâÈ­µÇ¾úÀ¸¹Ç·Î À̸¦ Ç¥½ÃÇÏ°í ¾÷µ¥ÀÌÆ®ÇÕ´Ï´Ù. frame->ShowWindow( SW_SHOW ); frame->UpdateWindow(); return TRUE; } bool cMapEditorApp::CheckMutex() { /// ¹ÂÅØ½º »ý¼º HANDLE mutex = ::CreateMutex( 0, TRUE, "Iris MapEditor Mutex" ); /// ¹ÂÅØ½º°¡ ÀÌ¹Ì Á¸ÀçÇÏ´ÂÁö °Ë»ç bool alreadyExist = false; if( ::GetLastError() == ERROR_ALREADY_EXISTS ) alreadyExist = true; if( mutex ) ::ReleaseMutex( mutex ); if( alreadyExist ) { return false; } return true; } BOOL cMapEditorApp::OnIdle( LONG count ) { if( VIEW == m_pMainWnd->GetFocus() ) { VIEW->Update(); return TRUE; } else { return CWinApp::OnIdle(count); } } class cAboutDialog : public CDialog { public: cAboutDialog(); enum { IDD = IDD_ABOUTBOX }; }; cAboutDialog::cAboutDialog() : CDialog(cAboutDialog::IDD) { } void cMapEditorApp::OnAppAbout() { cAboutDialog aboutDlg; aboutDlg.DoModal(); }