[SOLVED]Windows Forms problems

Jun 6, 2008 at 11:42am
Hello,

I am a complete beginner with Windows Forms, and Microsoft's help file is not in the least bit helpful.
I am using Visual Studio 2005, and I am trying to make a simple app where you click a button, and it sets a label's text to whatever the user has entered into a textbox. However, I always get errors when running it.

1. When I try:
1
2
3
char* text;
text = textBox1->Text;
label1->Text = text;


It gives me errors regarding "char*"



2. MyForm.cpp has this code:
1
2
3
4
5
6
7
#include "MyForm.h"

int __stdcall WinMain()
{
	Application::Run(new MyForm());
	return 0;
}


But it gives me an error "Syntax error: identifier 'MyForm' "


Any help with a simple app like this would be really appreciated!

Regards,
Chris Matthews
Last edited on Jun 6, 2008 at 8:24pm
Jun 6, 2008 at 11:58am
closed account (z05DSL3A)
Point 1: Try:
1
2
3
System::String ^ text;
text = textBox1->Text;
label1->Text = text;


Point 2: That is harder to answer.
How did you creat the project?
Jun 6, 2008 at 2:49pm
Point 1 worked, thank you!

Point 2:
I created it using the project wizard. If you have MSN or something, I could send you the project files?

Thanks,
Chris
Jun 6, 2008 at 3:46pm
closed account (z05DSL3A)
Sorry, I don't accept mail from 'strangers'.

Was it the Windows Forms Application wizard under CLR or a different one? The reason I ask is that my copy of Visual Studio 2005 produces code like this when I run the Windows Forms Application wizard.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include "stdafx.h"
#include "Form1.h"

using namespace test;

[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());
	return 0;
}


Jun 6, 2008 at 4:01pm
Thats the same wizard I used, but mine doesn't generate code like that... Maybe I'll try it again and see.

Sorry about the mail thing, no offence intended.

Thanks,
Chris

EDIT
Hey Grey Wolf,
I ran the wizard again, and it worked perfectly! Thanks for your help, not sure what happened the first time.

Many Thanks,
Chris Matthews
Last edited on Jun 6, 2008 at 4:05pm
Jun 6, 2008 at 4:09pm
closed account (z05DSL3A)
Sorry about the mail thing, no offence intended.

Non taken. :0)

Topic archived. No new replies allowed.