Am new to C++ and don't know if I'm doing something fundementally wrong. Have a form with a textbox and buttons. When I click on button, I am running a function in my .cpp file. However, in this function I need to update the text box in the form. Have created a public function set_address in the .h file form1 class definition that uses the following code.
public:
void Form1::set_address(char *add)
{
char temp_str[80];
sprintf(temp_str,add);
textBox1->AppendText(temp_str);
}
When I call it from my .cpp file with
Form1* pFm = new Form1;
pFm->set_address(temp_str);
It compiles OK and even runs the code, but the text box is not updated. If however I call the function from a clickbutton
private: System::Void button1_Click(System::Object * sender, System::EventArgs * e)
{
char temp_str[80];
sprintf(temp_str,"from button");
set_address(temp_str);
}
It happily updates the text box.
Have been pulling my hair out for 2 days, so any help would be GREATLY appreciated
Using Microsoft Visual C++.net Version 2003
Thanks
Dave C