|
Fine, but in the second case you are drawing at Point(0, 0) !
The best things in life are not things.
|
|
|
|
|
grpx.DrawImage(m_img, 0, 0, m_img->GetWidth(),m_img->GetHeight());
why don't you try using same rect.left and rect.top instead of 0,0 in drawimage??
Regards,
Gopinath.
|
|
|
|
|
Hello
How can i create one button for two events?
For example: I want to have one button for start/stop.
At the beginning of the application button name is start (start the event ), when I click the button second time it change the name to Stop (stop the event)????
I am very new to C# programming, i know to do this in VB6... Sorry for my bad english!
ThankYou
|
|
|
|
|
This is in the wrong forum, try the C# forum next door...
|
|
|
|
|
About the best redirect I've seen here. +5
Peter
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
glad you liked it...
|
|
|
|
|
|
Hi
Any sample or help?
Thanks
www.logicsims.ir
|
|
|
|
|
Hi,
Take a look at thisexample, it does detail the AT codes etc that may help you...
|
|
|
|
|
Hi all,
How can i browse image and display on dialog.Any good links for this.
Thanks
Manju
|
|
|
|
|
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??
|
|
|
|
|