Change Text of a CText Static

I have several CText static text areas on a dialog in my application.  I'm trying to change the text contained within them when certain events occur.  Specifically, I'm trying to print the name of the file opened to the static text control.  I have all the code in place to give me the filename from CFileDialog, but cannot implement the change to the static text controls.  I previously did this with edit boxes, but I would like to convert to static texts for a more polished look.  I was thinking along the lines of getting a pointer to the control and using *ptr->SetWindowText(str_Text) but was unable to do it.  I would appreciate any help offered.  Thanks in advance.
klax33Asked:
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.

AlexFMCommented:
GetDlgItem(IDC_STATIC_TEXT)->SetWindowText(_T("New text"));
0

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
klax33Author Commented:
That code compiles and builds but gives a "memory could not be read" error.  Also, when you try to just type the first part GetDlgItem(STATIC_TEXT)-> the listbox with all the possible functions does not pop up as it normally does.  [I am using Visual C++ 6.0].  
0
klax33Author Commented:
Thanks for your quick response AlexFM.  You are correct in your code fragment.  However I did not use a unique identifier to my static control and since IDC_STATIC is shared, it was causing a memory error.  jhance who answered my identical double post mentioned that I needed a unique identifier.  You code works and is the most concise so you get the points.  Thanks again.
0
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.