Graphics* graph; doesn't work

I just opened a project in Visual Studio 2005 beta 2(c++) and I want to draw, but I cannot declerate Graphics and Pen.

My code:

#pragmaonce

namespace TicTacToe

{

usingnamespace System;

usingnamespace System::ComponentModel;

usingnamespace System::Collections;

usingnamespace System::Windows::Forms;

usingnamespace System::Data;

usingnamespace System::Drawing;

publicrefclass Form1 :public System::Windows::Forms::Form

{

private:

Graphics* graph;

Pen* pen;

public:

Form1(void)

{

InitializeComponent();

graph=this->CreateGraphics();

pen=gcnew Pen(Color::Black);

graph->DrawLine(pen, 20,20, 100, 200);

}

protected:

///<summary>

/// Clean up any resources being used.

///</summary>

///<param name="disposing">"description of the parameter"</param>

virtualvoid Dispose(Boolean disposing)override

{

if (disposing && components)

{

delete components;

}

__super::Dispose(disposing);

}

private:

///<summary>

/// Required designer variable.

///</summary>

System::ComponentModel::Container ^components;

#pragmaregion Windows Form Designer generated code

///<summary>

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

///</summary>

void InitializeComponent(void)

{

this->components =gcnew System::ComponentModel::Container();

this->Size = System::Drawing::Size(300,300);

this->Text = L"Form1";

this->Padding = System::Windows::Forms::Padding(0);

this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;

}

#pragmaendregion

};

}

Pls let me know what is wrong or which settings I have to chance.

The error messages are:

Error 1 error C3699: '*' : cannot use this indirection on type 'System::Drawing::Graphics' c:\markus\spiele\tic tac toe\tic tac toe\Form1.h 16

Error 2 error C3699: '*' : cannot use this indirection on type 'System::Drawing::Pen' c:\markus\spiele\tic tac toe\tic tac toe\Form1.h 17

[6026 byte] By [Markus1982] at [2007-12-16]
# 1

Use "^" instead of "*".

That is to say:

Graphics^ graph;

Pen^ pen;

Here is a small sample describing the change you can do:
using namespace System;
int main() {
String * s; // C3699
// try the following line instead
// String ^ s2;
}

Thanks,
Ayman Shoukry
VC++

AymanShoukry at 2007-9-9 > top of Msdn Tech,Visual C++,Visual C++ General...
# 2
"*" is old systax and is only supported under "/clr:oldsyntax" conpiler switch. As said use "^"!

Bye
Martin

maddin123 at 2007-9-9 > top of Msdn Tech,Visual C++,Visual C++ General...
# 3
I don'T know how to program that. Is there any homepage where I can see the differnces to the normal/old C++.

Or can anybody tell me where I can switch to the old one.

If anybody knows pls help me. If it would be possible I would like to know both.

Thanks

Markus1982 at 2007-9-9 > top of Msdn Tech,Visual C++,Visual C++ General...
# 4

I wrote an article for MSDN introducing the new C++/CLI syntax. You can read it here:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnvs05/html/vs05cplus.asp

Cheers,

Kenny Kerr

Microsoft MVP

http://weblogs.asp.net/kennykerr/

KennyKerr at 2007-9-9 > top of Msdn Tech,Visual C++,Visual C++ General...
# 5
For Example how can I write:

graph=Form::CreateGraphics();

error message is:

Error 1 error C2352: 'System::Windows::Forms::Control::CreateGraphics' : illegal call of non-static member function c:\Markus\Spiele\Tic Tac Toe\Tic Tac Toe\tic tac toe.cpp 23

Markus1982 at 2007-9-9 > top of Msdn Tech,Visual C++,Visual C++ General...
# 6
If anybody can tell me how I can create the Graphics object I would really appreciate, because otherwise I cannot start and I cannot find it anywhere.

Thanks for you help.

Markus1982 at 2007-9-9 > top of Msdn Tech,Visual C++,Visual C++ General...
# 7
And the question is still left how can I program the old C++ with Visual studio, where do I have to change something?
Markus1982 at 2007-9-9 > top of Msdn Tech,Visual C++,Visual C++ General...
# 8
Hello,
Markus, you were already told the answer; instead of
Graphics* graph;
do
Graphics^ graph;
Same goes to pen.
Gal Beniamini.
GalBeniamini at 2007-9-9 > top of Msdn Tech,Visual C++,Visual C++ General...