|
Check this link ->[^]
"Every Little Smile can touch Somebody's Heart...
May we find Hundreds of Reasons to Smile Everyday... and
May WE be the Reason for someone else to smile always!" (ICAN)
|
|
|
|
|
the problem of mine is: I defined four document templates "A B C D" in my program and I set the document template "A" as master document template others as slaves.that means I use the master document template to open data and transfer data to other document templates. so I only implement the OnOpenDocument() function of the master document template. after I have finished all the framework. my leader tell me that the view from the "B" document template should be display firstly or on top after the data is opened. so I have to hide the view of master document template and show the view of slave "B" document template. but I found the "B" is not activate, that means all the menu or toolbar command message loop are still clue to master document template. please tell me how to active the B document template and let it to response all the menu commands.
swandream
|
|
|
|
|
i am trying to Encrypting files SetEncryptionMethod(CZipCryptograph::encWinZipAes256)
its not encrypting full here is my code ...
CZipArchive zip;
LPCTSTR sar = _T("C:\\saad.zip");
LPCTSTR password = _T("1234");
zip.Open(sar,CZipArchive::zipCreate);
zip.SetPassword(password);
zip.SetEncryptionMethod(CZipCryptograph::encWinZipAes256);
zip.AddNewFile(filepath);
zip.Close();
// TODO: Add your control notification handler code here
MessageBox(_T("file is locked successfully"),NULL,MB_OK);
when i see in winhex its shows the which type of file and data ...
by using winrar i encrypted the file then drag into the winhex it does not show file type or etc
i looking to do it like that using the zip archive lib ........
is there any other way to do it in aip archive lib only ??????
thanking you
sarfarz
|
|
|
|
|
have you tried asking the author(s) of CZipArchive ?
|
|
|
|
|
|
hello everybody :
i created a dialog base program and it has a CListCtrl on the dialog. now ,i wanna print the datas of CListCtrl.but the reuslt was wrong.
may be the wrong in TextOut function
following 's my code , help me please.
BOOL CBingLiGuanLi::PrintList(CListCtrl *pListCtrl)<br />
{<br />
PRINTDLG pd; <br />
pd.lStructSize = sizeof(PRINTDLG); <br />
pd.Flags = PD_RETURNDC; <br />
pd.hDC = NULL; <br />
pd.hwndOwner = NULL; <br />
pd.hInstance = NULL; <br />
pd.nMaxPage = 1; <br />
pd.nMinPage = 1; <br />
pd.nFromPage = 1; <br />
pd.nToPage = 1; <br />
pd.nCopies = 1; <br />
pd.hDevMode = NULL; <br />
pd.hDevNames = NULL; <br />
if(!PrintDlg(&pd)) return FALSE; <br />
ASSERT(pd.hDC!=NULL); <br />
int nHorRes = GetDeviceCaps(pd.hDC, HORZRES); <br />
int nVerRes = GetDeviceCaps(pd.hDC, VERTRES); <br />
int nXMargin = 2; <br />
int nYMargin = 2; <br />
TEXTMETRIC tm; <br />
GetTextMetrics(pd.hDC, &tm); <br />
int nCharHeight = tm.tmHeight; <br />
int nCharWidth = tm.tmAveCharWidth; <br />
CHeaderCtrl* pHeader = pListCtrl->GetHeaderCtrl(); <br />
int nColCount = pHeader->GetItemCount(); <br />
int nLineCount = pListCtrl->GetItemCount(); <br />
int ColOrderArray[100]; <br />
COLATT ca[100]; <br />
pListCtrl->GetColumnOrderArray(ColOrderArray, nColCount); <br />
int nColX =nXMargin*nCharWidth; <br />
for(int iXinXi =0 ; iXinXi< nColCount; iXinXi++) <br />
{ <br />
ca[iXinXi].nColIndex = ColOrderArray[iXinXi]; <br />
LVCOLUMN lvc; <br />
char text[100]; <br />
lvc.mask = LVCF_TEXT|LVCF_SUBITEM; <br />
lvc.pszText = text; <br />
lvc.cchTextMax = 100; <br />
pListCtrl->GetColumn(ca[iXinXi].nColIndex, &lvc); <br />
ca[iXinXi].strColText = lvc.pszText; <br />
ca[iXinXi].nSubItemIndex = lvc.iSubItem; <br />
ca[iXinXi].nPrintX = nColX; <br />
nColX += nCharWidth * strlen(ca[iXinXi].strColText); <br />
if(nColX > nHorRes) <br />
{ <br />
DeleteDC(pd.hDC); <br />
AfxMessageBox("字段太多,无法在一行内打印,请试用较大的纸,或横向打印。"); <br />
return FALSE; <br />
} <br />
} <br />
DOCINFO di; <br />
di.cbSize = sizeof(DOCINFO); <br />
di.lpszDocName = "ListCtrl Data Printing"; <br />
di.lpszOutput = (LPTSTR) NULL; <br />
di.lpszDatatype = (LPTSTR) NULL; <br />
di.fwType = 0; <br />
StartDoc(pd.hDC, &di); <br />
StartPage(pd.hDC); <br />
int space = (nHorRes-nXMargin*nCharWidth-nColX) / (nColCount -1); <br />
for(int iKuanDu =1; iKuanDu<nColCount; iKuanDu++) <br />
{ <br />
ca[iKuanDu].nPrintX += iKuanDu*space; <br />
} <br />
for(int iLieBiaoTi =0; iLieBiaoTi<nColCount; iLieBiaoTi++) <br />
{<br />
TextOut(pd.hDC, ca[iLieBiaoTi].nPrintX, nYMargin, <br />
ca[iLieBiaoTi].strColText, strlen(ca[iLieBiaoTi].strColText)); <br />
}<br />
int nMaxLinePerPage = nVerRes/nCharHeight -3; <br />
int nCurPage =1; <br />
for(int i=0; i<nLineCount; i++) <br />
{ <br />
for(int j =0; j<nColCount; j++) <br />
{ <br />
if(i+1-(nCurPage-1)*nMaxLinePerPage > nMaxLinePerPage) <br />
{ <br />
EndPage(pd.hDC); <br />
StartPage(pd.hDC); <br />
nCurPage ++; <br />
} <br />
CString subitem = pListCtrl->GetItemText(j, ca[j].nSubItemIndex); <br />
TextOut(pd.hDC, ca[j].nPrintX,nYMargin+(j+1-(nCurPage-1)*nMaxLinePerPage)*nCharHeight,subitem, strlen(subitem)); <br />
<br />
<br />
} <br />
} <br />
EndPage(pd.hDC); <br />
EndDoc(pd.hDC); <br />
DeleteDC(pd.hDC); <br />
return TRUE; <br />
}
|
|
|
|
|
Please use the <pre> tags (use the 'code block' button)to post code snippets.
What do you mean with 'wrong result'? Please elaborate.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
For merging together some recording data stored in CSV files I have used the class CtextFile (by Johan Rosengren via the Codeproject site) to read in and write out the processed files. I also used class CNewStringArray (which is a modified version of CStringArray by Anders M Eriksson, again via the Codeproject)
I use the MFC function AfxExtractSubString() to extract the various fields of the CSV record and CnewStringArray variables to hold and process the data.
Now I have a problem where the size of some of the files to be processed may be in the order of 250 to 700Gb.
I have never used files larger that about 10Mb, but will I have problems with files these sizes and do I need to consider new methods of processing these very large files.
Any comments and advice please.
|
|
|
|
|
I'm not an expert on that topic, but I think you have to look at Memory Map Files .
That will let you navigate the file without having to load the whole file in memory.
Watched code never compiles.
|
|
|
|
|
Yes, you definitely are better off using memory mapped files,
namely, you should use "CreateFileMapping", "MapViewOfFile", "UnmapViewOfFile" and the likes.
It is a bit outdated, but the book from Jeffrey Richter
"Programming Applications for Microsoft Windows" has a good introduction to such an API.
Maybe, looking into MSDN with these pointers will lead you to the correct API to use
for your Operating System version.
Cheers
Federico
yeap, it is still the same API in latest versions of Windows, just checked on MSDN:
http://msdn.microsoft.com/en-us/library/aa366537(v=VS.85).aspx
modified on Thursday, May 19, 2011 7:51 AM
|
|
|
|
|
Thanks Federico for your post.
I have used these API's, but for large auto generated data structures ~ 50k bytes.
I did look at he link you gave and the following concerns me:-
If the file mapping object is backed by the operating system paging file (the hfile parameter is INVALID_HANDLE_VALUE), specifies that when a view of the file is mapped into a process address space, the entire range of pages is committed rather than reserved. The system must have enough committable pages to hold the entire mapping. Otherwise, CreateFileMapping fails.
With files sizes of ~ 500GB will these APIs work?
Andy.
|
|
|
|
|
Hello Andy,
what follows is extracted from the book from Jeffrey Richter
"Programming Applications for Microsoft Windows"
It is written for a 32bit O.S. so be careful to adapt it in case you work on Win 7
--- start ---
Processing a Big File Using Memory-Mapped Files
In an earlier section, I said I would tell you how to map a 16-EB file into a small address space.
Well, you can't. Instead, you must map a view of the file that contains only a small portion of the file's data.
You should start by mapping a view of the very beginning of the file.
When you've finished accessing the first view of the file, you can unmap it and then map a new view
starting at an offset deeper within the file. You'll need to repeat this process until you access the complete file. This certainly makes dealing with large memory-mapped files less convenient, but fortunately most files are small enough that this problem doesn't usually come up.
Let's look at an example using an 8-GB file and a 32-bit address space.
Here is a routine that counts all the 0 bytes in a binary data file in several steps:
__int64 Count0s(void) {
SYSTEM_INFO sinf;
GetSystemInfo(&sinf);
HANDLE hFile = CreateFile("C:\\HugeFile.Big", GENERIC_READ,
FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL);
HANDLE hFileMapping = CreateFileMapping(hFile, NULL,
PAGE_READONLY, 0, 0, NULL);
DWORD dwFileSizeHigh;
__int64 qwFileSize = GetFileSize(hFile, &dwFileSizeHigh);
qwFileSize += (((__int64) dwFileSizeHigh) << 32);
CloseHandle(hFile);
__int64 qwFileOffset = 0, qwNumOf0s = 0;
while (qwFileSize > 0) {
DWORD dwBytesInBlock = sinf.dwAllocationGranularity;
if (qwFileSize < sinf.dwAllocationGranularity)
dwBytesInBlock = (DWORD) qwFileSize;
PBYTE pbFile = (PBYTE) MapViewOfFile(hFileMapping, FILE_MAP_READ,
(DWORD) (qwFileOffset >> 32),
(DWORD) (qwFileOffset & 0xFFFFFFFF),
dwBytesInBlock);
for (DWORD dwByte = 0; dwByte < dwBytesInBlock; dwByte++) {
if (pbFile[dwByte] == 0)
qwNumOf0s++;
}
UnmapViewOfFile(pbFile);
qwFileOffset += dwBytesInBlock;
qwFileSize -= dwBytesInBlock;
}
CloseHandle(hFileMapping);
return(qwNumOf0s);
}
This algorithm maps views of 64 KB (the allocation granularity size) or less.
Also, remember that MapViewOfFile requires that
the file offset parameters be a multiple of the allocation granularity size.
As each view is mapped into the address space, the
scanning for zeros continues. After each 64-KB chunk of the file has been mapped and scanned,
it's time to tidy up by closing the file-mapping object.
--- end ---
Cheers
Federico
|
|
|
|
|
Thanks Federico for the information. The requirement has gone away, but I thought that it would be good to do this task (a worked example) should I ever need to revist this problem again.
Just one follow up question you suggest 64 KB (the allocation granularity size)?
Is this from expericence? And the best value.
Andy
|
|
|
|
|
Hi,
the allocation granularity size, if you look at the code, is system dependent:
SYSTEM_INFO sinf;
GetSystemInfo(&sinf);
[... snipped ...].
DWORD dwBytesInBlock = sinf.dwAllocationGranularity;
I don't know the values for recent Windows OS's, I cited 64Kb just to say a size,
you may just get them from the API (GetSystemInfo).
As far as what would be the best value, I would say that you should map in multiples of
such allocation size and other considerations (as available memory for the system and/or the single
process) come into play.
You may have to experiment a bit to find the best for your requirements.
Cheers
Federico
|
|
|
|
|
250 to 700GB of data or is it a typo error???? if its 250 to 700 Gb of data, where are your data stored??
|
|
|
|
|
Andy202 wrote: For merging together some recording data stored in CSV files I have used the
class CtextFile (by Johan Rosengren via the Codeproject site) to read in and
write out the processed files.
Presumably you are doing something more than just creating one file out of two.
Consequently your design with much larger files, needs to take into account specifically what you need to do.
And if it was me I would also look into the business requirement that requires that the output be another file. Pretty pointless to parse a large file and then parse it again.
|
|
|
|
|
Thanks for your post jschell.
Two input files to generate one output file.
Input1 sampled at 50 msec and Input2 sampled at 200 msec, so using timing information merge the two sets of data into one output file; interporlate as required.
I can do what is required if the files were as follows:-
Input1 = 1 Mb; Input2 = 2Mb and Output = 5Mb.
Andy
|
|
|
|
|
Andy202 wrote: Input1 sampled at 50 msec and Input2 sampled at 200 msec, so using timing information merge the two sets of data into one output file; interporlate as required.
So you have one 'block' (perhaps one line or longer) from file 1 that exists every 50msec. Call this X.
You have another 'block' from file 2 that exists every 200msec. Call this Y.
Thus you have 4 (200msec/50msect) X entries before each Y entry.
Steps
1. Build a buffered reader for each file. Buffered in the case reads N 'block' entries and allows it to read M more on request. The timestamp is exposed (parsed from the block.)
2. Read X via the buffer where N is 200.
3. Read Y via the buffer where N is also 200 (could be less as well.)
4. Now 2 will have data that fits into 3. Because you have read enough to overlap.
5. Step 4 represents a starting point. Basically the two buffers will mostly be off by 4.
6. You can't assume it will always be offset by 4 so continue to compare the two timestamps as you read.
7. On start up you need to sync the two buffer reads, since one file might have a much different start time from the other.
Performance impacts
- Play with the stream buffer sizes (actual file read versus buffered readers above.)
- Profile it with a tool for some large and real files, say 50 meg at least.
|
|
|
|
|
I would like to create a dialog box which contains an embedded Excel workbook. (Excel is installed on the computer, of course.) MS provides example code showing how to do something like this with a Document/View based app, but not in a dialog.
(I saw from searching this forum that there was a discussion about "Embedded Excel", but when I try to access it, I get an empty list with the message "Unable to load messages due to high load.")
|
|
|
|
|
You can go to the project tab and select Add to Project Sub menu. This menu has another sub menu. select the last option. Components and control
When you select that a windows dialog will pop up with 2 folders. Select the first one. Search for Microsoft Office SpreadSheet. Select that and click OK.
The spreadsheet will be embedded in your dialog.
|
|
|
|
|
I'm not sure what you mean by the "Project Tab" and "Add To Project". If I right-click on the solution, I get an item "Add New Project" and under that one of the possibilities is Visual C#/Microsoft Office/Excel Workbook, but I don't see how this will help me. Won't it just create a whole new project unrelated to my current one?
|
|
|
|
|
I should have mentioned that I am using VS2008
|
|
|
|
|
Forgot to mention, In the menu bar. There should be an option called Project. You should select that.
|
|
|
|
|
I still don't see this.
In VS2008, all I have under the "Project" menu or the right-click menu on the project is "Add New Item" and "Components and controls" is not a selection from the dialog I get from that.
|
|
|
|
|
What you can do is, Right click on the Dialog. You will get an option. Insert ActiveX Control. You will get the same component here also. Here you can select Microsoft Office SpreadSheet 11.0 or 10.0.
Hope it helps
|
|
|
|