473,386 Members | 1,819 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Problems with this->CreateGraphics()

Hello Everyone,

I'm trying to just play with managed VC++. I just want to draw a box
on the form when it is clicked. Here is my click event handler

System::Void Test_Click(System::Object^ sender, System::EventArgs^ e)

{
// Create a Graphics object for the Control.
Graphics* g = this->CreateGraphics() ;

g->DrawRectangle(gcnew Pen(Color::Green, 1.0), 1, 1, 100, 100);
}

Trying to create a graphics object this way (Graphics* g =
this->CreateGraphics();)
I get this error:

Error 1 error C3699: '*' : cannot use this indirection on type
'System::Drawing::Graphics' c:\documents and settings\saul01\my
documents\visual studio
2005\projects\cc2\managedxp\managedxp\Test.h 77
Trying to create a graphics object this way (Graphics g =
this->CreateGraphics();)

Error 1 error C3767: 'System::Drawing::Graphics::Graphics': candidate
function(s) not accessible c:\documents and settings\saul01\my
documents\visual studio
2005\projects\cc2\managedxp\managedxp\Test.h 77
I'm using VS2005 and all the other code was generated by Visual Studio.

Thanks for the help, L. Lee Saunders

Dec 20 '05 #1
6 3890
Hello Everyone,

Further more, I cannot even create variable of type Graphics even in:

System::Void Test_Paint(System::Object^ sender,
System::Windows::Forms::PaintEventArgs^ e)

I get the same errors. I can though draw using:

e->Graphics->DrawRectangle(gcnew Pen(Color::Green, 1.0), 1, 1, 100,
100);

Thanks for the help, L. Lee Saunders

Dec 20 '05 #2
You can only draw your box while in the Paint event of your form. Thus, you
need something along the lines of (typed from memory, so might be a little
off):

void OnPaint( Object^, PaintEventArgs^ e ) override
{
Graphics graphics = e->Graphics ;
graphics->DrawRectangle(...) ;
}

However, the error you got is becuase you're mixing syntaxes. '*' is the
pointer character in 'old style' syntax, you need to use '^' in the new
syntax. And note you're (trying to) using both at the same time! : )

[==P==]

<sa******@hotmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
Hello Everyone,

I'm trying to just play with managed VC++. I just want to draw a box
on the form when it is clicked. Here is my click event handler

System::Void Test_Click(System::Object^ sender, System::EventArgs^ e)

{
// Create a Graphics object for the Control.
Graphics* g = this->CreateGraphics() ;

g->DrawRectangle(gcnew Pen(Color::Green, 1.0), 1, 1, 100, 100);
}

Trying to create a graphics object this way (Graphics* g =
this->CreateGraphics();)
I get this error:

Error 1 error C3699: '*' : cannot use this indirection on type
'System::Drawing::Graphics' c:\documents and settings\saul01\my
documents\visual studio
2005\projects\cc2\managedxp\managedxp\Test.h 77
Trying to create a graphics object this way (Graphics g =
this->CreateGraphics();)

Error 1 error C3767: 'System::Drawing::Graphics::Graphics': candidate
function(s) not accessible c:\documents and settings\saul01\my
documents\visual studio
2005\projects\cc2\managedxp\managedxp\Test.h 77
I'm using VS2005 and all the other code was generated by Visual Studio.

Thanks for the help, L. Lee Saunders

Dec 20 '05 #3
correction:

void OnPaint( Object^, PaintEventArgs^ e ) override
{
Graphics^ graphics = e->Graphics ; // important!!! :)
graphics->DrawRectangle(...) ;
}

"Peter Oliphant" <po*******@RoundTripInc.com> wrote in message
news:ep**************@TK2MSFTNGP14.phx.gbl...
You can only draw your box while in the Paint event of your form. Thus,
you need something along the lines of (typed from memory, so might be a
little off):

void OnPaint( Object^, PaintEventArgs^ e ) override
{
Graphics graphics = e->Graphics ;
graphics->DrawRectangle(...) ;
}

However, the error you got is becuase you're mixing syntaxes. '*' is the
pointer character in 'old style' syntax, you need to use '^' in the new
syntax. And note you're (trying to) using both at the same time! : )

[==P==]

<sa******@hotmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
Hello Everyone,

I'm trying to just play with managed VC++. I just want to draw a box
on the form when it is clicked. Here is my click event handler

System::Void Test_Click(System::Object^ sender, System::EventArgs^ e)

{
// Create a Graphics object for the Control.
Graphics* g = this->CreateGraphics() ;

g->DrawRectangle(gcnew Pen(Color::Green, 1.0), 1, 1, 100, 100);
}

Trying to create a graphics object this way (Graphics* g =
this->CreateGraphics();)
I get this error:

Error 1 error C3699: '*' : cannot use this indirection on type
'System::Drawing::Graphics' c:\documents and settings\saul01\my
documents\visual studio
2005\projects\cc2\managedxp\managedxp\Test.h 77
Trying to create a graphics object this way (Graphics g =
this->CreateGraphics();)

Error 1 error C3767: 'System::Drawing::Graphics::Graphics': candidate
function(s) not accessible c:\documents and settings\saul01\my
documents\visual studio
2005\projects\cc2\managedxp\managedxp\Test.h 77
I'm using VS2005 and all the other code was generated by Visual Studio.

Thanks for the help, L. Lee Saunders


Dec 20 '05 #4
Just to emphasize, this is not proper syntax:

Graphics* graphics ;

this is:

Graphics^ graphics ;

[==P==]
<sa******@hotmail.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
Hello Everyone,

Further more, I cannot even create variable of type Graphics even in:

System::Void Test_Paint(System::Object^ sender,
System::Windows::Forms::PaintEventArgs^ e)

I get the same errors. I can though draw using:

e->Graphics->DrawRectangle(gcnew Pen(Color::Green, 1.0), 1, 1, 100,
100);

Thanks for the help, L. Lee Saunders

Dec 20 '05 #5
Thanks Peter!

Why oh why does every example of Microsofts uses the * ?

I've seen examples with the ^ but I've never seen a discussion on what
it is or used for.

Thanks again, Lee

Dec 20 '05 #6
<sa******@hotmail.com> wrote in message
news:11*********************@g47g2000cwa.googlegro ups.com...
Why oh why does every example of Microsofts uses the * ?
There are two "dialects" of C++ that can be used to target the .Net
environment. The older is called Managed Extensions for C++ aka MC++. The
newer one - just out last month with VS 2005 - is called C++/CLI (common
language infrastructure) or something.

MC++ uses pointers syntax _both_ for addresses of native objects and for the
GC handles to managed objects.

C++/CLI stresses the difference between pointer and handle by using the
circumflex (^).
I've seen examples with the ^ but I've never seen a discussion on what
it is or used for.


You can start reading here

http://msdn.microsoft.com/msdnmag/issues/05/02/PureC/

and then google for

C++/CLI

Regards,
Will
Dec 20 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Senne Vaeyens | last post by:
Hi, I'm writing an app that will show a scrolling transparent graph and I'm ancountering some problems, explained in the following code: (a VS project explaining the problem(s) can be downloaded...
2
by: ΢ÈíÐÂÎÅ×é | last post by:
i want to abtain remote screen capture on the pc in LAN. i was suggested to transmit the changed parts only to save the bandwidth. so i divide the screen into 10*10 parts. and now , i need to...
1
by: S Domadia | last post by:
hi, now actually i want to design custom combo in which combo's button (in which down arrow is there to perform clicking for dropdown type of combo) should be also black in color. so as it's not...
1
by: JH | last post by:
I have a tab control in my form. I am trying to create a dynamic pie chart. If I use the following code,it works fine on the main form. this.CreateGraphics().FillPie(brushtargeted,240,200,200, 200,...
8
by: pigeonrandle | last post by:
Hi, Please pity me, i am on a dial-up connection for the first time in 5 years :( ! Does anyone know how the resulting Graphics objects differ ...? What i really mean is can someone explain it...
4
by: giddy | last post by:
hi when i run this class i made here , this is what it looks like without text - http://gidsfiles.googlepages.com/LinedTextBox_1.jpg WITH TEXT (heres the issue) -...
5
by: iKiLL | last post by:
Hi All, I am trying to Bulid Windows Mobile Forms Control with C# in VS2005 using CF2. On this control A lable is created and some text set for the control. My problem is that i dont know how...
2
by: RichGK | last post by:
This is from http://msdn2.microsoft.com/en-us/library/aa287522(VS.71).aspx public MainForm() { InitializeComponent(); System.Drawing.Pen myPen;
4
by: vijay_3491 | last post by:
Hi, How to write a CreateGraphics method for a class similar to form.CreateGraphics()? Pls help. Thanks in Advance.
3
by: bromptonville-un | last post by:
Hello, I'm an amateur in VB6, and I just switched to VB.Net (2003) . However, I've never used graphicals functions in neither those language... (Last time I drew something was in VB6). I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.