button click

This is a discussion on button click within the C++ Programming forums, part of the General Programming Boards category; No. C++/CLI is not an extension! It's a new language that cares strongly about backwards compatibility to C++. Stringer : ...

  1. #16
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,892
    No. C++/CLI is not an extension! It's a new language that cares strongly about backwards compatibility to C++.

    Stringer: no offence, but you apparently don't really understand scoping or classes. Please, do yourself a favour and learn the basics of C++ first. Then, if you really, really need to, you can learn C++/CLI. The way you're doing it now, you'll only get confused and write code that will eventually be featured on http://www.thedailywtf.com/ . It is the wrong approach.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  2. #17
    Registered User
    Join Date
    Oct 2006
    Posts
    14
    after some messing around with everything I figured out how to change the label text by putting the form1 class constructor in the source file.


    But the only way I can figure out how to do an action when a button is clicked is to make another class and have a switch in it so when a button is clicked it passes an int value to the switch to identify which button was clicked and then put whatever code I want in the case. This seems kind of jerryrigged(better word?) to me though, I dont think I should have to have another class that has to sort out which button was clicked and then do whatever

  3. #18
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,892
    No you shouldn't. The button_Clicked method is passed an event object, which contains a reference to the button that was clicked.

    I wish you would have followed my advice. Then you wouldn't have to ask questions like this.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  4. #19
    Registered User
    Join Date
    Oct 2006
    Posts
    14
    ok your right, I just had to declare my functions in the header file and everything worked like that.

    I just want to finish this one program im making and then learn everything the right way later, I know it sounds stupid but im determined


    so I got the button click stuff figured out, now im just trying to dynamically change the text of a label. My problem with this is that I need to use "sprintf" to create a string but I cant pass that string to the label's text because it requires a System::String^ object. So how can I get the contents of a character array string to a System::String^ object?

  5. #20
    Registered User
    Join Date
    Oct 2006
    Posts
    14
    Just found out how to do the label text problem, Converting a text box value into a character array?

  6. #21
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,892
    Don't use sprintf. Use Format instead. I forgot which class it is part of. That way, you're always working with System::String.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Creating a function pointer from a button click event?
    By dxfoo in forum Windows Programming
    Replies: 20
    Last Post: 01-29-2008, 02:35 AM
  2. Button click out of WM_COMMAND
    By Sober in forum Windows Programming
    Replies: 8
    Last Post: 05-03-2007, 09:07 PM
  3. Updating window after button click?
    By ac251404 in forum Windows Programming
    Replies: 0
    Last Post: 07-18-2006, 10:20 AM
  4. Click button on dialog box to open window.
    By ooosawaddee3 in forum Windows Programming
    Replies: 1
    Last Post: 11-29-2002, 07:53 AM
  5. Replies: 6
    Last Post: 04-20-2002, 06:35 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21