AddLine Adds a new line to the control. If logging is on and the addToLog param is TRUE then this line is also added to the log file. Params string - string to add addToLog - if TRUE then add to the file log, if it is enabled Return 0 - (UH_SUCCESS) 1 - (UH_ERROR) ***********************************/
| 1055 | 1 - (UH_ERROR) |
| 1056 | ***********************************/ |
| 1057 | int CUH_Control::AddLine(LPCTSTR string, COLORREF TextColor, COLORREF BackColor, BOOLEAN addToLog){ |
| 1058 | |
| 1059 | //enter into a critical section |
| 1060 | #ifdef UH_THREADSAFE |
| 1061 | EnterCriticalSection(&m_criticalSection); |
| 1062 | #endif |
| 1063 | |
| 1064 | //update the log file |
| 1065 | if(addToLog && m_enableLog) |
| 1066 | WriteToLog(string,TRUE); |
| 1067 | |
| 1068 | //check to see if a window exists |
| 1069 | int updateScrollFlag = FALSE; |
| 1070 | if(m_hWnd != NULL){ |
| 1071 | UH_HistoryList *old = m_historyList; |
| 1072 | |
| 1073 | m_historyList = new UH_HistoryList; |
| 1074 | m_historyList->m_next =old; |
| 1075 | m_historyList->m_prev = NULL; |
| 1076 | m_historyList->m_textColor = TextColor; |
| 1077 | m_historyList->m_backColor = BackColor; |
| 1078 | |
| 1079 | if(old != NULL) |
| 1080 | old->m_prev = m_historyList; |
| 1081 | |
| 1082 | int len = (int)_tcslen(string); |
| 1083 | if(len == 0) { |
| 1084 | m_historyList->m_string = new _TCHAR[1]; |
| 1085 | m_historyList->m_string = 0; |
| 1086 | m_historyList->m_len =0; |
| 1087 | } |
| 1088 | else{ |
| 1089 | m_historyList->m_string = new _TCHAR[len+1]; |
| 1090 | _tcscpy(m_historyList->m_string,string); |
| 1091 | // TD TODO CUT_StrMethods::RemoveCRLF(m_historyList->m_string); |
| 1092 | m_historyList->m_len = (int)_tcslen(m_historyList->m_string); |
| 1093 | } |
| 1094 | |
| 1095 | //store the max line width |
| 1096 | if(len > m_maxLineWidth){ |
| 1097 | m_maxLineWidth = len; |
| 1098 | updateScrollFlag = TRUE; |
| 1099 | } |
| 1100 | |
| 1101 | //adjust the current pos |
| 1102 | if(m_HLCurrentPosPtr != NULL) |
| 1103 | m_HLCurrentPosPtr = m_HLCurrentPosPtr->m_prev; |
| 1104 | else{ |
| 1105 | m_HLCurrentPosPtr = m_historyList; |
| 1106 | m_HLCurrentPos = 0; |
| 1107 | } |
| 1108 | |
| 1109 | //cut items off the end - if reached |
| 1110 | if(m_HLEndPosPtr != NULL){ |
| 1111 | if(m_HLEndPos == m_historyListMaxLen -1){ |
| 1112 | UH_HistoryList *old = m_HLEndPosPtr; |
| 1113 | m_HLEndPosPtr = m_HLEndPosPtr->m_prev; |
| 1114 | m_HLEndPosPtr->m_next = NULL; |
nothing calls this directly
no outgoing calls
no test coverage detected