void CMsgSignalDBWnd::OnClose() { // Get active frame CMainFrame *pFrame = (CMainFrame*)AfxGetApp()->m_pMainWnd; if (pFrame != NULL) { // Get appropriate data structure CMsgSignal** ppTempMsgSg = NULL; ppTempMsgSg = (CMsgSignal**)(m_sDbParams.m_ppvActiveDB); //CMsgSgDetView* podMsgSg = pFrame->podGetMsgSgDetView(m_sDbParams.m_eBus); if ((*ppTempMsgSg)->bGetModifiedFlag() == FALSE) { UINT bRetVal = AfxMessageBox(ASK_SAVE_PROMPT, MB_YESNO|MB_ICONQUESTION); if ( bRetVal == IDYES ) { //save the database modificatins. vSaveModifiedDBs(ppTempMsgSg); } else if( bRetVal == IDNO ) { // if this is new database // then delete the memory and the file itself if ( pFrame->vGetNewDatabaseFlag()) { // This file is no longer required CFile::Remove( m_sDbParams.m_omDBPath ); pFrame->vSetNewDatabaseFlag(FALSE); } } } else { // If the user just creates new database, // and closes the window // delete the file if ( pFrame->vGetNewDatabaseFlag() ) { // This file is no longer required CFile::Remove( m_sDbParams.m_omDBPath ); pFrame->vSetNewDatabaseFlag(FALSE); } } // delete previously allocated memory if any (*ppTempMsgSg)->bDeAllocateMemoryInactive(); // Reset the flag to indicate the closing of database window if (m_sDbParams.m_eBus == CAN) { CFlags* pFlags = theApp.pouGetFlagsPtr(); if ( pFlags != NULL ) { pFlags->vSetFlagStatus( DBOPEN, FALSE ); } } else if (m_sDbParams.m_eBus == J1939) { CMsgSignalDBWnd::sm_bValidJ1939Wnd = FALSE; } CMDIChildWnd::OnClose(); } }
void CMsgSignalDBWnd::OnClose() { // Get active frame CMainFrame* pFrame = static_cast<CMainFrame*> (AfxGetApp()->m_pMainWnd); if (pFrame != NULL) { // Get appropriate data structure CMsgSignal** ppTempMsgSg = NULL; ppTempMsgSg = (CMsgSignal**)(m_sDbParams.m_ppvActiveDB); //CMsgSgDetView* podMsgSg = pFrame->podGetMsgSgDetView(m_sDbParams.m_eBus); if ((*ppTempMsgSg)->bGetModifiedFlag() == FALSE) { UINT bRetVal = AfxMessageBox(ASK_SAVE_PROMPT, MB_YESNO|MB_ICONQUESTION); if ( bRetVal == IDYES ) { (*ppTempMsgSg)-> bWriteIntoDatabaseFileFromDataStructure( m_sDbParams.m_omDBPath ); if ((*ppTempMsgSg)->bGetDBAcitveFlagStatus() == TRUE) { pFrame->vPostMsgToSendMsgDlg(m_sDbParams.m_eBus); } // Check if the modified file is being loaded or not. //If yes then prompt the user whether he wants to //import it or not. CStringArray omImportedDBNames; CMsgSignal** m_ppsMSTemp = (CMsgSignal**)(m_sDbParams.m_ppvImportedDBs); if ((*m_ppsMSTemp) != NULL) { (*m_ppsMSTemp)->vGetDataBaseNames(&omImportedDBNames); for (INT nDBCount = 0; nDBCount < omImportedDBNames.GetSize(); nDBCount++) { if (m_sDbParams.m_omDBPath == omImportedDBNames.GetAt(nDBCount)) { CString omText; omText.Format( _T("File \"%s\" has been modified which is currently being loaded.\nDo you want to re-import it to reflect the changes?"), m_sDbParams.m_omDBPath); if (MessageBox(omText, "", MB_ICONQUESTION | MB_YESNO) == IDYES) { switch (m_sDbParams.m_eBus) { case CAN: { pFrame->dLoadDataBaseFile(m_sDbParams.m_omDBPath, FALSE); } break; case J1939: { pFrame->dLoadJ1939DBFile(m_sDbParams.m_omDBPath, FALSE); } break; }; } } } } //Checking ends // Set the modified flag as saved if (NULL != (*ppTempMsgSg)) { (*ppTempMsgSg)->vSetModifiedFlag(TRUE); } } else if( bRetVal == IDNO ) { // if this is new database // then delete the memory and the file itself if ( pFrame->vGetNewDatabaseFlag()) { // This file is no longer required CFile::Remove( m_sDbParams.m_omDBPath ); pFrame->vSetNewDatabaseFlag(FALSE); } } } else { // If the user just creates new database, // and closes the window // delete the file if ( pFrame->vGetNewDatabaseFlag() ) { // This file is no longer required CFile::Remove( m_sDbParams.m_omDBPath ); pFrame->vSetNewDatabaseFlag(FALSE); } } // delete previously allocated memory if any (*ppTempMsgSg)->bDeAllocateMemoryInactive(); // Reset the flag to indicate the closing of database window if (m_sDbParams.m_eBus == CAN) { CFlags* pFlags = theApp.pouGetFlagsPtr(); if ( pFlags != NULL ) { pFlags->vSetFlagStatus( DBOPEN, FALSE ); } } else if (m_sDbParams.m_eBus == J1939) { CMsgSignalDBWnd::sm_bValidJ1939Wnd = FALSE; } CMDIChildWnd::OnClose(); } }
BOOL CCANMonitorApp::InitInstance() { // Begin of Multiple Language support if ( CMultiLanguage::m_nLocales <= 0 ) // Not detected yet { CMultiLanguage::DetectLangID(); // Detect language as user locale CMultiLanguage::DetectUILanguage(); // Detect language in MUI OS } TCHAR szModuleFileName[MAX_PATH]; // Get Module File Name and path int ret = ::GetModuleFileName(theApp.m_hInstance, szModuleFileName, MAX_PATH); if ( ret == 0 || ret == MAX_PATH ) { ASSERT(false); } // Load resource-only language DLL. It will use the languages // detected above, take first available language, // or you can specify another language as second parameter to // LoadLangResourceDLL. And try that first. ghLangInst = CMultiLanguage::LoadLangResourceDLL( szModuleFileName ); if (ghLangInst) { AfxSetResourceHandle( ghLangInst ); } // End of Multiple Language support INITCOMMONCONTROLSEX InitCtrls; InitCtrls.dwSize = sizeof(InitCtrls); InitCtrls.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&InitCtrls); //InitCommonControls(); // START CHANGES MADE FOR AUTOMATION CWinAppEx::InitInstance(); // Initialize OLE libraries if (!AfxOleInit()) { AfxMessageBox(_("Fail to Intilaize OLE")); return FALSE; } //CoInitializeEx(nullptr, COINIT_MULTITHREADED ); CBusmasterDump dump("BUSMASTER"); // END CHANGES MADE FOR AUTOMATION // Enable OLE/ActiveX objects support AfxEnableControlContainer(); InitContextMenuManager(); InitKeyboardManager(); InitTooltipManager(); CMFCToolTipInfo ttParams; ttParams.m_bVislManagerTheme = TRUE; theApp.GetTooltipManager()->SetTooltipParams(AFX_TOOLTIP_TYPE_ALL, RUNTIME_CLASS(CMFCToolTipCtrl), &ttParams); // 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. DEBUG //#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. // TODO: You should modify this string to be something appropriate // such as the name of your company or organization. SetRegistryKey("RBEI-ETAS\\BUSMASTER_v3.1.0"); // START CHANGES MADE FOR AUTOMATION COleTemplateServer::RegisterAll(); // END CHANGES MADE FOR AUTOMATION //LoadStdProfileSettings(0); // Load standard INI file options (including MRU) // Enable drag/drop open // Enable DDE Execute open //EnableShellOpen(); //RegisterShellFileTypes(TRUE); // Display splash screen CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); short shRegServer = -1; short shUnRegServer = -1; if (__argc > 1) { shRegServer = (short) strcmpi(__targv[1],"/regserver"); shUnRegServer = (short) strcmpi(__targv[1],"/unregserver"); } // Don't display a new MDI child window during startup if (cmdInfo.m_nShellCommand == CCommandLineInfo::FileNew || cmdInfo.m_nShellCommand == CCommandLineInfo::FileOpen) { cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing; } // START CHANGES MADE FOR AUTOMATION if (cmdInfo.m_bRunEmbedded || cmdInfo.m_bRunAutomated) { m_bFromAutomation = TRUE; // return TRUE; } else if (cmdInfo.m_nShellCommand == CCommandLineInfo::AppUnregister) { AfxOleUnregisterTypeLib(LIBID_CAN_MonitorApp); } else { COleObjectFactory::UpdateRegistryAll(); AfxOleRegisterTypeLib(AfxGetInstanceHandle(), LIBID_CAN_MonitorApp); } if ( shRegServer == 0 || shUnRegServer == 0 ) //If command line argument match { return FALSE; } if (!m_bFromAutomation) { CSplashScreen::ActivateSplashScreen(cmdInfo.m_bShowSplash); } // Allocate memory for CFlags m_pouFlags = &(CFlags::ouGetFlagObj()); // create main MDI Frame window CMainFrame* pMainFrame = new CMainFrame; if ( pMainFrame == nullptr ) { ::PostQuitMessage(0); return FALSE; } if (!pMainFrame->LoadFrame(IDR_MAINFRAME)) { return FALSE; } m_pMainWnd = pMainFrame; // Dispatch commands specified on the command line if (!ProcessShellCommand(cmdInfo)) { return FALSE; } m_pMainWnd->DragAcceptFiles(); // show main frame m_pMainWnd->ShowWindow(m_nCmdShow); m_pMainWnd->UpdateWindow(); //// Create message window if(m_pouMsgSgInactive == nullptr ) { if(m_bFromAutomation==FALSE) MessageBox(nullptr,_(MSG_MEMORY_CONSTRAINT), "BUSMASTER", MB_OK|MB_ICONINFORMATION); ::PostQuitMessage(0); } BOOL bResult; bResult = m_aomState[UI_THREAD].SetEvent(); // get the information of the last used configuration file.. // initialize the flag that indicates if the configuratin file has been // loaded.. m_bIsConfigFileLoaded = FALSE; CString ostrCfgFilename = ""; // If user has double click the .cfg file then assign that file name else // read from registry. if(cmdInfo.m_strFileName.IsEmpty() == TRUE) { //ostrCfgFilename = // GetProfileString(_(SECTION), defCONFIGFILENAME, ""); DWORD dwVal; bReadFromRegistry(HKEY_CURRENT_USER, _(SECTION), defCONFIGFILENAME, REG_SZ, ostrCfgFilename, dwVal); } else { ostrCfgFilename = cmdInfo.m_strFileName; } BOOL bValidDir = TRUE; CFileFind findFile; if (!ostrCfgFilename.IsEmpty() && !findFile.FindFile(ostrCfgFilename)) { DWORD dwErr = GetLastError(); CString strMsg = ""; if (dwErr == ERROR_PATH_NOT_FOUND) { bValidDir = FALSE; FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, nullptr, dwErr, 0, strMsg.GetBuffer(1024), 1024, nullptr); AfxMessageBox(strMsg); } } if(ostrCfgFilename.IsEmpty() == FALSE && bValidDir == TRUE) { bInitialiseConfiguration(m_bFromAutomation); // load the configuration information if(pMainFrame->nLoadConfigFile(ostrCfgFilename) != defCONFIG_FILE_SUCCESS) { //m_oConfigDetails.vInitDefaultValues(); m_ostrConfigFilename = ""; } else { m_ostrConfigFilename = ostrCfgFilename; } m_bIsConfigFileLoaded = TRUE; //build all nodes -- Node Simulation. pMainFrame->BuildAllNodes(); } else { BOOL bReturn = bInitialiseConfiguration(m_bFromAutomation); if(bReturn == FALSE ) { ::PostQuitMessage(0); } // Load a default database file //CStringArray omDatabaseArray; //CString omSampleDatabasePath; //omSampleDatabasePath.Format("%s\\Samples\\SampleDB.dbf",m_acApplicationDirectory); //DWORD dRetVal = pMainFrame->dLoadDataBaseFile(omSampleDatabasePath, FALSE); //if (dRetVal == S_OK) //{ // //omDatabaseArray.Add(omSampleDatabasePath); // //Store in configdetails // //bSetData(DATABASE_FILE_NAME, &omDatabaseArray); // bWriteIntoTraceWnd(_(MSG_DEFAULT_DATABASE)); // bWriteIntoTraceWnd(_(MSG_CREATE_UNLOAD_DATABASE)); //} pMainFrame->OnHex_DecButon(); // setting HEX by default } // ******** Filter workaround ******** // Filter list is initialised before msg wnd creation. So update display // filter here // Update Message Display Filter List //::PostThreadMessage(GUI_dwThread_MsgDisp, TM_UPDATE_FILTERLIST, nullptr, nullptr ); // ******** Filter workaround ******** // Start Logging if is enabled // Get the Flag Pointer CFlags* pomFlag = pouGetFlagsPtr(); if( pomFlag != nullptr ) { // Get the Logging Status BOOL bLogON = pomFlag->nGetFlagStatus(LOGTOFILE); // If it is on then post a message to display thread to start logging if(bLogON == TRUE ) { // Start Logging //CLogManager::ouGetLogManager().vStartStopLogging( TRUE ); } } //pMainFrame->OnHex_DecButon(); // setting HEX by default //CExecuteManager::ouGetExecuteManager().vStartDllReadThread(); return TRUE; }