int WINAPI WinMain(HINSTANCE hinst, HINSTANCE hprev, LPSTR cmdline, int show) { MainDialog dlg; WTL::CMessageLoop loop; int ret = 1; CoInitialize(NULL); _Module.Init(NULL, hinst); _Module.AddMessageLoop(&loop); if(dlg.Create(NULL)) { dlg.ShowWindow(show); ret = loop.Run(); } _Module.RemoveMessageLoop(); _Module.Term(); CoUninitialize(); return ret; }
int Run(LPTSTR /*lpstrCmdLine*/ = NULL, int nCmdShow = SW_SHOWDEFAULT) { WTL::CMessageLoop theLoop; _Module.AddMessageLoop(&theLoop); CMainFrame wndMain; if(wndMain.CreateEx() == NULL) { ATLTRACE(_T("Main window creation failed!\n")); return 0; } wndMain.ShowWindow(nCmdShow); int nRet = theLoop.Run(); _Module.RemoveMessageLoop(); return nRet; }
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR lpstrCmdLine, int nCmdShow) { HRESULT hRes = ::CoInitialize(NULL); // If you are running on NT 4.0 or higher you can use the following call instead to // make the EXE free threaded. This means that calls come in on a random RPC thread. // HRESULT hRes = ::CoInitializeEx(NULL, COINIT_MULTITHREADED); ATLASSERT(SUCCEEDED(hRes)); // this resolves ATL window thunking problem when Microsoft Layer for Unicode (MSLU) is used ::DefWindowProc(NULL, 0, 0, 0L); WTL::AtlInitCommonControls(ICC_BAR_CLASSES); // add flags to support other controls hRes = _Module.Init(NULL, hInstance); ATLASSERT(SUCCEEDED(hRes)); int nRet = Run(lpstrCmdLine, nCmdShow); _Module.Term(); ::CoUninitialize(); return nRet; }
int CQueryBuilderApp::ExitInstance() { //TODO: handle additional resources you may have added if (m_hMDIMenu != NULL) FreeResource(m_hMDIMenu); if (m_hMDIAccel != NULL) FreeResource(m_hMDIAccel); if (hGrid) ::FreeLibrary(hGrid); // Terminate ATL _Module.Term(); int retVal = CWinAppEx::ExitInstance(); return retVal; }
LRESULT MainDialog::OnInitDialog(HWND hwnd, LPARAM lp) { WTL::CMessageLoop *loop = _Module.GetMessageLoop(); loop->AddMessageFilter(this); DragAcceptFiles(*this, true); SetIcon(WTL::AtlLoadIconImage(IDI_MEDIAWIKI, 0, GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON))); SetIcon(WTL::AtlLoadIconImage(IDI_MEDIAWIKI, 0, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON)), false); EnableDlgItem(IDC_OPT_COMPRESS_FULL, false); EnableDlgItem(IDC_START, false); DoDataExchange(); m_progress.SetRange(0, 100); m_waitcursor.LoadOEMCursor(IDC_WAIT); return false; }
BOOL CQueryBuilderApp::InitInstance() { HRESULT hRes = _Module.Init(NULL, m_hInstance); ATLASSERT(SUCCEEDED(hRes)); #ifndef _DEBUG // Setup exception handler BT_SetAppName(_T("ECL IDE")); BT_SetSupportEMail(_T("*****@*****.**")); BT_SetFlags(BTF_DETAILEDMODE | BTF_EDITMAIL | BTF_ATTACHREPORT); BT_SetSupportURL(_T("http://hpccsystems.com/support")); // = BugTrapServer =========================================== //BT_SetSupportServer(_T("localhost"), 9999); // - or - //BT_SetSupportServer(_T("127.0.0.1"), 9999); // = BugTrapWebServer ======================================== //BT_SetSupportServer(_T("http://localhost/BugTrapWebServer/RequestHandler.aspx"), BUGTRAP_HTTP_PORT); // required since VS 2005 SP1 BT_InstallSehFilter(); #endif // InitCommonControlsEx() is required on Windows XP if an application // manifest specifies use of ComCtl32.dll version 6 or later to enable // visual styles. Otherwise, any window creation will fail. INITCOMMONCONTROLSEX InitCtrls; InitCtrls.dwSize = sizeof(InitCtrls); // Set this to include all the common control classes you want to use // in your application. InitCtrls.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&InitCtrls); CWinAppEx::InitInstance(); // Initialize OLE libraries if (!AfxOleInit()) { AfxMessageBox(IDP_OLE_INIT_FAILED); return FALSE; } AfxEnableControlContainer(); // 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 // Change the registry key under which our settings are stored // TODO: You should modify this string to be something appropriate // such as the name of your company or organization HINSTANCE hInstanceResources = ::LoadLibrary(_T("en_us.dll")); _Module.SetResourceInstance(hInstanceResources); AfxSetResourceHandle(hInstanceResources); SetApplicationName(_T("eclide.exe")); boost::filesystem::path iniPath; GetIniPath(iniPath); CComPtr<IConfig> ini = CreateIConfig(QUERYBUILDER_INI, iniPath); CComPtr<IConfig> config = CreateIConfig(QUERYBUILDER_CFG); if (!hGrid) hGrid = ::LoadLibrary(SGRID::CGridCtrl::GetLibraryName()); std::_tstring majorVersion; GetAppMajorVersion(majorVersion); SetRegistryKey((boost::_tformat(_T("HPCC Systems\\Version%1%")) % majorVersion).str().c_str()); LoadStdProfileSettings(0); // Load standard INI file options InitContextMenuManager(); InitKeyboardManager(); InitTooltipManager(); CMFCToolTipInfo ttParams; ttParams.m_bVislManagerTheme = TRUE; theApp.GetTooltipManager()->SetTooltipParams(AFX_TOOLTIP_TYPE_ALL, RUNTIME_CLASS(CMFCToolTipCtrl), &ttParams); theApp.EnableTaskbarInteraction(false); //const TCHAR * path = _tgetenv(_T("PATH")); //if (path) //{ // const TCHAR * hpccbin = _tgetenv(_T("HPCCBIN")); // if (hpccbin) // { // boost::filesystem::wpath eclccPath = hpccbin; // eclccPath /= _T("eclcc.exe"); // if (boost::filesystem::exists(eclccPath)) // { // std::_tstring envVar = _T("PATH="); // envVar += hpccbin; // envVar += _T(";"); // envVar += path; // _tputenv(envVar.c_str()); // ini->Set(GLOBAL_COMPILER_LOCATION, eclccPath.native_file_string()); // } // boost::filesystem::wpath stdLibPath = hpccbin; // stdLibPath /= _T("ecllib"); // if (boost::filesystem::exists(stdLibPath)) // { // ini->Set(GLOBAL_COMPILER_STDLIB, stdLibPath.native_file_string()); // } // } //} // To create the main window, this code creates a new frame window // object and then sets it as the application's main window object CMDIFrameWnd* pFrame = new CMainFrame; if (!pFrame) return FALSE; m_pMainWnd = pFrame; // create main MDI frame window if (!pFrame->LoadFrame(IDR_MAINFRAME)) return FALSE; // try to load shared MDI menus and accelerator table //TODO: add additional member variables and load calls for // additional menu types your application may need //HINSTANCE hInst = AfxGetResourceHandle(); //m_hMDIMenu = ::LoadMenu(hInst, MAKEINTRESOURCE(IDR_QueryBuilderTYPE)); //m_hMDIAccel = ::LoadAccelerators(hInst, MAKEINTRESOURCE(IDR_QueryBuilderTYPE)); // The main window has been initialized, so show and update it pFrame->ShowWindow(m_nCmdShow); pFrame->UpdateWindow(); return TRUE; }