bool App::OnInit() { SetAppName(u8"flutterrust"); SetAppDisplayName(u8"flutterrust"); const wxFileName exeFileName{wxStandardPaths::Get().GetExecutablePath()}; const std::string exePath = exeFileName.GetPath().ToStdString(); try { Creature::loadTypes(exePath + static_cast<char>(wxFileName::GetPathSeparator()) + u8"CreatureTable.txt"); mainFrame = new MainFrame{exePath}; } catch (const std::exception& e) { wxMessageDialog dialog{nullptr, u8"Exception caught. Terminating.\n", u8"Fatal error", wxICON_ERROR | wxOK}; dialog.SetExtendedMessage(std::string{typeid(e).name()} + ": \"" + e.what() + '"'); dialog.ShowModal(); return false; // Exit the application immediately. } catch (...) { wxMessageDialog(nullptr, u8"Unknown exception caught. Terminating.", u8"Fatal error", wxICON_ERROR | wxOK) .ShowModal(); return false; } mainFrame->Show(true); SetTopWindow(mainFrame); return true; // Continue processing. }
bool KMPackageBuilderApp::OnInit() { SetAppName(wxT("KaraokeMachine Package Builder")); // create default config file wxConfigBase::Get(true); wxImage::AddHandler(new wxJPEGHandler); //// Create a document manager docManager_ = new wxDocManager; docManager_->FileHistoryLoad(*wxConfigBase::Get()); //// Template: Song (void) new wxDocTemplate((wxDocManager *) docManager_, wxT("Song Packages"), wxT("*.kms"), wxT(""), wxT("kms"),wxT("Songs Doc"), wxT("Songs View"), CLASSINFO(PBSongDocument), CLASSINFO(PBSongView)); //// Template: Image (void) new wxDocTemplate(docManager_, wxT("Image Packages"), wxT("*.kmi"), wxT(""), wxT("kmi"), wxT("Images Doc"), wxT("Images View"), CLASSINFO(PBImageDocument), CLASSINFO(PBImageView)); KMPackageBuilderFrame* frame = new KMPackageBuilderFrame((wxDocManager *) docManager_, (wxFrame *) NULL, wxT("KaraokeMachine Package Builder"), wxPoint(0, 0), wxSize(500, 400), wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE); #ifdef __WXMSW__ frame->SetIcon(wxICON(aaaa)); // To Set App Icon #endif frame->Show(true); SetTopWindow(frame); return true; }
bool Springsettings::OnInit() { wxSetEnv( _T("UBUNTU_MENUPROXY"), _T("0") ); //this triggers the Cli Parser amongst other stuff if (!wxApp::OnInit()) return false; SetAppName(_T("SpringSettings")); const wxString configdir = TowxString(SlPaths::GetConfigfileDir()); if ( !wxDirExists(configdir) ) wxMkdir(configdir); if (!m_crash_handle_disable) { #if wxUSE_ON_FATAL_EXCEPTION wxHandleFatalExceptions( true ); #endif #if defined(__WXMSW__) && defined(ENABLE_DEBUG_REPORT) //this undocumented function acts as a workaround for the dysfunctional // wxUSE_ON_FATAL_EXCEPTION on msw when mingw is used (or any other non SEH-capable compiler ) SetUnhandledExceptionFilter(filter); #endif } //initialize all loggers //TODO non-constant parameters wxLogChain* logchain = 0; wxLogWindow* loggerwin = InitializeLoggingTargets( 0, m_log_console, m_log_file_path, m_log_window_show, m_log_verbosity, logchain ); //this needs to called _before_ mainwindow instance is created #ifdef __WXMSW__ wxString path = wxPathOnly( wxStandardPaths::Get().GetExecutablePath() ) + wxFileName::GetPathSeparator() + _T("locale"); #else #if defined(LOCALE_INSTALL_DIR) wxString path ( _T(LOCALE_INSTALL_DIR) ); #else // use a dummy name here, we're only interested in the base path wxString path = wxStandardPaths::Get().GetLocalizedResourcesDir(_T("noneWH"),wxStandardPaths::ResourceCat_Messages); path = path.Left( path.First(_T("noneWH") ) ); #endif #endif m_translationhelper = new wxTranslationHelper( GetAppName().Lower(), path ); SetSettingsStandAlone( true ); // configure unitsync paths before trying to load SlPaths::ReconfigureUnitsync(); //unitsync first load, NEEDS to be blocking LSL::usync().ReloadUnitSyncLib(); settings_frame* frame = new settings_frame(NULL,GetAppName()); SetTopWindow(frame); frame->Show(); if ( loggerwin ) { // we got a logwindow, lets set proper parent win loggerwin->GetFrame()->SetParent( frame ); } return true; }
bool App::OnInit() { SetAppName(u8"TrackHack"); SetAppDisplayName(u8"TrackHack"); wxFileName localFileName = wxFileConfig::GetLocalFile("track_hack.ini", wxCONFIG_USE_SUBDIR); if (!localFileName.FileExists() && // Does the user-specific configuration file exist? !localFileName.DirExists()) // If not, does the directory where it would have // been not exist either? { // Create that directory. bool success = wxFileName::Mkdir(localFileName.GetPath(), wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL); if (!success) { // Assert success in creating it; otherwise terminate. ::wxLogFatalError("Failed to create local configuration directory: " "%s\n\nTerminating.", localFileName.GetPath()); } } wxConfigBase::Set(new wxFileConfig{u8"TrackHack", wxEmptyString, u8"track_hack.ini", u8"track_hack.ini", wxCONFIG_USE_LOCAL_FILE | wxCONFIG_USE_GLOBAL_FILE | wxCONFIG_USE_SUBDIR}); // No wxInitAllImageHandlers() as for now, only the BMP/DIB file format is supported. mainFrame = new MainFrame(wxDefaultPosition, wxSize(640, 720)); mainFrame->Show(true); SetTopWindow(mainFrame); return true; }
/** OnInit * * Initializes the program */ bool BBBApp::OnInit() { srand(time(NULL)); logger.reset(new LoggerWx()); if (!wxApp::OnInit()) return false; #ifndef __WIN32 wxHandleFatalExceptions(); #endif wxInitAllImageHandlers(); SetVendorName("Bottomless Block Builder"); SetAppName("Bottomless Block Builder"); wxBitmap bitmap(panels_gfx_xpm); panelImages.push_back(bitmap.GetSubBitmap(wxRect(112, 16, 16, 16))); panelImages.push_back(bitmap.GetSubBitmap(wxRect(0, 0, 16, 16))); panelImages.push_back(bitmap.GetSubBitmap(wxRect(16, 0, 16, 16))); panelImages.push_back(bitmap.GetSubBitmap(wxRect(32, 0, 16, 16))); panelImages.push_back(bitmap.GetSubBitmap(wxRect(48, 0, 16, 16))); panelImages.push_back(bitmap.GetSubBitmap(wxRect(64, 0, 16, 16))); panelImages.push_back(bitmap.GetSubBitmap(wxRect(80, 0, 16, 16))); panelImages.push_back(bitmap.GetSubBitmap(wxRect(96, 0, 16, 16))); panelImages.push_back(bitmap.GetSubBitmap(wxRect(112, 0, 16, 16))); BBBFrame* frame = new BBBFrame(); frame->Show(); return true; }
/*------------------------------------------------------ FLEXplorer implementation (The Application class) --------------------------------------------------------*/ bool FLEXplorer::OnInit() { wxLocale::AddCatalogLookupPathPrefix("."); wxLocale::AddCatalogLookupPathPrefix("./locale"); m_locale.Init(); m_locale.AddCatalog("flexemu"); ReadDefaultOptions(); SetAppName(_("FLEXplorer")); #ifdef wxUSE_DRAG_AND_DROP wxTheClipboard->UsePrimarySelection(); #endif int width = 820; // Create the main frame window FlexParentFrame *frame = new FlexParentFrame((wxFrame *)nullptr, -1, GetAppName(), wxPoint(-1, -1), wxSize(width, 700), wxDEFAULT_FRAME_STYLE | wxHSCROLL | wxVSCROLL); frame->Show(true); SetTopWindow(frame); for (int i = 1; i < argc; ++i) { if (!frame->OpenContainer(argv[i].ToUTF8())) { break; } } return true; }
bool App::OnInit() { bool ok = wxApp::OnInit(); if (ok) { wxLocaleHelper::Init(&m_locale, STE_APPNAME, m_cmdLine.m_lang); ::wxInitAllImageHandlers(); // Fill in the application information fields before creating wxConfig. SetVendorName(wxT("wxWidgets")); SetAppName(APP_NAME_SHORT); #if (wxVERSION_NUMBER >= 2900) SetAppDisplayName(APP_NAME_DISPLAY); #endif // Create a document manager wxDocManager* docManager = CreateDocManager(); // create the main frame window MainFrame* frame = new MainFrame(); ok = frame->Create(docManager, GetAppDisplayName()); if (ok) { frame->Show(); OpenDocuments(docManager); } else { delete frame; } } return ok; }
bool retcon::OnInit() { raii_set rs; //wxApp::OnInit(); //don't call this, it just calls the default command line processor SetAppName(appname); InitWxLogger(); rs.add([&]() { DeInitWxLogger(); }); ::wxInitAllImageHandlers(); srand((unsigned int) time(nullptr)); datadir = stdstrwx(wxStandardPaths::Get().GetUserDataDir()); cmdlineproc(argv, argc); if(terms_requested) return false; if(!globallogwindow) new log_window(nullptr, LOGT::GROUP_LOGWINDEF, false); if(!datadir.empty() && datadir.back() == '/') datadir.pop_back(); wxString wxdatadir = wxstrstd(datadir); if(!::wxDirExists(wxdatadir)) { ::wxMkdir(wxdatadir, 0700); } InitCFGDefaults(); SetTermSigHandler(); sm.InitMultiIOHandler(); rs.add([&]() { sm.DeInitMultiIOHandler(); }); bool res = DBC_Init(datadir + "/retcondb.sqlite3"); if(!res) return false; rs.add([&]() { DBC_DeInit(); }); if(terms_requested) return false; pool.reset(new ThreadPool::Pool(gc.threadpoollimit)); InitGlobalFilters(); RestoreWindowLayout(); if(mainframelist.empty()) { mainframe *mf = new mainframe( appversionname, wxPoint(50, 50), wxSize(450, 340)); if(alist.empty() && ad.tpanels.empty()) { //everything is empty, maybe new user //make 3 basic auto tpanels to make things more obvious auto flags = TPF::AUTO_ALLACCS | TPF::DELETEONWINCLOSE; auto tpt = tpanel::MkTPanel("", "", flags | TPF::AUTO_TW, 0); tpt->MkTPanelWin(mf, true); auto tpm = tpanel::MkTPanel("", "", flags | TPF::AUTO_MN, 0); tpm->MkTPanelWin(mf, false); auto tpd = tpanel::MkTPanel("", "", flags | TPF::AUTO_DM, 0); tpd->MkTPanelWin(mf, false); } } if(terms_requested) return false; mainframelist[0]->Show(true); for(auto it=alist.begin(); it!=alist.end(); ++it) { (*it)->Setup(); (*it)->CalcEnabled(); (*it)->Exec(); } if(terms_requested) return false; rs.cancel(); return true; }
bool EditorApplication::OnInit() { COCA_DEBUG_INFO( "EditorApplication::OnInit" ); SetAppName( "coca editor" ); // coca resource manager _resourceManager.createThread(); // frame EditorFrame* frame = new EditorFrame( 0, E_ID_EDITOR_FRAME, "coca editor", wxDefaultPosition, wxSize( 800, 600 ) ); SetTopWindow( frame ); readConfig(); loadPlugins(); createDocumentTemplates(); _documentManager.SetMaxDocsOpen( 1 ); frame->Show(); COCA_DEBUG_INFO( "EditorApplication::OnInit finished" ); return true; }
bool wxExTestApp::OnInit() { SetAppName("wxex-test-gui-report"); if (!wxExApp::OnInit()) { return false; } wxExFrameWithHistory *frame = new wxExFrameWithHistory(NULL, wxID_ANY, wxTheApp->GetAppDisplayName()); frame->Show(true); wxLog::SetActiveTarget(new wxLogStderr()); CppUnit::TextUi::TestRunner runner; wxExTestSuite* suite = new wxExTestSuite; runner.addTest(suite); runner.run(); // Return false, so test ends here. return false; }
LauncherApp::LauncherApp() : wxApp() { completed = false; SetAppName(_("IzPack launcher")); loadParams(); }
// 'Main program' equivalent: the program execution _T("starts") here bool ASSDrawApp::OnInit() { SetAppName(TITLE); // create the main application window ASSDrawFrame * assdrawframe = new ASSDrawFrame( this, TITLE, wxDefaultPosition, wxSize(640, 480) ); SetTopWindow(assdrawframe); return TRUE; }
bool App::OnInit() { ::fwWX::LoggerInitializer::initialize(); m_profile = ::fwRuntime::profile::getCurrentProfile(); SLM_ASSERT("Profile is not initialized", m_profile); #ifndef TDVPM_COMPLIANT m_locale = new wxLocale(); ::boost::filesystem::path pathLauncher; pathLauncher = ::boost::filesystem::current_path() / "share" / "launcher_0-1" / "locale" ; wxLocale::AddCatalogLookupPathPrefix( ::fwWX::std2wx( pathLauncher.string() )); m_locale->Init(GetUILanguage()); m_locale->AddCatalog(_T("launcher")); m_locale->AddCatalog(_T("runtime")); // Set the locale to C for all number of all application setlocale(LC_NUMERIC,"C"); #else setlocale(LC_ALL,"C"); #endif wxApp::OnInit(); std::string appName = m_profile->getName(); #ifndef TDVPM_COMPLIANT m_locale->AddCatalog(::fwWX::std2wx(appName), wxLANGUAGE_FRENCH, _T("utf-8")); #endif SetAppName( ::fwWX::std2wx(appName) ); std::string checkerPath = ::fwTools::os::getUserDataDir("IRCAD", appName, true); if (checkerPath.empty()) { checkerPath = ::fwTools::os::getUserDataDir("IRCAD", "", true); } if (checkerPath.empty()) { checkerPath = ::fwTools::os::getUserDataDir("", "", true); } SLM_ASSERT("Unable to find user's data dir.", !checkerPath.empty()); m_checker = new wxSingleInstanceChecker(); if (m_profile->getCheckSingleInstance()) { m_checker->Create( ::fwWX::std2wx(appName) + _(".pid"), ::fwWX::std2wx(checkerPath)); if ( m_checker->IsAnotherRunning() ) { wxLogError(_("Another " + ::fwWX::std2wx(appName) + _(" instance is already running, aborting."))); return false; } } // Initialize root object : root object, views, ... //::fwServices::RootManager::initializeRootObject(); return TRUE; }
App::App() { SetAppName( _("launcher") ); #ifdef __MACOSX__ ProcessSerialNumber PSN; GetCurrentProcess(&PSN); TransformProcessType(&PSN,kProcessTransformToForegroundApplication); #endif }
bool MyApp::OnInit() { SetVendorName(_T("Free world")); SetAppName(_T("wxEdit")); MyFrame *frame = new MyFrame( NULL, wxID_ANY, _T("wxEdit"), wxPoint(20,20), wxSize(500,340) ); frame->Show( true ); return true; }
/*!*********************************************************************** @Function OsInit @description Initialisation for OS-specific code. *************************************************************************/ void PVRShellInit::OsInit() { XInitThreads(); // set values to negative to mark that these are default values m_pShell->m_pShellData->nShellDimX = -240; m_pShell->m_pShellData->nShellDimY = -320; m_X11Display = NULL; m_X11Visual = NULL; // Pixmap support: init variables to 0 m_X11Pixmap = BadValue; /* Construct the binary path for GetReadPath() and GetWritePath() */ // Get PID (Process ID) pid_t ourPid = getpid(); char *pszExePath, pszSrcLink[64]; int len = 64; int res; sprintf(pszSrcLink, "/proc/%d/exe", ourPid); pszExePath = 0; do { len *= 2; delete[] pszExePath; pszExePath = new char[len]; res = readlink(pszSrcLink, pszExePath, len); if(res < 0) { m_pShell->PVRShellOutputDebug("Warning Readlink %s failed. The application name, read path and write path have not been set.\n", pszExePath); break; } } while(res >= len); if(res >= 0) { pszExePath[res] = '\0'; // Null-terminate readlink's result SetReadPath(pszExePath); SetWritePath(pszExePath); SetAppName(pszExePath); } delete[] pszExePath; m_u32ButtonState = 0; gettimeofday(&m_StartTime,NULL); }
UpdaterApp::UpdaterApp(): m_version( _T("-1") ), m_updater_window( 0 ) { SetAppName( _T("springlobby_updater") ); const std::string filename = STD_STRING(wxPathOnly( wxStandardPaths::Get().GetExecutablePath() ) + wxFileName::GetPathSeparator() + _T("update.log") ).c_str(); m_logstream_target = new std::ofstream(filename); if ( (!m_logstream_target->good()) || (!m_logstream_target->is_open() )) { printf("Error opening %s\n", filename.c_str()); } }
// 'Main program' equivalent: the program execution "starts" here bool MyApp::OnInit() { wxInitAllImageHandlers(); wxBitmap splashbitmap; if (splashbitmap.LoadFile("/opt/extras.ubuntu.com/azpazeta/media/splash.png", wxBITMAP_TYPE_PNG)) { wxSplashScreen* splash = new wxSplashScreen(splashbitmap, wxSPLASH_CENTRE_ON_SCREEN|wxSPLASH_TIMEOUT, 6000, NULL, -1, wxDefaultPosition, wxSize(400,400), wxSIMPLE_BORDER|wxSTAY_ON_TOP); } wxYield(); //ChrTaskBarIcon* icon = new ChrTaskBarIcon(); // call the base class initialization method, currently it only parses a // few common command-line options but it could be do more in the future if ( !wxApp::OnInit() ) return false; SetAppName(wxT("Azpazeta")); SetVendorName(wxT("Adrian Arroyo Calle para Divel")); if(wxApp::argc>=2){ fachada=1; wxString archivo=wxApp::argv[1].mb_str(); //int* newsavedlg=new SaveDialog::Cargar(wxString archivo); SaveDialog* newsavedlg=new SaveDialog(); newsavedlg->Cargar(archivo); newsavedlg->Destroy(); MyFrame *frame = new MyFrame("Azpazeta"); frame->Show(true); frame->Load(); frame->Paint(); //if(city==4){MyFrame::Stage4();} }else{ MyFrame *frame = new MyFrame("Azpazeta"); frame->Show(true); frame->OnJugar(); frame->Paint();} // create the main application window // and show it (the frames, unlike simple controls, are not shown when // created initially) // success: wxApp::OnRun() will be called which will enter the main message // loop and the application will run. If we returned false here, the // application would exit immediately. return true; }
/*------------------------------------------------------ flexemuSetup implementation (The Application class) --------------------------------------------------------*/ bool FlexemuSetup::OnInit() { #ifdef _UNICODE int i; std::vector<wxCharBuffer> args; auto mb_argv = std::unique_ptr<char *[]>(new char *[argc]); args.reserve(argc); for (i = 0; i < argc; i++) { args.push_back(argv[i].ToUTF8()); } for (i = 0; i < argc; i++) { mb_argv[i] = args[i].data(); } optionMan.InitOptions(&guiOptions, &options, argc, mb_argv.get()); #else optionMan.InitOptions(&guiOptions, &options, argc, argv); #endif wxLocale::AddCatalogLookupPathPrefix("."); wxLocale::AddCatalogLookupPathPrefix("./locale"); m_locale.Init(); m_locale.AddCatalog("flexemu"); optionMan.GetOptions(&guiOptions, &options); optionMan.GetEnvironmentOptions(&guiOptions, &options); SetAppName("FlexemuSetup"); SetExitOnFrameDelete(true); auto dialog = new FlexemuOptionsDialog(guiOptions, options, nullptr, -1, _("Flexemu Options Dialog"), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxSYSTEM_MENU | wxDIALOG_NO_PARENT | wxRESIZE_BORDER); SetTopWindow(dialog); if (dialog->ShowModal() == wxID_OK) { optionMan.WriteOptions(&guiOptions, &options); } dialog->Destroy(); return true; }
bool MidiLearnApp::OnInit() { SetAppName(wxT("MIDILearn")); //SetVendorName("MIDILearn"); MidiLearnFrame* frame = new MidiLearnFrame(0L, _("MIDILearn 0.5")); #ifdef __WXMSW__ frame->SetIcon(wxICON(MIDILEARNICON)); // To Set App Icon #endif frame->Show(); frame->Maximize(true); return true; }
bool App::OnInit() { SetAppName("syncodbcquery"); if (!wxExApp::OnInit()) { return false; } Frame *frame = new Frame(); frame->Show(true); return true; }
pulseTest::pulseTest() { SetAppName(wxT("OpenNX")); wxConfig *cfg; #ifdef __WXMSW__ cfg = new wxConfig(wxT("OpenNX"), wxT("InnoviData")); #else # ifdef __WXMAC__ cfg = new wxConfig(wxT("OpenNX"), wxT("InnoviData"), wxT("OpenNX Preferences"), wxT("OpenNX Preferences")); # else cfg = new wxConfig(wxT("OpenNX"), wxT("InnoviData"), wxT(".opennx"), wxT("opennx.conf")); # endif #endif wxConfigBase::Set(cfg); }
ApplicationContext::ApplicationContext(const String& name, Impl& impl) : quitting(false), errorHandler(nullptr), _resourcesDestroyed(false), _pImpl(impl) { NEX_NEW(LogManager()); SetAppName(name); SetProjectName(StringUtils::Default); SetProjectVersion(NEX_MAKE_VERSION(1, 0, 0)); // initialize the pools #ifdef NEX_DEBUG // add a default logger static Logger logger("Debug"); LogManager::Instance().AddNewLogger(&logger, true); #endif }
OyunApp::OyunApp() { // Some assorted wxWidgets initialization calls wxInitAllImageHandlers(); wxFileSystem::AddHandler(new wxArchiveFSHandler); // We need a true-color visual for drawing the plots // later on SetUseBestVisual(true, true); // Tell the wxApp who we are SetAppName(wxT("Oyun")); SetClassName(wxT("Oyun")); SetVendorName(wxT("OyunTeam")); }
/// This function is called during application start-up. virtual bool OnInit() { wxLog::SetActiveTarget(new wxLogStderr); SetAppName(_T("CryptoTE")); SetVendorName(_T("panthema.net")); // Setup locale to system default locale = new MyLocale(wxLANGUAGE_DEFAULT, wxLOCALE_CONV_ENCODING); // Load and initialize the catalog if (!locale->AddCatalogFromMemory(_T("cryptote"), cryptote_catalogs) || !locale->AddCatalogFromMemory(_T("wxstd"), wxstd_catalogs)) { // Could not load message catalog for system language, falling back // to English. delete locale; locale = new MyLocale(wxLANGUAGE_ENGLISH, wxLOCALE_CONV_ENCODING); if (!locale->AddCatalogFromMemory(_T("cryptote"), cryptote_catalogs) || !locale->AddCatalogFromMemory(_T("wxstd"), wxstd_catalogs)) { wxLogError(_T("Could not load message catalog for system or English language.")); return false; } } if (!wxApp::OnInit()) return false; wxImage::AddHandler(new wxPNGHandler()); wxLog::SetActiveTarget(NULL); // Create main window frame wmain = new WPassGen(NULL, true); SetTopWindow(wmain); // Load config presets and settings from registry/user-configfile wxConfigBase* cfg = wxConfigBase::Get(); wmain->LoadSettings(cfg); // Show Dialog wmain->Show(); return true; }
CaMuleExternalConnector::CaMuleExternalConnector() : m_configFile(NULL), m_port(-1), m_KeepQuiet(false), m_Verbose(false), m_interactive(false), m_commands(*this), m_ECClient(NULL), m_InputLine(NULL), m_NeedsConfigSave(false), m_locale(NULL), m_strFullVersion(NULL), m_strOSDescription(NULL) { SetAppName(wxT("aMule")); // Do not change! }
////////////// // Initialize bool KanaMemo::OnInit() { // Configuration SetAppName(_T("KanaMemo")); srand((unsigned)time(NULL)); // Get path GetFullPath(argv[0]); GetFolderName(); // Create the window GameWindow *window = new GameWindow(); window->Show(); // Initialization OK return true; }
// `Main program' equivalent, creating windows and returning main app frame bool MyApp::OnInit() { if ( !wxApp::OnInit() ) return false; // we're using wxConfig's "create-on-demand" feature: it will create the // config object when it's used for the first time. It has a number of // advantages compared with explicitly creating our wxConfig: // 1) we don't pay for it if we don't use it // 2) there is no danger to create it twice // application and vendor name are used by wxConfig to construct the name // of the config file/registry key and must be set before the first call // to Get() if you want to override the default values (the application // name is the name of the executable and the vendor name is the same) SetVendorName(wxT("wxWidgets")); SetAppName(wxT("conftest")); // not needed, it's the default value wxConfigBase *pConfig = wxConfigBase::Get(); // uncomment this to force writing back of the defaults for all values // if they're not present in the config - this can give the user an idea // of all possible settings for this program pConfig->SetRecordDefaults(); // or you could also write something like this: // wxFileConfig *pConfig = new wxFileConfig("conftest"); // wxConfigBase::Set(pConfig); // where you can also specify the file names explicitly if you wish. // Of course, calling Set() is optional and you only must do it if // you want to later retrieve this pointer with Get(). // create the main program window MyFrame *frame = new MyFrame; frame->Show(true); // use our config object... if ( pConfig->Read(wxT("/Controls/Check"), 1l) != 0 ) { wxMessageBox(wxT("You can disable this message box by unchecking\n") wxT("the checkbox in the main window (of course, a real\n") wxT("program would have a checkbox right here but we\n") wxT("keep it simple)"), wxT("Welcome to wxConfig demo"), wxICON_INFORMATION | wxOK); } return true; }
BOOL QApp::Run( HINSTANCE hInstance ) { SetAppName(NULL); // 设置工作目录 SetCurrentDirectory(quibase::GetModulePath()); // 配置应用程序 QConfig *pCfg = QUIGetConfig(); if ((NULL == pCfg) || !(pCfg->SetConfigPath(GetConfigPath()))) { // 这个时候还没有加载UI,不能使用QUI里面的MessageBox ::MessageBox(NULL,L"读取配置文件失败!", L"错误", MB_OK); ATLASSERT(FALSE); return FALSE; } // 配置UI管理器 if (!QUIMgr::GetInstance()->Startup()) { ::MessageBox(NULL,L"UI管理器启动失败!", L"错误", MB_OK); ATLASSERT(FALSE); return FALSE; } // 默认开启窗口的圆角和阴影效果 CWndShadow::Initialize(hInstance); SetTopFrameStyle(WS_QEX_ROUNDCONNER|WS_QEX_WNDSHADOW); // 主界面线程循环 QMessageLoop loop; AddMessageLoop(&loop); // 启动主界面 if (!InitRun() || (m_pMainWnd == NULL)) { return FALSE; } loop.Run(); RemoveMessageLoop(); UnInit(); QUIGetMainWnd(); return TRUE; }
bool wxExSampleApp::OnInit() { SetAppName("wxex-sample"); if (!wxExApp::OnInit()) { return false; } wxExSampleFrame *frame = new wxExSampleFrame(); frame->Show(true); wxLogStatus( "Locale: " + GetLocale().GetLocale() + " dir: " + GetCatalogDir()); return true; }