Please check the following link for the solution http://www.codeproject.com/script/comments/forums.asp?forumid=1647&mode=all&userid=161454&select=491032&df=100&fr=16230.5#xx491032xx
Hari Krishnan Noida
Posts
-
can not access the calss view???? -
Check if file existe, get temporary file name?Hi, 1. Check File exists CFileFind chkFileExistence; if(chkFileExistence.FindFile(strFileName)) { //File exists }else{ //File does not exists } 2. Creating Temporary File Name You can use different methods to create a temporary file name. My suggestion, try to create a file name with Date & Time. Hope this helps. regards ~Hari~
-
Opening foldersHi, Try the following code, it will open the specified folder in explorer. void UserDialog::OnButtonClicked() { ShellExecute(GetSafeHwnd (), "open", "C:\\dave\\folder", NULL, NULL, SW_SHOWNORMAL); } regards ~Hari~
-
Memory leak detection... the best solution?Hi, Its not MFC. Basically, it uses _CRT... Functions/Flags only. But the thing is, CMemoryState is declared & defined AFX.H/AFXMEM.cpp respectively. Just have a look at the code, if possible write your own. Hope this helps.
-
Memory leak detection... the best solution?Hi, http://www.codeproject.com/script/comments/forums.asp?msg=491851&forumid=1647&mode=all&userid=161454#xx491851xx ----------------------------------------------------------- Hi, Regarding the technique of dumping in-memory statistics, is given below Note: memstate1 takes snapshot of pre-memory leak and memstate2 takes snapshot of post-memory leak. finally, memstate3 makes the statistics based on both the snapshots. CMemoryState memState1, memState2, memState3; void CHello::MakeMemoryLeak() { memState1.Checkpoint(); LPCTSTR strMemoryLeak = new char[50]; memState2.Checkpoint(); memState3.Difference(memState1, memState2); memState3.DumpStatistics(); } Hope this Helps Regards ~Hari~
-
CFile troubleHi, use "CFile::modeCreate" mode. It will truncate the file to 0, if the file is already exists(overwrite). Otherwise, it will create a new file. Hope this helps regards ~Hari~
-
How to locate an adress to write in a file?Hi, do you mean "Append"? regards ~Hari~
-
NM_RCLICKHi, For Left Mouse Button, it is just NM_CLICK. regards ~Hari~
-
How to delete a single line in a text file?Hi, consider CStdioFile::ReadString(It reads single line) and use intermediate buffer to write. Hope this Helps. regards ~Hari~
-
How to change the MFC iconHi, Here is the way to change the icon programmatically, CSomeApp::InitInstance() { ... ... pMainFrame->ShowWindow(m_nCmdShow); pMainFrame->UpdateWindow(); HICON hIcon = LoadIcon(IDR_CHANGED); pMainFrame->SetIcon(hIcon, TRUE); pMainFrame->SetIcon(hIcon, FALSE); } regards ~Hari~
-
center text in title bar of app.Hi, As, other members were suggested, its bit of complex coding. If you really want to do it, here is the link, and download "C++0697.exe" http://www.microsoft.com/msj/0697/c0697.aspx regards ~Hari~
-
center text in title bar of app.Hi, there was a working code on the net called "shadcap", originally written by "Paul DiLascia", Q&A author of MSJ Magaizine. Please search it on the net. Actually, I downloaded the code, just few days back. I couldnt find the link now. Please search it on the net. Otherwise, I can send u the code.
-
Memory LeakHi David, if you see the memory contents of (pStrWord), it contains 5 (CD - valid memory allocated) and 4 FD(padded memory, # may differ) (Note: Assume that nStrLength is 5) Following code lines, are writing on unallocated memory. pStrWord[nWordIndex++] = ' '; //This causes the problem. pStrWord[nWordIndex] = '\0'; _tcscat(pStrFinal,_tcsrev(pStrWord)); as well, pStrFinal = _tcsrev(pStrFinal); //This assignment also causes the problem. Actually, he has to allocate the extra one byte of memory to put the space character (' '). Hopefully, I am right. regards ~Hari~
-
Memory LeakHi, Regarding the technique of dumping in-memory statistics, is given below Note: memstate1 takes snapshot of pre-memory leak and memstate2 takes snapshot of post-memory leak. finally, memstate3 makes the statistics based on both the snapshots. CMemoryState memState1, memState2, memState3; void CHello::MakeMemoryLeak() { memState1.Checkpoint(); LPCTSTR strMemoryLeak = new char[50]; memState2.Checkpoint(); memState3.Difference(memState1, memState2); memState3.DumpStatistics(); } Hope this Helps Regards ~Hari~
-
Can someone help, im new to C++Hi, Try with following code snippet. ---------------------------------------------------------- :)CString strSentence = "a do cat from hello thomas d"; int iLongest = 0; //Initialize with minimum value. int iShortest = 1024; //Initialize with Big Value int nIndex; //Backup. If you dont want you can remove CString strHelper(strSentence); while(!strHelper.IsEmpty()) { if(-1 == (nIndex = strHelper.Find(' ', 0))) { nIndex = strHelper.GetLength(); //Last word strHelper.Empty(); } if(nIndex < iShortest) iShortest = nIndex; if(nIndex > iLongest) iLongest = nIndex; strHelper.Delete(0, nIndex+1); //Remove including space. } ----------------------------------------------------------
-
CFileHi, As, franks mentioned, it happens because, the output is not null-terminated. Here's the code snippet, which very well read your file, without any memory leaks. ----------------------------------------------------------- CFile oFile; DWORD dwFileLength; if(oFile.Open("F:\\test\\id.txt", CFile::modeRead)) { try { CString strBuffer; dwFileLength = oFile.GetLength(); LPTSTR szBuffer = strBuffer.GetBufferSetLength(dwFileLength); oFile.Read((LPVOID)szBuffer, dwFileLength); oFile.Close(); CString csPath(strBuffer); strBuffer.ReleaseBuffer(); } catch(CFileException *e) { AfxMessageBox ("Error!"); e->Delete(); } } ----------------------------------------------------------- regards ~Hari~
-
Why have my Classes disappeared?Hi, The .ncb file contains ClassView browser information. I believe, some of your .ncb(if you're using multiple projects) file permission may have changed. That is the cause. To check that, create a sample program and change .ncb file to read-only. Now you reload the project, you will not be able to see any classes in the classview. Hope this helps, if not better you move all your .ncb files to some other location. so that your .dsw/.dsp will recreate your class view again. regards ~Hari~
-
dynamic creation of buttons and tooltips?Hi, You need to relayevent to the tooltip control. Otherwise, how tooltip control will know when & where to show what? Also, whether you are using CTooltipCtrl? If so, then you have to add some more stuff also like addtool, etc.. regards ~Hari~
-
How to delete entire row in CListCtrl?Hi, You do the following, m_LCtrlPtr->DeleteItem(m_LCtrlPtr->GetSelectionMark()); This will delete the currently selected item in the list control. GetSelectionMark() is to retrieve the currently selected item. hope this helps!! regards ~Hari~
-
Execution problem with TrackPopupMenu, help !!!Hi, do the following things, 1. Declare CMenu Variable as a member variable 2. Load the menu, during initialization. 3. And, try now, it should work. regards ~Hari~