Introduction
At last we can set ourselves the task of conservation and read-out of necessary information for our application from files of data. In typical MFC program standard serialization of data is usually supported with CDocument
classes. In principle nothing interferes to us to use this method for our aims. However, at once does a question get up in what format to keep information? Certainly we can invent an own data format, appropriate it our extension, for example, *.eee and to work with it as this will be comfortably us. Perhaps, for educational aims or there where principle of serialization of information has a substantial value, this method is very quite good. But, as we design working application in which it is necessary to have an random access to file memory, the use of serialization does not seem an optimum enough decision for us already. In addition, for development of own format of data are needed very weighty grounds. I think that satisfaction of own ego is not such cause.
So, at first, we must be determined with the existent format of data, and secondly, to define a method of random access to file information. At such wording, decision of these tasks are fully obviously. The simplest and well known format of data is structure of dbf-file which gives a good account of itself. And random access to content of files of data easily to carry out taking advantages of technology of memory mapped files – MMF. Main desert of this technology is in that we work with files as with ordinary memory. For databases files it is an excellent decision. There is not a necessity preliminary to read information in ordinary memory for their further use, although we can do it for small but often using information, with the purpose of optimization, for example for meta data, describing structure of a database. In addition, an obvious necessity to be engaged in spooling of data falls off, that is very comfortably for filling of CListCtrl
classes and its descendants in the virtual mode. Except for it, we can directly use static
structure of database for random access to its elements of data. Plus lightness of the use of technology of MMF. Advantages are so much, that has no sense to talk about serialization of information, while practically at those efforts we get all of advantages of random access to memory mapped files.
On this stage we define organization of work thus. At opening a certain table form, the program searches proper by it a dbf-file, described in our meta data. If finds, tries to open its and use its information for filling of a proper list, otherwise creates this dbf-file, reading information from our static variables. If to change such file by some external editor program of dbf-files, at repeated his read-out we will see new information already. Later we will learn to edit dbf-files directly in our program. This project is already supplied with the prepared files, located in the Dbf folder. Its names are «First.dbf», «Second.dbf» and «Third.dbf». They have an alike structure (in the third file the fields «Name» and «Title» moved between itself) but its data are sorted variously. In all from them there are 360 records. If for example we delete the file «Third .dbf», instead of its our program will be to create the same file and will fill its data with our static variables. As the result we will get an example indicated on a Fig. 1.
Fig. 1. Filling of lists in the Virtual Mode by information from dbf-files, including created.
1. Structure of DBF file
In the Internet is not very much hardness to find necessary information about dbf-files, as this format is opened and a long ago known. However succeeded finding an official specification was not. Therefore we will expound short results about their structure, see Fig. 2.
Fig. 2. Schema of dbf-file and range of definition of DBF_FILE1 and DBF_FILE2 structures.
If we know beforehand an amount of fields FLDCOUNT = N in a database, their lengths FLDLEN1 = M1, FLDLEN2 = M2, . . ., FLDLENn = Mn and number of records RECCOUNT = K, the proper structure of dbf-file can be defined as:
//*** The dbf file structure
typedef struct {
DBF_HEADER DbfHdr;
DBF_FIELD aDbfField[FLDCOUNT];
BYTE cHdrEnd;
BYTE acDbcFile[263];
DBF_RECORD aDbfRec[RECCOUNT];
BYTE cFileEnd;
} DBF_FILE;
where the proper structures are determined as:
//*** The dbf header structure
typedef struct {
BYTE cType;
BYTE cYear;
BYTE cMonth;
BYTE cDay;
ULONG nRecCount;
WORD wFirstRec;
WORD wRecSize;
BYTE cReserv1227[16];
BYTE cFlag;
BYTE cCodePage;
WORD wReserv3031;
} DBF_HEADER;
//*** The dbf field structure
typedef struct {
BYTE cName[11];
BYTE cType;
ULONG nOffset;
BYTE cLen;
BYTE cDec;
BYTE cFlag;
LONG nNext;
BYTE cStep;
BYTE cReserv2431[8];
} DBF_FIELD;
//*** The dbf record structure
typedef struct {
BYTE cDelete;
BYTE cData1[FLDLEN1];
BYTE cData2[FLDLEN2],
. . .
BYTE cDataN[FLDLENN];
} DBF_RECORD;
Here is showed the static structure of dbf-file actually (we are oriented on the VFP format with the file type 0x30 (48)). For dynamic structures in ordinary memory, organization of data must be other – through pointers (size of which is known) to complete structures of data, sizes of which are unknown on the stage of compiling of program (or not desirable for the use, not to limit to ourselves with a concrete structure of one file). And as the compiler of VS6 C++ can not create dynamic types of data, size of which turns out only on the stage of executing of program (runtime), we can not use the structure of data obviously described higher for direct manipulation file information. But we also do not wish preliminary to read information of records in ordinary memory, to analyze and convert its directly to use in future. The same we lose advantages of the MMF. Thus, gets up the task of maximal description of dynamic structures of data with static ones, with the purpose of effective selection of elements of data from databases (in this case dbf-files) on the stage of executing of the program.
2. Determination of dynamic structures (unknown sizes) via static ones
This theme is important enough in itself, to spare it a little bit of attention. Ordinary compilers can not create dynamic types of data, when sizes of structures are ascertained in runtime. Just the «data type» bears in mind but not a dynamical storage area is reserved under it. We will illustrate said the known example. We will assume want to create an array of bytes for length which we determine dynamically, for example:
UINT nX = 100;
BYTE acData[nX];
But on this very simple construction a compiler will «swear». instead of nX
it wants to see constant expression, as though
BYTE acData[100];
Thus, constant expression must be indicated obviously. For example, expression:
UINT nCount = sizeof(aKnownStructure)/ sizeof(aKnownStructure[0]);
acData[nCount];
will be erroneous, while the direct use:
acData[sizeof(aKnownStructure)/ sizeof(aKnownStructure[0])];
will be faithful.
Nevertheless, building the indicated array of the dynamically calculated size is possible if only to give up obvious static determination of array and substitute it by non-obvious static determination. I.e. instead of
BYTE acData[nX];
we write
BYTE *acData = new BYTE[nX];
A difference is here in that in first case of sizeof(acData) = 100
, and in second sizeof(acData) = 4
. I.e. in second case, actually we has not dynamic type, measuring 100 bytes, and static one of length 4 bytes, because it is a size of pointer to a dynamically selected storage area measuring 100 bytes. From viewpoint of the use of these elements of arrays are differences no, and from viewpoint of sizes of in-use structures difference is substantial. For an example will show yet how dynamically to build a bi-dimensional array.
BYTE **aaсFldName = new BYTE *[m_nFldCount];
for(int i = 0; i < m_nFldCount; i++) {
m_aacFldName[i] = new BYTE[11];
for(int j = 0; j < 11; j++)
m_aacFldName[i][j] = aDbfField[i].acName[j];
}
It is the real code from our application. Apparently, this technique is good for copying of dynamic structures of unknown beforehand (on the stage of compiling) size. But that well for often in-use and not largeness of meta data, is not very much well for enormous arrays of elements of data. It would be desirable directly to handle to them at their use (without a preliminary copying and analysis of structure of data). However for this purpose it is necessary beforehand to know key parameters of file of database, what on their basis to build the static types of complete structures of data. As it applies to the structure of dbf-file described higher, obvious knowledge of the parameters indicated there is needed. But as mentioned already, even if these parameters for this file know us, it is not interestingly us to specify them statically in our program, because it limits to us consideration only exactly this file. Certainly, we can beforehand describe the whole great number of dbf-files, in-use in our program, as it is ordinary and done, but however, if we wish to have an access to random dbf-file, this technique does not arrange us.
So, we walked up to the contradiction. From one side, static description of structure of database (as it is done at the beginning of the first section) allows us to take advantage memory mapped files, but limits to us the fixed set of these structures (i.e. by the certain amount of concrete types of files). From other side dynamic description of structures of data through pointers to structures, unknown beforehand sizes, results in the necessity of the use of flow of entrance data of unknown structure, that deprives us obvious advantages of MMF technology, namely random access to elements of a database.
For an example will specify that second a way was went author of «The alxBase classes for work with DBF files» by Alexey, therefore, MMF technician was not used him. He applies the classic method of retrieval of data from a dbf-file by the obvious positioning of file pointer and then reading of data elements. However one thing when we directly write a sort of (in right part it is file memory elements):
BYTE *acDataElement = acRecord[j].acField[i];
and another, that at first we must calculate file pointer of current element of data, positioned on it and only after have read information. But even it is not main (for the dbf-file it is not difficult to do it by ourselves), but circumstance that it is needed to work at organization of share (multi-user , multi-thread) access to common data yet. As far as I understood Alexey limited to monopolistic access to database, that limits the use of his library substantially. It is visible already because he withdrew support his project from 2005 (at least, in public). In MMF technology considerably anymore possibilities for organization of share access to data, so that, I think, it is not needed to ignore this possibility.
But will go back to our «contradiction». Clear, that we are not arranged by neither first nor second way. If someone knows a third way, it would be interestingly to know about it. We will endeavour to unite these methods, so, as far as it is possible. As we do not can beforehand fully statically to describe a dbf-file structure, limited to then partial static description, thus by not one similar structure, but two. If we once again attentively will look at the structure of dbf-file resulted higher (which in such kind will not be «understood» by a compiler), easily to see that in it it’s possible to select two static parts, which already will be «clear» a compiler. Namely:
//*** The dbf file structure (Part No. 1)
typedef struct {
DBF_HEADER DbfHdr;
DBF_FIELD aDbfField[1];
} DBF_FILE1;
//*** The dbf file structure (Part No. 2)
typedef struct {
BYTE cHdrEnd;
BYTE acDbcFile[263];
BYTE aDbfRec[1];
} DBF_FILE2;
Further, we will take advantage of the known «hacker» technique – conscious output outside the statically declared array of data. «Paying» for such combined approach will be a transition from «flat», «bi-dimensional» indexation (j, i)
to «one-dimensional», linear indexation of ji = j*nColCount + i
(for a count of linear number of cell of information) and necessity of calculation of general linear displacement nLineInd = j*nRowSize + m_anOff[i]
(in bytes). But, I think, that it is not too large «price», for such approach.
Exactly these structures we will really attach to a dbf-file, applying after a conscious output outside indexes of the static arrays of structures aDbfField[1]
and aDbfRec[1]
, by the mentioned linear indexes. As practice showed, it is fully good approach and it can be used for other data files, for example, for memo-fields (fpt-files), index cdx-files, database containers (dbc-files) etc.
3. MMF and reading of existent DBF files
Reading of having dbf-file takes a place by MMF technology, the use of which is presented in the function CMainDoc::OnOpenDocument
:
BOOL CMainDoc::OnOpenDocument(LPCTSTR szFileName) {
TCHAR *szDbfName = m_MetaTable.szDbfName;
CFileStatus FileStatus;
if(!CFile::GetStatus(szDbfName, FileStatus)) {
if(!CreateDocumentFile(szDbfName)) {
return FALSE;
}
}
m_hDbfFile = ::CreateFile(
szDbfName,
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL
);
if(m_hDbfFile == INVALID_HANDLE_VALUE) {
_M("CMainDoc: Failed to call ::CreateFile function!");
return FALSE;
}
TCHAR szStr[MAXITEMTEXT];
ULONG nDbfSize = ::GetFileSize(
m_hDbfFile,
NULL
);
if(nDbfSize == 0) {
swprintf(
szStr,
_T("CMainDoc: File '%s' is empty!"),
szDbfName
);
_M(szStr);
::CloseHandle(m_hDbfFile);
return FALSE;
}
m_hDbfMap = ::CreateFileMapping(
m_hDbfFile,
NULL,
PAGE_READWRITE,
0,
0,
NULL
);
if(!m_hDbfMap) {
_M("CMainDoc: Failed to call ::CreateFileMapping function!");
return FALSE;
}
m_pDbfView1 = reinterpret_cast<DBF_FILE1 *>(::MapViewOfFile(
m_hDbfMap,
FILE_MAP_WRITE,
0,
0,
0
));
if(!m_pDbfView1) {
_M("CMainDoc: Failed to call ::MapViewOfFile function!");
return FALSE;
}
m_pDbfHdr = &m_pDbfView1->DbfHdr;
if(m_pDbfHdr->cType != VFPTYPE) {
swprintf(
szStr,
_T("CMainDoc: Dbf type: %d doesn't equal to VFP type: %d!"),
m_pDbfHdr->cType,
VFPTYPE
);
_M(szStr);
return FALSE;
}
m_nRecCount = m_pDbfHdr->nRecCount;
m_nRecSize = m_pDbfHdr->wRecSize;
if((m_nRecSize == 0 && m_nRecCount != 0) ||
(m_nRecSize != 0 && m_nRecCount == 0)) {
swprintf(
szStr,
_T("CMainDoc: Not matches record size (%d) and record count (%d)!"),
m_nRecSize,
m_nRecCount
);
_M(szStr);
return FALSE;
}
ULONG nDataSize = nDbfSize - 1 - m_pDbfHdr->wFirstRec;
if(nDataSize != m_nRecCount*m_nRecSize) {
swprintf(
szStr,
_T("CMainDoc: Data size (%d) doesn't equal record count (%d) * record size (%d)!"),
nDataSize,
m_nRecCount,
m_nRecSize
);
_M(szStr);
return FALSE;
}
m_nFldCount = (m_pDbfHdr->wFirstRec - 296)/32;
if(m_nFldCount > m_nRecSize - 1) {
_M("CMainDoc: Field count is very large!");
return FALSE;
}
DBF_FIELD *aDbfField = m_pDbfView1->aDbfField;
m_pDbfView2 = reinterpret_cast<DBF_FILE2 *>(
&m_pDbfView1->aDbfField[m_nFldCount].acName[0]
);
BYTE cHdrEnd = 0;
try {
cHdrEnd = m_pDbfView2->cHdrEnd;
} catch(...) {
_M("CMainDoc: Dbf file has wrong structure!");
return FALSE;
}
if(cHdrEnd != HEADEREND) {
swprintf(
szStr,
_T("CMainDoc: Header record terminator: %d doesn't equal to: %d!"),
m_pDbfView2->cHdrEnd,
HEADEREND
);
_M(szStr);
return FALSE;
}
m_aacFldName = new BYTE *[m_nFldCount];
m_acFldType = new BYTE[m_nFldCount];
m_anOff = new UINT[m_nFldCount];
m_acLen = new BYTE[m_nFldCount];
m_acDec = new BYTE[m_nFldCount];
for(int i = 0; i < m_nFldCount; i++) {
m_aacFldName[i] = new BYTE[11];
for(int j = 0; j < 11; j++)
m_aacFldName[i][j] = aDbfField[i].acName[j];
m_acFldType[i] = aDbfField[i].cType;
m_acLen[i] = aDbfField[i].cLen;
m_anOff[i] = aDbfField[i].nOffset;
m_acDec[i] = aDbfField[i].cDec;
}
BYTE cFileEnd = 0;
try {
cFileEnd = m_pDbfView2->aDbfRec[m_nRecCount * m_nRecSize];
} catch(...) {
_M("CMainDoc: Dbf file has wrong structure!");
return FALSE;
}
if(cFileEnd != DBFEND) {
swprintf(
szStr,
_T("CMainDoc: Header record terminator: %d doesn't equal to: %d!"),
m_pDbfView2->aDbfRec[m_nRecCount * m_nRecSize],
DBFEND
);
_M(szStr);
return FALSE;
}
CListCtrlEx *pTable = m_pMainApp->m_apTable[m_eTable];
if(!pTable) {
_M("CMainDoc: Empty a CListCtrlEx object!");
return FALSE;
}
pTable->SetItemCount(m_nRecCount);
m_pMainApp->m_apDoc[m_eTable] = this;
return TRUE;
}
4. Creation of DBF files and filling their with static data
To create a file of database, it is needed preliminary to know its structure. In our demonstration program there are three such static structures which allow to create three different dbf-files. Changing their amount and content it is possible to create random enough files of the Visual FoxPro format of databases. Here are basic structures of our meta data:
//*** The dbf-file fields data structure
typedef struct {
TCHAR *szFldName;
TCHAR *szFldType;
UINT nFldLen;
UINT nDecLen;
} META_DATA;
//*** The meta table header structure
typedef struct {
TCHAR *szHdrName;
DWORD nAdjust;
UINT nWidth;
} META_HEADER;
//*** The meta table structure
typedef struct {
TCHAR *szDbfName;
META_DATA *aMetaData;
TCHAR *szTblName;
META_HEADER *apMetaHeader;
DWORD dwStyle;
DWORD dwExStyle;
RECT *pFrmRect;
RECT *pViewRect;
CFont *pHdrFont;
CFont *pListFont;
UINT nHdrHeight;
UINT nListHeight;
UINT nColCount;
UINT nRowCount;
TCHAR **apRowText;
} META_TABLE;
Using these structures the function CMainApp::CreateDocumentFile
creates a necessary dbf-file:
BOOL CMainDoc::CreateDocumentFile(TCHAR *szDbfName) {
CFileStatus FileStatus;
if(CFile::GetStatus(szDbfName, FileStatus))
return TRUE;
ULONG nRecCount = m_MetaTable.nRowCount;
UINT nFldCount = m_MetaTable.nColCount;
SYSTEMTIME SysTime = {0};
GetSystemTime(&SysTime);
DBF_HEADER DbfHdr = {0};
DbfHdr.cType = VFPTYPE;
DbfHdr.cYear = SysTime.wYear%BASEYEAR;
DbfHdr.cMonth = SysTime.wMonth;
DbfHdr.cDay = SysTime.wDay;
DbfHdr.nRecCount = nRecCount;
DbfHdr.cCodePage = CP1252;
DBF_FIELD DbfField = {0};
HANDLE hDbfFile = ::CreateFile(
szDbfName,
GENERIC_WRITE,
0,
NULL,
CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
NULL
);
TCHAR szStr[MAXITEMTEXT];
if(hDbfFile == INVALID_HANDLE_VALUE) {
swprintf(
szStr,
_T("CMainApp: Failed to create new file: '%s'!"),
szDbfName
);
_M(szStr);
::CloseHandle(hDbfFile);
return FALSE;
}
DWORD dwBytes = 0;
WriteFile(hDbfFile, &DbfHdr, sizeof(DbfHdr), &dwBytes, NULL);
BYTE *acFldLen = new BYTE[nFldCount];
BYTE *acFldType = new BYTE[nFldCount];
UINT nOffset = 1;
for(int i = 0; i < nFldCount; i++) {
META_DATA MetaData = m_MetaTable.aMetaData[i];
BYTE *acName = DbfField.acName;
TCHAR *szFldName = MetaData.szFldName;
while(*acName++ = *szFldName++);
acFldType[i] = MetaData.szFldType[0];
DbfField.cType = acFldType[i];
DbfField.nOffset = nOffset;
acFldLen[i] = MetaData.nFldLen;
DbfField.cLen = acFldLen[i];
DbfField.cDec = MetaData.nDecLen;
nOffset += acFldLen[i];
WriteFile(hDbfFile, &DbfField, sizeof(DbfField), &dwBytes, NULL);
}
DbfHdr.wRecSize = nOffset;
BYTE cHdrEnd = HEADEREND;
WriteFile(hDbfFile, &cHdrEnd, sizeof(cHdrEnd), &dwBytes, NULL);
BYTE acDbcFile[263] = {0};
WriteFile(hDbfFile, &acDbcFile, sizeof(acDbcFile), &dwBytes, NULL);
DWORD nCurOffset = SetFilePointer(hDbfFile, 0, NULL, FILE_CURRENT);
DbfHdr.wFirstRec = nCurOffset;
BYTE cDelete = 32;
UINT ji = 0;
for(ULONG j = 0; j < nRecCount; j++) {
WriteFile(hDbfFile, &cDelete, sizeof(cDelete), &dwBytes, NULL);
for(i = 0; i < nFldCount; i++) {
ji = j*nFldCount + i;
TCHAR *acRowText = m_MetaTable.apRowText[ji];
BYTE cFldLen = acFldLen[i];
BYTE cFldType = acFldType[i];
BYTE *acFldData = new BYTE[cFldLen + 2];
for(int k = 0; k < cFldLen; k++)
acFldData[k] = acRowText[k];
if(cFldType == 68) {
if(cFldLen != 8) {
swprintf(
szStr,
_T("CMainApp: Length of date format is %d. Must be 8!"),
cFldLen
);
_M(szStr);
return FALSE;
}
if(cFldLen == 8) {
acFldData[8] = acRowText[8];
acFldData[9] = acRowText[9];
acFldData[2] = acFldData[8];
acFldData[5] = acFldData[4];
acFldData[4] = acFldData[3];
acFldData[3] = acFldData[9];
acFldData[8] = acFldData[0];
acFldData[9] = acFldData[1];
acFldData[0] = acFldData[6];
acFldData[1] = acFldData[7];
acFldData[6] = acFldData[8];
acFldData[7] = acFldData[9];
}
}
WriteFile(hDbfFile, acFldData, cFldLen, &dwBytes, NULL);
}
}
BYTE cFileEnd = DBFEND;
WriteFile(hDbfFile, &cFileEnd, sizeof(cFileEnd), &dwBytes, NULL);
ULONG nPos = (ULONG) &DbfHdr.wFirstRec - (ULONG) &DbfHdr.cType;
WORD wFirstRec = DbfHdr.wFirstRec;
WORD wRecSize = DbfHdr.wRecSize;
SetFilePointer(hDbfFile, nPos, NULL, FILE_BEGIN);
WriteFile(hDbfFile, &wFirstRec, sizeof(wFirstRec), &dwBytes, NULL);
WriteFile(hDbfFile, &wRecSize, sizeof(wRecSize), &dwBytes, NULL);
::CloseHandle(hDbfFile);
return TRUE;
}
5. Processing of data in the Virtual Mode
In conclusion we will show the code of LVN_GETDISPINFO
handler, which is «responsible» for the virtual mode.
BOOL CListCtrlEx::OnChildNotify(UINT message, WPARAM wParam, LPARAM lParam, LRESULT *pResult) {
NMHDR *pNMHdr = reinterpret_cast<NMHDR *>(lParam);
LV_DISPINFO *pLVDI = reinterpret_cast<LV_DISPINFO *>(lParam);
LV_ITEM *pItem = &pLVDI->item;
if(message == WM_NOTIFY) {
switch(pNMHdr->code) {
case LVN_GETDISPINFO: {
if(pItem->mask & LVIF_TEXT) {
UINT nRow = pItem->iItem;
UINT nCol = pItem->iSubItem;
TCHAR szStr[MAXITEMTEXT];
m_pDoc = m_pMainApp->m_apDoc[m_eTable];
if(!m_pDoc) {
_M("CListCtrlEx::CListCtrlEx : Empty document!");
exit(-1);
}
ULONG nColCount = m_pDoc->m_nFldCount;
if(nColCount == 0) {
_M("CListCtrlEx::OnChildNotify : Column count = 0!");
exit(-1);
}
if(m_MetaTable.nColCount != nColCount) {
swprintf(
szStr,
_T("CListCtrlEx::OnChildNotify : Table (%d) and Dbf (%d) columns are different!"),
m_MetaTable.nColCount,
nColCount
);
_M(szStr);
exit(-1);
}
ULONG nRowCount = m_pDoc->m_nRecCount;
if(nRowCount == 0) {
_M("CListCtrlEx::OnChildNotify : Row count = 0!");
exit(-1);
}
m_MetaTable.nRowCount = nRowCount;
ULONG nRowSize = m_pDoc->m_nRecSize;
if(nRowSize == 0) {
_M("CListCtrlEx::OnChildNotify : Row size = 0!");
exit(-1);
}
ULONG nLineInd = nRow*nRowSize + m_pDoc->m_anOff[nCol];
if(nLineInd < 0) {
_M("CListCtrlEx::OnChildNotify : Line index < 0!");
exit(-1);
}
DBF_FILE2 *m_pDbfView2 = m_pDoc->m_pDbfView2;
if(!m_pDbfView2) {
_M("CListCtrlEx::OnChildNotify : Empty view of dbf file!");
exit(-1);
}
BYTE *aDbfRec = m_pDbfView2->aDbfRec;
if(!aDbfRec) {
_M("CListCtrlEx::OnChildNotify : Empty array of dbf file!");
exit(-1);
}
if(!aDbfRec) {
_M("CListCtrlEx::OnChildNotify : Empty records into dbf file!");
exit(-1);
}
UINT ji = nRow*nColCount + nCol;
if(ji < 0) {
_M("CListCtrlEx::OnChildNotify : Line cell index < 0!");
exit(-1);
}
if(ji < nRowCount*nColCount) {
try {
CString sFldVal(
(LPCSTR) &aDbfRec[nLineInd],
m_pDoc->m_acLen[nCol]
);
if(m_pDoc->m_acFldType[nCol] == 68) {
CString sDate =
sFldVal.Right(2) + _T(".") +
sFldVal.Mid(4, 2) + _T(".") +
sFldVal.Left(4);
sFldVal = sDate;
}
wcscpy((wchar_t *)(pItem->pszText), sFldVal);
} catch (...) {
exit(-1);
}
} else {
wcscpy((wchar_t *)(pItem->pszText), _T("***"));
}
}
break;
}
}
}
return CListCtrl::OnChildNotify(message, wParam, lParam, pResult);
}