void CConfigMsgLogDlg::OnLvnItemchangedLogBlockLst(NMHDR* pNMHDR, LRESULT* pResult) { NM_LISTVIEW* pNMListView = (NM_LISTVIEW*) pNMHDR; // Update Log File Components if ((pNMListView->uChanged != LVIF_TEXT) && (m_bUpdatingUI == FALSE)) { // Selected & Focused if (pNMListView->uNewState == (LVIS_FOCUSED | LVIS_SELECTED)) { // Update selection m_nLogIndexSel = pNMListView->iItem; // Update selected Log file details vUpdate_GUI_From_Datastore((USHORT) m_nLogIndexSel); if(m_bLogON) { m_bEditingON = FALSE; GetDlgItem(IDC_CHECK_RESET_TIMESTAMP)->EnableWindow(FALSE); } else { m_bEditingON = TRUE; } } else if (pNMListView->uNewState & MASK_CHECK_UNCHECK) { //ASSERT(m_nLogIndexSel == pNMListView->iItem); vUpdate_Datastore_From_GUI((USHORT) pNMListView->iItem, IDC_LOGBLOCK_LST); } else { m_bEditingON = FALSE; // Update Button Status vEnableDisableControls(FALSE); EnablingMaxNumEdit(); GetDlgItem(IDC_CHECK_RESET_TIMESTAMP)->EnableWindow(FALSE); } } *pResult = 0; }
BOOL CConfigMsgLogDlg::OnInitDialog() { CDialog::OnInitDialog(); m_ChkbEnableLogOnConnect.SetCheck(m_bLogOnConnect == TRUE? BST_CHECKED : BST_UNCHECKED); m_odStartMsgID.vSetConfigData(IDC_EDIT_STARTMSGID); m_odStopMsgID.vSetConfigData(IDC_EDIT_STOPMSGID); m_odStartMsgID.vSetBase(BASE_HEXADECIMAL); m_odStopMsgID.vSetBase(BASE_HEXADECIMAL); m_odStartMsgID.vSetSigned(false); m_odStopMsgID.vSetSigned(false); vCreateFileList(); InitialiseWindow(); USHORT LogBlocks = GetLoggingBlockCount(); if (LogBlocks > 0) { for (USHORT i = 0; i < LogBlocks; i++) { SLOGINFO sLogObject; HANDLE hFind; WIN32_FIND_DATA FindData; CStdioFile omStdiofile; GetLoggingBlock(i, sLogObject); // check for valid log file CString strTempLog = sLogObject.m_sLogFileName; hFind = FindFirstFile(strTempLog, &FindData); if(hFind == INVALID_HANDLE_VALUE )//file not found { DWORD dError = GetLastError(); if(dError == ERROR_FILE_NOT_FOUND)//file not found { BOOL bFileOpen = omStdiofile.Open(strTempLog, CFile::modeCreate | CFile::modeWrite | CFile::typeBinary); if(bFileOpen == TRUE)///file created, add in the list { omStdiofile.Close(); AddNewItem_GUI(sLogObject, i); } else //not a valid file { RemoveLoggingBlock(i--); //remove the old log data LogBlocks = GetLoggingBlockCount(); //refresh the log count } } else //not a valid filepath / file folder is removed { RemoveLoggingBlock(i--); //remove the old log data LogBlocks = GetLoggingBlockCount(); //refresh the log count } } else ///file found add in the list { AddNewItem_GUI(sLogObject, i); } } m_nLogIndexSel = 0; if(m_omListLogFiles.GetItemCount() > 0 )//check for log files exists { m_omListLogFiles.SetItemState(m_nLogIndexSel, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED); } else { vEnableDisableControls(FALSE);//disable controls if no log files exists } } else { vEnableDisableControls(FALSE); } SetWindowText(m_strCurrWndText); if (m_bLogON) { vEnableDisableControls(FALSE); if(m_omListLogFiles.GetItemCount()>0) { vUpdate_GUI_From_Datastore(0); } GetDlgItem(IDC_CBTN_ADDLOG)->EnableWindow(FALSE); GetDlgItem(IDC_CHECK_RESET_TIMESTAMP)->EnableWindow(FALSE); GetDlgItem(IDC_EDIT_NO_OF_FILES)->EnableWindow(FALSE); GetWindowText(m_strCurrWndText); m_strCurrWndText+=_(" - Read Only as Logging is ON"); SetWindowText(m_strCurrWndText); // If Logging is on GetDlgItem(IDOK)->EnableWindow(FALSE); m_unDispUpdateTimerId = SetTimer(600, 600, nullptr); } else { // If Logging is on GetDlgItem(IDOK)->EnableWindow(TRUE); } // Hide or show the Filters button in the dialog based on the protocol GetDlgItem(IDC_LOG_FILTER)->ShowWindow(SW_SHOWNORMAL); /*if (J1939 == m_eCurrBus) { GetDlgItem(IDC_LOG_FILTER)->ShowWindow(0); }*/ return TRUE; }
BOOL CConfigMsgLogDlg::OnInitDialog() { CDialog::OnInitDialog(); m_ChkbEnableLogOnConnect.SetCheck(m_bLogOnConnect == TRUE? BST_CHECKED : BST_UNCHECKED); m_odStartMsgID.vSetConfigData(IDC_EDIT_STARTMSGID); m_odStopMsgID.vSetConfigData(IDC_EDIT_STOPMSGID); m_odStartMsgID.vSetBase(BASE_HEXADECIMAL); m_odStopMsgID.vSetBase(BASE_HEXADECIMAL); m_odStartMsgID.vSetSigned(false); m_odStopMsgID.vSetSigned(false); vCreateFileList(); //Load channel combo box m_omComboChannel.ResetContent(); if (NULL != GetICANDIL()) { LPARAM lParam = 0; if (S_OK == GetICANDIL()->DILC_GetControllerParams(lParam, NULL, NUMBER_HW)) { m_unChannelCount = (UINT)lParam; } } m_omComboChannel.InsertString(0, _("ALL")); for (UINT i = 1; i <= m_unChannelCount; i++) { CString omChannel; omChannel.Format("%d", i); m_omComboChannel.InsertString(i, omChannel.GetBuffer(MAX_PATH)); } m_omComboChannel.SetCurSel(0); USHORT LogBlocks = GetLoggingBlockCount(); if (LogBlocks > 0) { for (USHORT i = 0; i < LogBlocks; i++) { SLOGINFO sLogObject; HANDLE hFind; WIN32_FIND_DATA FindData; CStdioFile omStdiofile; GetLoggingBlock(i, sLogObject); // check for valid log file CString strTempLog = sLogObject.m_sLogFileName; hFind = FindFirstFile(strTempLog, &FindData); if(hFind == INVALID_HANDLE_VALUE )//file not found { DWORD dError = GetLastError(); if(dError == ERROR_FILE_NOT_FOUND)//file not found { BOOL bFileOpen = omStdiofile.Open(strTempLog, CFile::modeCreate | CFile::modeWrite | CFile::typeBinary); if(bFileOpen == TRUE)///file created, add in the list { omStdiofile.Close(); AddNewItem_GUI(sLogObject, i); } else //not a valid file { RemoveLoggingBlock(i--); //remove the old log data LogBlocks = GetLoggingBlockCount(); //refresh the log count } } else //not a valid filepath / file folder is removed { RemoveLoggingBlock(i--); //remove the old log data LogBlocks = GetLoggingBlockCount(); //refresh the log count } } else ///file found add in the list { AddNewItem_GUI(sLogObject, i); } } m_nLogIndexSel = 0; if(m_omListLogFiles.GetItemCount() > 0 )//check for log files exists { m_omListLogFiles.SetItemState(m_nLogIndexSel, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED); } else { vEnableDisableControls(FALSE);//disable controls if no log files exists } } else { vEnableDisableControls(FALSE); } SetWindowText(m_strCurrWndText); if (m_bLogON) { vEnableDisableControls(FALSE); if(m_omListLogFiles.GetItemCount()>0) { vUpdate_GUI_From_Datastore(0); } GetDlgItem(IDC_CBTN_ADDLOG)->EnableWindow(FALSE); GetDlgItem(IDC_CHECK_RESET_TIMESTAMP)->EnableWindow(FALSE); GetWindowText(m_strCurrWndText); m_strCurrWndText+=_(" - Read Only as Logging is ON"); //SetWindowText(m_strCurrWndText); // PTV [1.6.4] // If Logging is on GetDlgItem(IDOK)->EnableWindow(FALSE); // PTV [1.6.4] SetWindowText(""); m_unDispUpdateTimerId = SetTimer(600, 600, NULL); } else { // PTV [1.6.4] // If Logging is on GetDlgItem(IDOK)->EnableWindow(TRUE); // PTV [1.6.4] } // Hide or show the Filters button in the dialog based on the protocol if (CAN == m_eCurrBus) { GetDlgItem(IDC_LOG_FILTER)->ShowWindow(1); } else if (J1939 == m_eCurrBus) { GetDlgItem(IDC_LOG_FILTER)->ShowWindow(0); } return TRUE; }