Change Text of a CText Static

Posted on 2003-02-24
Medium Priority
Last Modified: 2013-11-20
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.
Question by:klax33
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 32

Accepted Solution

jhance earned 400 total points
ID: 8008770
1) Change the ID of the static control from the default IDC_STATIC (which is shared among all static controls) to something unique.

2) In your code, you can use the CWnd member function SetDlgItemText(IDC_STATIC_ID, "New Text");

Author Comment

ID: 8008982
Exactly what I needed.  Thanks for the quick and correct response jhance.

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question