void CMyListCtrl::InitList(CString csParams, int nCount) { DeleteAllColumns(); SetExtendedStyle(GetExtendedStyle() |LVS_EX_GRIDLINES |LVS_EX_FULLROWSELECT |LVS_EX_SUBITEMIMAGES); SetParamCount(nCount); SetHead(csParams); AutoSize(); }
BOOL CVNNetMsg::AddParam( int id, int type, int length, char* data ) // Current assumption is any 2, 4 byte integers are already // in network byte order. { if (m_Data == 0) return FALSE; // Ensure the parameter doesn't exist int tmp; if (GetParam(id, &tmp, &tmp, 0) == 0) { // The parameter already exists, we don't support // having two parameters of the same ID. There is // currently no method to modify a parameter within // a message either. return FALSE; } int requiredLength = ParamDataStart_Offset + length; if ((m_Pos + requiredLength) > m_MaxLength) { // Need to realloc the data int oldLength = m_MaxLength; m_MaxLength = m_Pos + requiredLength; char * hg = new char[m_MaxLength]; //HGLOBAL hg = GlobalAlloc(GMEM_FIXED, m_MaxLength); if (hg) { char* data = hg; memcpy(data, m_Data, oldLength); delete[] m_Data; //GlobalFree(GlobalHandle((void*)m_Data)); m_Data = data; } else { m_Data = 0; m_MaxLength = 0; return FALSE; } } // Update parmaeter count SetParamCount(GetParamCount() + 1); u_char* ptr = (u_char*)&m_Data[m_Pos]; ptr[ParamID_Offset] = id; ptr[ParamType_Offset] = type; u_long* lptr = (u_long*)&ptr[ParamLength_Offset]; *lptr = htonl(length); memcpy(&ptr[ParamDataStart_Offset], data, length); m_Pos += requiredLength; // Update message length int addedLength = ParamDataStart_Offset + length; SetLength(GetLength() + addedLength); return TRUE; }