MFC, Rich Edit HELP !!!
-
Please help me, I've been trying to solve this problem for more than a week now: I have to open a textfile with a common dialog box, put this file in a buffer, then I have to show this text in a richeditcontrol by calling the buffer. Oh, yeah: these text files are at least 1MEG big and I'm just getting started with MFC, glups ! Thanks if you can help me...
-
Please help me, I've been trying to solve this problem for more than a week now: I have to open a textfile with a common dialog box, put this file in a buffer, then I have to show this text in a richeditcontrol by calling the buffer. Oh, yeah: these text files are at least 1MEG big and I'm just getting started with MFC, glups ! Thanks if you can help me...
Check the 'Wordpad' MFC sample. Tomasz Sowinski -- http://www.shooltz.com
-
Please help me, I've been trying to solve this problem for more than a week now: I have to open a textfile with a common dialog box, put this file in a buffer, then I have to show this text in a richeditcontrol by calling the buffer. Oh, yeah: these text files are at least 1MEG big and I'm just getting started with MFC, glups ! Thanks if you can help me...
You could use SetText() or stream the text in with a callback function something like:
DWORD CALLBACK readText(DWORD dwFileHandle, LPBYTE lpBuffer, LONG nbrToRead,
LONG FAR* lpNbrRead)
{
BOOL file = ReadFile((HANDLE)dwFileHandle,lpBuffer, nbrToRead,
(unsigned long*)lpNbrRead, NULL);if(file == FALSE ){ AfxMessageBox(\_T("Could'n open file!"),MB\_ICONEXCLAMATION); return 1; } return 0;
}
and then call it with something like this:
EDITSTREAM stream; HANDLE hFil;//file to open fFormat = SF\_TEXT; strom.dwCookie = (DWORD)hFil; strom.pfnCallback = readText; m\_recText.StreamIn( fFormat, strom );//RichEditCtrl
/Per
-
Check the 'Wordpad' MFC sample. Tomasz Sowinski -- http://www.shooltz.com
-
Cannot open include file... Microsoft's products are perfect as always. What should I do? Lio.
mfc42ud.lib is not a header file - it's a library. Anyway, you should set the active configuration to non-unicode before building the sample. Tomasz Sowinski -- http://www.shooltz.com
-
You could use SetText() or stream the text in with a callback function something like:
DWORD CALLBACK readText(DWORD dwFileHandle, LPBYTE lpBuffer, LONG nbrToRead,
LONG FAR* lpNbrRead)
{
BOOL file = ReadFile((HANDLE)dwFileHandle,lpBuffer, nbrToRead,
(unsigned long*)lpNbrRead, NULL);if(file == FALSE ){ AfxMessageBox(\_T("Could'n open file!"),MB\_ICONEXCLAMATION); return 1; } return 0;
}
and then call it with something like this:
EDITSTREAM stream; HANDLE hFil;//file to open fFormat = SF\_TEXT; strom.dwCookie = (DWORD)hFil; strom.pfnCallback = readText; m\_recText.StreamIn( fFormat, strom );//RichEditCtrl
/Per