Archived

This topic is now archived and is closed to further replies.

communicating with forms

This topic is 5110 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

how do i make forms communicate with eachother in C++, say i want to click a button on form 1 and it will put text into a textbox on form2, i tried form2->textBox1->set_Text("text") but apparently that fails to work, all help appreciated, thanks gamedev, you rock!

Share this post


Link to post
Share on other sites
quote:
Specify what GUI you are using and people might have a chance to help you
Most likely .NET forms.
quote:
how do i make forms communicate with eachother in C++, say i want to click a button on form 1 and it will put text into a textbox on form2, i tried form2->textBox1->set_Text("text")
but apparently that fails to work, all help appreciated, thanks gamedev, you rock!
Almost every kind of interaction with an UI control raises an event, notifying you of what happened. So, if a button is pressed, a Click event is raised. To handle (to intercept) the event you need to assign it an event handler:
// in form 1
button->Click += new EventHandler(this, Button_OnClick);
Then, when the button is pressed, Button_OnClick will be called:

void Button_OnClick(EventArgs* e)
{
form2->textBox1->set_Text("text");
}


Edit: some how Button_OnClick became Button_whenclickedon... weird.

[edited by - Matsen on December 16, 2003 5:41:26 PM]

Share this post


Link to post
Share on other sites
quote:
Original post by simon10k
quote:
Original post by Anonymous Poster
C++ does have forms in C++ 7.0 .net


How does a programming language have forms?



If it''s in the language spec.

Which, however, is not the case for "C++ 7.0 .net".

Share this post


Link to post
Share on other sites