Click here to Skip to main content
15,887,175 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am writing an SDI explorer-style MFC application. I wish to open a file into the right pane, which is derived from a CView class.

I have read the file into a buffer and passed this to SetWindowText(buffer) to display the file contents. Although 'buffer' contains all the text, not all of it is displayed in the view. However, if I then call GetWindowTextLength, it returns the correct length. In the code below, dwLength, nActual and windowTextLength are all equal and their value is 133 220. This matches the files size of 133 220 bytes. The size of the text displayed appears to be only 13 633 bytes (I estimated this by deleting the contents that are not displayed and checking the file size).
C++
//read file
CFile* pFile = new CFile(filePathAndName, CFile::modeRead);
ULONGLONG dwLength = pFile->GetLength();//I64u
char* buffer = new char[(int)dwLength + 1];//add one extra to make space for null terminator
buffer[dwLength] = 0; //This will make the last character a null terminator
UINT nActual = pFile->Read(buffer, static_cast<UINT>(dwLength));//sizeof(szBuffer));
	
//convert char* buffer to LPCTSTR
CString strLPCTSTR (buffer);
m_displayData = strLPCTSTR;

SetWindowText(m_displayData);

int windowTextLength = GetWindowTextLength();


Please, does anyone have any idea why all my data is not displayed? Or is there an alternative way to do this?
Many thanks.
Posted
Updated 10-Jan-12 2:48am
v2

1 solution

er, sorry to anyone who has looked at this - I have just noticed a few things which mean this posting is irrelevant. Please ignore.
 
Share this answer
 
Comments
Albert Holguin 10-Jan-12 13:24pm    
I'm pretty sure you can delete your own question if need be. If not, I can certainly do so.
Jackie Lloyd 10-Jan-12 16:51pm    
yes please - I looked for a way to delete it but could not see one. Many thanks.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900