Results 1 to 7 of 7

Thread: Help! This one is too simple

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2000
    Location
    Mexico
    Posts
    25

    Unhappy 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....)

    The 'H' ^_^

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Oct 2000
    Location
    Mexico
    Posts
    25

    Unhappy Help! too easy for answer

    I'm new in Windows programming Visual C++ 5.0, i got a book to learn.....
    The 'H' ^_^

  4. #4
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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

  5. #5
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    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.
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Oct 2000
    Location
    Mexico
    Posts
    25

    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.
    The 'H' ^_^

  7. #7
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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
  •  



Click Here to Expand Forum to Full Width