1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
/*!
@file
@author Albert Semenov
@date 08/2008
@module
*/
#ifndef BASEMAIN_H_
#define BASEMAIN_H_
#include "Precompiled.h"
#if MYGUI_PLATFORM == MYGUI_PLATFORM_WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif
#if MYGUI_PLATFORM == MYGUI_PLATFORM_WIN32
# ifdef MYGUI_CHECK_MEMORY_LEAKS
# define MYGUI_APP(cls) INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT argc) { _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); return startApp<cls>(); }
# else
# define MYGUI_APP(cls) INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT argc) { return startApp<cls>(); }
# endif
#else
# define MYGUI_APP(cls) int main(int argc, char **argv) { return startApp<cls>(); }
#endif
template <class AppClass>
int startApp()
{
try
{
AppClass* app = new AppClass();
app->prepare();
if (app->create())
{
app->run();
app->destroy();
}
delete app;
app = 0;
}
catch (MyGUI::Exception& _e)
{
#if MYGUI_PLATFORM == MYGUI_PLATFORM_WIN32
MessageBoxA( NULL, _e.getFullDescription().c_str(), "An exception has occured", MB_OK | MB_ICONERROR | MB_TASKMODAL);
#else
std::cerr << "An exception has occured" << " : " << _e.getFullDescription().c_str();
#endif
throw;
}
return 0;
}
#endif
|