Solved

Setting pushbutton caption

Posted on 1998-08-14
3
209 Views
Last Modified: 2013-11-20
I'm pretty new to MFC, and I have the following problem:

I simply want to change the the caption of a pushbutton so that when the user clicks it, the text changes from "Start" to "Stop"or vice versa. I don't want to use bitmaps, and I don't want to create two buttons and show/hide them - I would like to learn how to programatically change the text of just one button.

In an MFC created dialog-based app called MyTest, with classes MyTest and MyTestDlg, and a pushbutton called  ID_START_STOP, how do I implement this feature ?

Thanks a lot,

Boedeker



0
Comment
Question by:boedeker
[X]
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
  • 2
3 Comments
 
LVL 6

Expert Comment

by:snoegler
ID: 1320781
The following lines must be placed in your CDialog object
(perhaps in the OnStartStop handler function):

CString newCaption;
// set newCaption to the desired text
GetDlgItem(ID_START_STOP)->SetWindowText(newCaption);

I would suggest that you re-open this question with 50 points - 100 points are really much for
this question :) :) :)

0
 

Author Comment

by:boedeker
ID: 1320782
Thanks for the answer snoegler - it works fine, so post anything as an answer and I'll give you the points :)


Boedeker
0
 
LVL 6

Accepted Solution

by:
snoegler earned 100 total points
ID: 1320783
Thanks :)
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying 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

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

688 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