int App::Run(LPCTSTR /*lpstrCmdLine*/, int nCmdShow) { if (!ParseCommandLine()) return 0; CMessageLoop theLoop; _Module.AddMessageLoop(&theLoop); MainFrame wndMain; if (!m_cszFilename.IsEmpty()) wndMain.OpenFileAtStart(m_cszFilename); if (wndMain.CreateEx() == nullptr) { ATLTRACE(_T("Main window creation failed!\n")); return 0; } wndMain.ShowWindow(nCmdShow); int nRet = theLoop.Run(); _Module.RemoveMessageLoop(); return nRet; }
/// runs GeoTagTool main frame window int Run(LPTSTR /*lpstrCmdLine*/ = NULL, int nCmdShow = SW_SHOWDEFAULT) { CMessageLoop theLoop; _Module.AddMessageLoop(&theLoop); MainFrame wndMain; if (wndMain.CreateEx() == NULL) { ATLTRACE(_T("Main window creation failed!\n")); return 0; } wndMain.ShowWindow(nCmdShow); int ret = theLoop.Run(); _Module.RemoveMessageLoop(); return ret; }
static int Run(LPTSTR /*lpstrCmdLine*/ = NULL, int nCmdShow = SW_SHOWDEFAULT) { checkCommonControls(); CMessageLoop theLoop; _Module.AddMessageLoop(&theLoop); CEdit dummy; CWindow splash; CRect rc; rc.bottom = GetSystemMetrics(SM_CYFULLSCREEN); rc.top = (rc.bottom / 2) - 80; rc.right = GetSystemMetrics(SM_CXFULLSCREEN); rc.left = rc.right / 2 - 85; dummy.Create(NULL, rc, _T(APPNAME) _T(" ") _T(VERSIONSTRING), WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | ES_CENTER | ES_READONLY, WS_EX_STATICEDGE); splash.Create(_T("Static"), GetDesktopWindow(), splash.rcDefault, NULL, WS_POPUP | WS_VISIBLE | SS_USERITEM | WS_EX_TOOLWINDOW); splash.SetFont((HFONT)GetStockObject(DEFAULT_GUI_FONT)); HDC dc = splash.GetDC(); rc.right = rc.left + 350; rc.bottom = rc.top + 120; splash.ReleaseDC(dc); splash.HideCaret(); splash.SetWindowPos(NULL, &rc, SWP_SHOWWINDOW); splash.SetWindowLongPtr(GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(&splashCallback)); splash.CenterWindow(); sTitle = _T(VERSIONSTRING) _T(" ") _T(CONFIGURATION_TYPE); splash.SetFocus(); splash.RedrawWindow(); WinUtil::preInit(); startup(callBack, (void*)splash.m_hWnd); if(BOOLSETTING(PASSWD_PROTECT)) { PassDlg dlg; dlg.description = TSTRING(PASSWORD_DESC); dlg.title = TSTRING(PASSWORD_TITLE); dlg.ok = TSTRING(UNLOCK); if(dlg.DoModal(/*m_hWnd*/) == IDOK){ tstring tmp = dlg.line; if (tmp != Text::toT(Util::base64_decode(SETTING(PASSWORD)))) { ExitProcess(1); } } } splash.DestroyWindow(); dummy.DestroyWindow(); if(ResourceManager::getInstance()->isRTL()) { SetProcessDefaultLayout(LAYOUT_RTL); } MainFrame wndMain; rc = wndMain.rcDefault; if( (SETTING(MAIN_WINDOW_POS_X) != CW_USEDEFAULT) && (SETTING(MAIN_WINDOW_POS_Y) != CW_USEDEFAULT) && (SETTING(MAIN_WINDOW_SIZE_X) != CW_USEDEFAULT) && (SETTING(MAIN_WINDOW_SIZE_Y) != CW_USEDEFAULT) ) { rc.left = SETTING(MAIN_WINDOW_POS_X); rc.top = SETTING(MAIN_WINDOW_POS_Y); rc.right = rc.left + SETTING(MAIN_WINDOW_SIZE_X); rc.bottom = rc.top + SETTING(MAIN_WINDOW_SIZE_Y); // Now, let's ensure we have sane values here... if( (rc.left < 0 ) || (rc.top < 0) || (rc.right - rc.left < 10) || ((rc.bottom - rc.top) < 10) ) { rc = wndMain.rcDefault; } } int rtl = ResourceManager::getInstance()->isRTL() ? WS_EX_RTLREADING : 0; if(wndMain.CreateEx(NULL, rc, 0, rtl | WS_EX_APPWINDOW | WS_EX_WINDOWEDGE) == NULL) { ATLTRACE(_T("Main window creation failed!\n")); return 0; } if(BOOLSETTING(MINIMIZE_ON_STARTUP)) { wndMain.ShowWindow(SW_SHOWMINIMIZED); } else { wndMain.ShowWindow(((nCmdShow == SW_SHOWDEFAULT) || (nCmdShow == SW_SHOWNORMAL)) ? SETTING(MAIN_WINDOW_STATE) : nCmdShow); } int nRet = theLoop.Run(); _Module.RemoveMessageLoop(); dummy.Create(NULL, rc, _T(APPNAME) _T(" ") _T(VERSIONSTRING), WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | ES_CENTER | ES_READONLY, WS_EX_STATICEDGE); splash.Create(_T("Static"), GetDesktopWindow(), splash.rcDefault, NULL, WS_POPUP | WS_VISIBLE | SS_USERITEM | WS_EX_TOOLWINDOW); splash.SetFont((HFONT)GetStockObject(DEFAULT_GUI_FONT)); dc = splash.GetDC(); rc.right = rc.left + 350; rc.bottom = rc.top + 120; splash.ReleaseDC(dc); splash.HideCaret(); splash.SetWindowPos(NULL, &rc, SWP_SHOWWINDOW); splash.SetWindowLongPtr(GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(&splashCallback)); splash.CenterWindow(); sTitle = TSTRING(PROCESSING); splash.SetFocus(); splash.RedrawWindow(); shutdown(callBack, (void*)splash.m_hWnd); splash.DestroyWindow(); dummy.DestroyWindow(); return nRet; }
static int Run(LPTSTR /*lpstrCmdLine*/ = NULL, int nCmdShow = SW_SHOWDEFAULT) { checkCommonControls(); CMessageLoop theLoop; _Module.AddMessageLoop(&theLoop); SplashWindow splash(IDB_SPLASH); class PeersConfiguration : public StartupConfiguration, public FavoriteManagerInitializer { private: FavoriteHubEntry* findHub(FavoriteHubEntry::List& favoriteHubs, const string& server) const { if (!favoriteHubs.empty()) { for (FavoriteHubEntry::Iter i = favoriteHubs.begin(); i != favoriteHubs.end(); ++i) { FavoriteHubEntry* entry = *i; if (Util::stricmp(entry->getServer(), server) == 0) { return entry; } } const string fullServerName = "dchub://" + server; for (FavoriteHubEntry::Iter i = favoriteHubs.begin(); i != favoriteHubs.end(); ++i) { FavoriteHubEntry* entry = *i; if (Util::stricmp(entry->getServer(), fullServerName) == 0) { return entry; } } } return NULL; } void checkHub(FavoriteHubEntry::List& favoriteHubs, const string& server, const tstring& name, const tstring& description, bool forceAutoConnect, int mode) const { FavoriteHubEntry* e = findHub(favoriteHubs, server); if (e == NULL) { e = new FavoriteHubEntry(); e->setName(Text::fromT(name)); e->setConnect(true); e->setDescription(Text::fromT(description)); e->setNick(Util::emptyString); e->setPassword(Util::emptyString); e->setServer(server); e->setUserDescription(Util::emptyString); e->setMode(mode); favoriteHubs.push_back(e); } else if (forceAutoConnect) { #ifndef _DEBUG e->setConnect(true); #endif } } public: virtual void onLoad(int& version, FavoriteHubEntry::List& favoriteHubs) const { checkHub(favoriteHubs, PeersUtils::PEERS_HUB, _T("Пирс"), _T("Файлообменная сеть Электронного города"), true, 0); // Always set mode auto for PEERS_HUB FavoriteHubEntry *peers = findHub(favoriteHubs, PeersUtils::PEERS_HUB); peers->setMode(0); if (version < BUILDID) { version = BUILDID; } } }; PeersConfiguration configuration; configuration.m_clientId = APPNAME " V:" VERSIONSTRING; configuration.m_queueManagerVersion = VERSIONSTRING; configuration.m_settingsManagerVersion = Util::toString(BUILDID); configuration.m_mainHub = PeersUtils::PEERS_HUB; if (!g_DisableSplash) { splash.init(); Application::startup(splash.getCallback(), &configuration); } else { class NOPCallback : public ProgressCallback { public: virtual void showMessage(const tstring&) { } } nop; Application::startup(&nop, &configuration); } PreviewApplication::List lst = FavoriteManager::getInstance()->getPreviewApps(); if (lst.empty()) { FavoriteManager::getInstance()->addPreviewApp("VLC", ".\\VLC\\VLCPortable.exe", "%[file]", "avi;divx;mpg;mpeg"); } else if (lst.size() == 1 && (Util::stricmp(lst[0]->getApplication(),"AVIPreview.exe") == 0 || Util::stricmp(lst[0]->getApplication(),".\\AVIPreview.exe") == 0)) { PreviewApplication fixed(*lst[0]); fixed.setName("VLC"); fixed.setApplication(".\\VLC\\VLCPortable.exe"); FavoriteManager::getInstance()->updatePreviewApp(0, fixed); } if (BOOLSETTING(DOWNLOAD_DIRECTORY_SHORTCUT)) { const string path = SETTING(DOWNLOAD_DIRECTORY); File::ensureDirectory(path); Shortcut::createDesktopShortcut(Text::toT(path), _T("Загрузки Peers")); } /* if (Util::readRegistryBoolean(_T("SiteShortcut"), true)) { TCHAR path[MAX_PATH]; GetModuleFileName(NULL, path, MAX_PATH); int iconIndex = 0; for (int i = 0; i < IDI_SITE_SHORTCUT; ++i) { if (LoadIcon(_Module.GetResourceInstance(), MAKEINTRESOURCE(i)) != NULL) { ++iconIndex; } } Shortcut::createInternetShortcut(_T("http://www.cn.ru/"), _T("Портал cn.ru"), path, iconIndex); } */ ChatBot::newInstance(); // !SMT!-CB if(ResourceManager::getInstance()->isRTL()) { SetProcessDefaultLayout(LAYOUT_RTL); } int nRet; {// !SMT!-fix this will ensure that GUI (wndMain) destroyed before client library shutdown (gui objects may call lib) MainFrame wndMain; CRect rc = wndMain.rcDefault; if( (SETTING(MAIN_WINDOW_POS_X) != CW_USEDEFAULT) && (SETTING(MAIN_WINDOW_POS_Y) != CW_USEDEFAULT) && (SETTING(MAIN_WINDOW_SIZE_X) != CW_USEDEFAULT) && (SETTING(MAIN_WINDOW_SIZE_Y) != CW_USEDEFAULT) ) { rc.left = SETTING(MAIN_WINDOW_POS_X); rc.top = SETTING(MAIN_WINDOW_POS_Y); rc.right = rc.left + SETTING(MAIN_WINDOW_SIZE_X); rc.bottom = rc.top + SETTING(MAIN_WINDOW_SIZE_Y); // Now, let's ensure we have sane values here... if( (rc.left < 0 ) || (rc.top < 0) || (rc.right - rc.left < 10) || ((rc.bottom - rc.top) < 10) ) { rc = wndMain.rcDefault; } } int rtl = ResourceManager::getInstance()->isRTL() ? WS_EX_RTLREADING : 0; if(wndMain.CreateEx(NULL, rc, 0, rtl | WS_EX_APPWINDOW | WS_EX_WINDOWEDGE) == NULL) { ATLTRACE(_T("Main window creation failed!\n")); return 0; } // Backup & Archive Settings at Starup!!! Written by Drakon. if (BOOLSETTING(STARTUP_BACKUP)) { tstring bkcmd = Text::toT(Util::getDataPath()) + _T("BackUp/BackupProfile.bat"); ShellExecute(NULL, NULL, bkcmd.c_str(), NULL, NULL, SW_HIDE); } // End of BackUp... DestroyAndDetachWindow(splash); if(nCmdShow == SW_SHOWMINIMIZED || BOOLSETTING(MINIMIZE_ON_STARTUP)) { wndMain.ShowWindow(SW_SHOWMINIMIZED); } else { wndMain.ShowWindow(((nCmdShow == SW_SHOWDEFAULT) || (nCmdShow == SW_SHOWNORMAL)) ? SETTING(MAIN_WINDOW_STATE) : nCmdShow); } nRet = theLoop.Run(); ChatBot::deleteInstance(); // !SMT!-CB _Module.RemoveMessageLoop(); } // !SMT!-fix Application::shutdown(); return nRet; }