First time creating a form
Hello,
I'm using visual C++ to try and create a window which will display various bits and bobs from my program. For example, I have a text box which I want to fill with a list of strings generated by my program.
I have a function called addText() which I wrote in the form header file.
Code:
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
}
void addText(){
String ^ b = gcnew String("asd");
textBox1->AppendText(b);
}
...
My question is, how can I call this from my main cpp file? (forget for now that it doesn't have any parameters).
This is a section from my cpp file:
Code:
using namespace form;
[STAThreadAttribute]
int main(array<System::String ^> ^args)
{
// Enabling Windows XP visual effects before any controls are created
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
// Create the main window and run it
Application::Run(gcnew Form1());
Form1 fas;
fas.addText();
return 0;
}
This currently will compile, but will not display the text correctly. My confusion lies in how to access the form which is running. Presumably, a form is created, runs and is displayed by this line:
Application::Run(gcnew Form1());
By creating 'fas' am I not just creating a new form, which will not be displayed? How should I access the member functions of the form that is being displayed?
Cheers,