![]() |
|
#1
|
|||
|
|||
Change the caption on button when clickedHello,
I have made a rudimentary GUI with MFC. I have a button labeled "start". when this button is clicked, i want to change the label to "stop" and also have it do somethign different when the stop button is clicked (i.e. different from when the "start" button is clicked- although they are the same button). here is some of the relevant code: CPP / C++ / C Code:
thanks! ps. i read some tutorials on the web on mfc. i'm pretty new to it.. they all seem to be quite basic and say the same thing. do you know of any tutorials on message maps that list all of the things you can do with them? with the relevant functions. for example, there are functions to know when the left button on the mouse has been clicked. it would be nice to be able to read up on this! thanks. Last edited by LuciWiz : 15-Oct-2004 at 09:53.
Reason: Please insert your C code between [c] & [/c] tags
|
|||
|
#2
|
||||
|
||||
|
Ok, here's what you can do: first, create a member data of the dialog class
CPP / C++ / C Code:
Then, initialize it, as well as your button's text (I suppose you did create a button and mapped a variable on it - I'll call it m_button) CPP / C++ / C Code:
Now, lets implement the OnClick event for your button (just double-click it, or use ClassView - it's your choice really): CPP / C++ / C Code:
If you want to check whether your button is set on "start" or "stop" at any point in your application, just check onStart - a value of 0 means it is "stoped", a value of 1 the other thing Best regards, Luci __________________
Please read these Guidelines before posting on the forum "A person who never made a mistake never tried anything new." Einstein |
|
#3
|
|||
|
|||
|
Luci, I think i owe you a drink! thanks a lot for taking the time to help me out.
I am still having some problems tho. Here is the code where i create teh button: CPP / C++ / C Code:
start.SetWindowText("Start") is a line you wanted me to add in. Its not compiling. It says "error C2228: left of '.SetWindowTextA' must have class/struct/union type". I put the line in the function "CGUIWindow::CGUIWindow(char *a)". is that where you wanted me to put it? By the way, startButtonLabel is a global variable i created to test things. but, i can replace it with "start" and it displays start. you probably already knew that! lol.. but i thought i would just mention it. thanks again. |
|
#4
|
||||
|
||||
|
Quote:
I apologize for this. It is really a stupid mistake. I have NO idea how this slipped to me. I tested the code I gave you except for this line (I knew what it does start is a pointer to a button, so when you call a method of the respective object you need something like this: CPP / C++ / C Code:
dsmith warned someone about making this mistake here, and I thought to myself: "Who would make this mistake?"; well, here I am Sorry again. Quote:
Yup, figured it out Kind regards, Luci __________________
Please read these Guidelines before posting on the forum "A person who never made a mistake never tried anything new." Einstein |
|
#5
|
|||
|
|||
|
Hi there,
Sorry, i was away from work for a few days. That worked just great! thanks a ton! Drew. PS. I don't know how that got by me either! i was using -> in the line right above it! |
|
#6
|
|||
|
|||
Re: change the caption on button when clickedwannna ask, how to close the window after changing the captions?
that means when the captions on the button changes to stop image, i click it, i wanna close the pop up window... is it possible? here's my code for that part. CPP / C++ / C Code:
Thanks. |
Recent GIDBlog
Programming ebook direct download available by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Styling the browse button... | erniegerdie | Web Design Forum | 23 | 19-Jan-2006 23:25 |
| changing caption of static text control | Pandiani | MS Visual C++ / MFC Forum | 1 | 20-Sep-2004 02:38 |
| change statement | jilshi | Web Design Forum | 0 | 26-Apr-2004 23:40 |
| Article by the W3C - Cool URI's don't change | jrobbio | Web Design Forum | 4 | 28-Apr-2003 07:40 |
| using a button to change table contents. | demtro | MySQL / PHP Forum | 20 | 02-Mar-2003 16:07 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The