Example #1
0
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;
}
Example #2
0
BOOL WindowsApp::InitInstance()
{
	// Standard initialization

#if _MFC_VER < 0x0700
#ifdef _AFXDLL
	Enable3dControls();			// Call this when using MFC in a shared DLL
#else
	Enable3dControlsStatic();	// Call this when linking to MFC statically
#endif
#endif

	// Change the registry key under which our settings are stored.
	SetRegistryKey(_T("Local AppWizard-Generated Applications"));

	// Qt initialization
	QMfcApp::instance(this);


	MainFrame* pFrame = new MainFrame;
	m_pMainWnd = pFrame;

	// create and load the frame with its resources

	pFrame->LoadFrame(IDR_MAINFRAME,
		WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, NULL,
		NULL);



	pFrame->ShowWindow(SW_SHOW);
	pFrame->UpdateWindow();

	return true;
}
Example #3
0
int WINAPI _tWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPTSTR lpCmdLine, _In_ int nShowCmd)
{
	HRESULT Hr = ::CoInitialize(NULL);
	if (FAILED(Hr)) return 0;

	CPaintManagerUI::SetInstance(hInstance);
	CPaintManagerUI::SetResourcePath(CPaintManagerUI::GetInstancePath() + _T("skin\\hitools\\"));

	MainFrame* pMainFrame = new MainFrame;
	if (pMainFrame == NULL) return 0;
	pMainFrame->Create(NULL, NULL, UI_WNDSTYLE_DIALOG, 0);
	pMainFrame->CenterWindow();
	pMainFrame->ShowWindow(true);
	CPaintManagerUI::MessageLoop();

	::CoUninitialize();
	return 0;
}
Example #4
0
/// 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;
}
BOOL CCrtdApp::InitInstance()
	{
	// CG: The following block was added by the Splash Screen component.
\
	{
\
		CCommandLineInfo cmdInfo;
\
		ParseCommandLine(cmdInfo);
\

\
//		CSplashWnd::EnableSplashScreen(cmdInfo.m_bShowSplash);
\
	}
	// CG: The following block was inserted by 'Status Bar' component.
	{
		//Set up date and time defaults so they're the same as system defaults
		setlocale(LC_ALL, "");
	}

	if (!AfxSocketInit())
	{
		AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
		return FALSE;
	}

	// Standard initialization
	// If you are not using these features and wish to reduce the size
	//  of your final executable, you should remove from the following
	//  the specific initialization routines you do not need.

#ifdef _AFXDLL
	Enable3dControls();			// Call this when using MFC in a shared DLL
#else
	Enable3dControlsStatic();	// Call this when linking to MFC statically
#endif

	// Change the registry key under which our settings are stored.
	// You should modify this string to be something appropriate
	// such as the name of your company or organization.
//	SetRegistryKey(_T("Local AppWizard-Generated Applications"));

//	LoadStdProfileSettings(0);  // Load standard INI file options (including MRU)

	LoadGlobalParamFromIni();


	// Register the application's document templates.  Document templates
	//  serve as the connection between documents, frame windows and views.

/*	CSingleDocTemplate* pDocTemplate;
	pDocTemplate = new CSingleDocTemplate(
		IDR_MAINFRAME,
		RUNTIME_CLASS(CCrtdDoc),
		RUNTIME_CLASS(CMainFrame),       // main SDI frame window
		RUNTIME_CLASS(CCrtdView));
	AddDocTemplate(pDocTemplate);*/

	// Parse command line for standard shell commands, DDE, file open
//	CCommandLineInfo cmdInfo;
//	ParseCommandLine(cmdInfo);

	HBRUSH hBrush=(HBRUSH)GetStockObject(WHITE_BRUSH);
	HCURSOR hCur=(HCURSOR)::LoadCursor(NULL,IDC_ARROW);
	HICON hIco=LoadIcon(MAKEINTRESOURCE(IDR_MAINFRAME));
	LPCTSTR lpClass=AfxRegisterWndClass(CS_DBLCLKS|CS_VREDRAW,hCur,hBrush,hIco);

	MainFrame *pMainFrame = new MainFrame;
	RECT rcM = { 0,0,100,100 };
	::GetWindowRect(::GetDesktopWindow(),&rcM);
	if (!pMainFrame->Create(lpClass,"Continuous Real-Time Display", WS_VISIBLE | WS_OVERLAPPEDWINDOW,rcM,NULL,NULL))	return FALSE;

	m_pMainWnd = pMainFrame;
	pMainFrame->ShowWindow(m_nCmdShow|SW_SHOWMAXIMIZED);
	pMainFrame->UpdateWindow();


	return TRUE;
	}
Example #6
0
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;
}
Example #7
0
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;
}