Click here to Skip to main content
15,909,437 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: loading .chm help file with vc++ Pin
HENDRIK R12-Feb-03 21:10
HENDRIK R12-Feb-03 21:10 
GeneralStatic Members, etc Pin
BigDaddyDrew11-Feb-03 14:49
sussBigDaddyDrew11-Feb-03 14:49 
GeneralRe: Static Members, etc Pin
Chris Losinger11-Feb-03 15:14
professionalChris Losinger11-Feb-03 15:14 
GeneralRe: Static Members, etc Pin
11-Feb-03 15:21
suss11-Feb-03 15:21 
GeneralRe: Static Members, etc Pin
Anonymous11-Feb-03 15:39
Anonymous11-Feb-03 15:39 
GeneralRe: Static Members, etc Pin
Kant11-Feb-03 15:44
Kant11-Feb-03 15:44 
GeneralWriting Files Pin
orcblood11-Feb-03 13:44
orcblood11-Feb-03 13:44 
GeneralRe: Writing Files Pin
MAAK11-Feb-03 23:24
MAAK11-Feb-03 23:24 
If I understand you right, you want to read text from file and load it into and Edit control.

If it is so then this is sample code for both reading both ANSI and UNICODE text files:
<code>
       CFile f;
       if(f.open("FILENAME.TXT, CFile::modeRead))
       {
           DWORD dwFLen = f.GetLength();
           //this short will be used to get the file header
           USHORT usHeader;
           f.Read(&usHeader, sizeof(USHORT));

           //UNICODE text files starts with value 0xFEFF
           if(usHeader == 0xFEFF)
           {
               //we are going to load the text into a character array
               wchar_t * filetxt;
               
               //allocate a charaters array one for null terminator
               filetxt = new wchar_t[dwFLen + 1];

               //clear the filetxt array
               memset(filetxt, 0, sizeof(wchar_t) * (dwFLen + 1));
               f.Read(filetxt, dwFLen);

               //use API function rather than MFC to be able
               //to read UNICODE and ANSI at the same time
               ::SetDlgItemTextW(this->GetSafeHwnd(), IDC_EDIT1, filetxt);
           }
           else
           {
               //ANSI files does not contain any headers, so we should
               //reset the file pointer
               f.SeekToBegin();
           
               //we are going to load the text into a character array
               char * filetxt;
               
               //allocate a charaters array one for null terminator
               filetxt = new char[dwFLen + 1];

               //clear the filetxt array
               memset(filetxt, 0, sizeof(char) * (dwFLen + 1));
               f.Read(filetxt, dwFLen);

               //use API function rather than MFC to be able
               //to read UNICODE and ANSI at the same time
               ::SetDlgItemTextA(this->GetSafeHwnd(), IDC_EDIT1, filetxt);
           }
           f.Close();
       }
</code> 

GeneralRe: Writing Files Pin
orcblood12-Feb-03 10:58
orcblood12-Feb-03 10:58 
GeneralRe: Writing Files Pin
MAAK12-Feb-03 13:58
MAAK12-Feb-03 13:58 
GeneralCustom Dialogs Pin
orcblood11-Feb-03 13:40
orcblood11-Feb-03 13:40 
GeneralRe: Custom Dialogs Pin
PJ Arends11-Feb-03 13:47
professionalPJ Arends11-Feb-03 13:47 
GeneralRe: Custom Dialogs Pin
orcblood11-Feb-03 14:26
orcblood11-Feb-03 14:26 
GeneralRe: Custom Dialogs Pin
PJ Arends11-Feb-03 15:07
professionalPJ Arends11-Feb-03 15:07 
Generalwindow background Pin
Perseus11-Feb-03 13:09
Perseus11-Feb-03 13:09 
GeneralRe: window background Pin
HENDRIK R11-Feb-03 21:22
HENDRIK R11-Feb-03 21:22 
QuestionModeless Dialog Doesn't Destroy During WM_CLOSE? Pin
Dan Wilson11-Feb-03 11:19
Dan Wilson11-Feb-03 11:19 
AnswerRe: Modeless Dialog Doesn't Destroy During WM_CLOSE? Pin
Joaquín M López Muñoz11-Feb-03 11:26
Joaquín M López Muñoz11-Feb-03 11:26 
GeneralRe: Modeless Dialog Doesn't Destroy During WM_CLOSE? Pin
Dan Wilson12-Feb-03 3:23
Dan Wilson12-Feb-03 3:23 
AnswerRe: Modeless Dialog Doesn't Destroy During WM_CLOSE? Pin
valikac11-Feb-03 12:20
valikac11-Feb-03 12:20 
GeneralXML-safe strings, and iostreams Pin
Simon Steele11-Feb-03 11:10
Simon Steele11-Feb-03 11:10 
GeneralRe: XML-safe strings, and iostreams Pin
palbano11-Feb-03 11:13
palbano11-Feb-03 11:13 
GeneralRe: XML-safe strings, and iostreams Pin
Simon Steele11-Feb-03 11:42
Simon Steele11-Feb-03 11:42 
GeneralRe: XML-safe strings, and iostreams Pin
Simon Steele11-Feb-03 11:46
Simon Steele11-Feb-03 11:46 
QuestionHow to draw password bullets in an edit control on XP? Pin
Brian Morearty11-Feb-03 10:30
Brian Morearty11-Feb-03 10:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.