EDIT Box to load up a .TXT File

Ok I have asked this before in the past, but I'm slow to this MFC Visual C++ stuff. I don't know any of the terms, all I do know is that I'm using MS Visual C++ 6.0, and how to point and click and type in stuff and semi, know how to program in VC a little.

Anyway, if you are going to give me cut and past code from codeguru.com then please explain it to me simply where it needs to go.

I have my Dialog box, in the call CMyDialog, in the box I have a Edit box, I have a veriable assisnged to it, called m_Message. I want the edit box to load up a txt file (yes it will be less then 64K) into the edit box when the program is loaded. It's just a one window dialog box program. Where do I put this code once I do get it? If you are familr with MS' Visual C++ Program, if you could tell me where exactly to go.  Thanks very much.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Vinayak KumbarSr Program ManagerCommented:

I assume that the variable m_Message is of CString class. In  the OnInitDialog() of the dialog. U can load the file and then display it.

These will bethe steps in OnInitDialog()

1. Open the text file using CFile
CFile file;
if(file.Open("d:\\myfile.txt", CFile::modeRead))
char *chTemp = NULL;
int len = file.GetLength();
chTemp = new char[len + 1];
ZeroMemory(chTemp, len + 1);

file.Read(chTemp, len);
m_Message = chTemp;

delete chTemp;
chTemp = NULL;

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
In OnInitDialog() function of your CMyDialog class. If you do not have function from menu->Class-wizard->select MyDialog class->add functon for WM_INITDIALOG. read text file into buffer then copy to m_Message and then call UpdateData(FALSE).

Hope this helps
Vinayak KumbarSr Program ManagerCommented:

I forgot to tell. put this code before the OnInitDialog()'s
return TRUE;

So that it will update the edit box.

Hope this helps. If U want sample I will send it to U. give me Ur mailID.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.