Link to home
Start Free TrialLog in
Avatar of boedeker
boedeker

asked on

Setting pushbutton caption

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



Avatar of snoegler
snoegler

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 :) :) :)

Avatar of boedeker

ASKER

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


Boedeker
ASKER CERTIFIED SOLUTION
Avatar of snoegler
snoegler

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial