|
-
Aug 23rd, 2001, 06:48 PM
#1
Thread Starter
Junior Member
Help! This one is too simple
Hi!
Well, i'm starting with Visual C++ I'm learning in selfteaching mode and i've got a question for anyone.
How can i change the 'Caption' of a PushButton ???
(ridiculous right? but i don't know how....)
-
Aug 23rd, 2001, 06:52 PM
#2
Monday Morning Lunatic
Are you new to C++, or new to Windows programming with C++? If the former, I would seriously suggest learning the language first
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Aug 23rd, 2001, 06:56 PM
#3
Thread Starter
Junior Member
Help! too easy for answer
I'm new in Windows programming Visual C++ 5.0, i got a book to learn.....
-
Aug 23rd, 2001, 06:59 PM
#4
Monday Morning Lunatic
In that case, depending on how you created the button, you need to retrieve its window handle.
Code:
// Somewhere in your code
hWnd_Button = CreateWindow("BUTTON", ...); // And so on
// or
hWnd_Button = GetDlgItem(hWnd_Dlg, IDB_THEBUTTON);
Then, just use SetWindowText:
Code:
SetWindowText(hWnd_Button, "New caption!");
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Aug 24th, 2001, 04:46 AM
#5
Frenzied Member
If you are using a dialog then you can use
SetDlgItemText
The SetDlgItemText function sets the title or text of a control in a dialog box.
BOOL SetDlgItemText(
HWND hDlg, // handle of dialog box
int nIDDlgItem, // identifier of control
LPCTSTR lpString // text to set
);
Parameters
hDlg
Identifies the dialog box that contains the control.
nIDDlgItem
Identifies the control with a title or text that is to be set.
lpString
Pointer to the null-terminated string that contains the text to be copied to the control.
-
Aug 24th, 2001, 09:18 AM
#6
Thread Starter
Junior Member
Thanks!!!
Thank you, it helped and worked correctly. um, do you know where could i get VC++ samples? so i could learn faster...
Thanks again.
-
Aug 24th, 2001, 09:22 AM
#7
Monday Morning Lunatic
The Platform SDK is full of them 
Plus I've posted quite a few - search this forum if you need anything and I'm sure Vlatko, Chimp, or a variety of others have posted something.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|