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....)
:(
Printable View
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....)
:(
Are you new to C++, or new to Windows programming with C++? If the former, I would seriously suggest learning the language first :)
I'm new in Windows programming Visual C++ 5.0, i got a book to learn.....
In that case, depending on how you created the button, you need to retrieve its window handle.Then, just use SetWindowText:Code:// Somewhere in your code
hWnd_Button = CreateWindow("BUTTON", ...); // And so on
// or
hWnd_Button = GetDlgItem(hWnd_Dlg, IDB_THEBUTTON);
Code:SetWindowText(hWnd_Button, "New caption!");
If you are using a dialog then you can use
Quote:
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.
Thank you, it helped and worked correctly. um, do you know where could i get VC++ samples? so i could learn faster...
Thanks again.
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.