본문 바로가기
Windows/MFC

MFC 리치에디터2.0 컨트롤의 내용을 txt파일로 저장

by Planetis 2015. 1. 23.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
DWORD CALLBACK MyStreamOutCallback(DWORD dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb)
{
    CFile* pFile = (CFile*)dwCookie;
    pFile ->Write(pbBuff, cb);
    *pcb = cb;
  
    return 0;
}
 
void CRichEditCtrlSave() {
    CFileException ex;
    CFile file;
    EDITSTREAM es;
 
    CString str("파일명.txt");
     
    file.Open(str, CFile::modeCreate | CFile::modeWrite, &ex);
  
    es.dwCookie = (DWORD) &file;
    es.pfnCallback = MyStreamOutCallback;
    컨트롤_변수명.StreamOut(SF_TEXT, es);
  
    file.Close();
}


320x100

댓글