473,549 Members | 2,588 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(Syst em::Object^ sender, System::EventAr gs^ e)

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

g->DrawRectangle( gcnew Pen(Color::Gree n, 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::Drawin g::Graphics' c:\documents and settings\saul01 \my
documents\visua l studio
2005\projects\c c2\managedxp\ma nagedxp\Test.h 77
Trying to create a graphics object this way (Graphics g =
this->CreateGraphics ();)

Error 1 error C3767: 'System::Drawin g::Graphics::Gr aphics': candidate
function(s) not accessible c:\documents and settings\saul01 \my
documents\visua l studio
2005\projects\c c2\managedxp\ma nagedxp\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 3913
Hello Everyone,

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

System::Void Test_Paint(Syst em::Object^ sender,
System::Windows ::Forms::PaintE ventArgs^ e)

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

e->Graphics->DrawRectangle( gcnew Pen(Color::Gree n, 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******@hotma il.com> wrote in message
news:11******** **************@ g44g2000cwa.goo glegroups.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(Syst em::Object^ sender, System::EventAr gs^ e)

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

g->DrawRectangle( gcnew Pen(Color::Gree n, 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::Drawin g::Graphics' c:\documents and settings\saul01 \my
documents\visua l studio
2005\projects\c c2\managedxp\ma nagedxp\Test.h 77
Trying to create a graphics object this way (Graphics g =
this->CreateGraphics ();)

Error 1 error C3767: 'System::Drawin g::Graphics::Gr aphics': candidate
function(s) not accessible c:\documents and settings\saul01 \my
documents\visua l studio
2005\projects\c c2\managedxp\ma nagedxp\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*******@Roun dTripInc.com> wrote in message
news:ep******** ******@TK2MSFTN GP14.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******@hotma il.com> wrote in message
news:11******** **************@ g44g2000cwa.goo glegroups.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(Syst em::Object^ sender, System::EventAr gs^ e)

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

g->DrawRectangle( gcnew Pen(Color::Gree n, 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::Drawin g::Graphics' c:\documents and settings\saul01 \my
documents\visua l studio
2005\projects\c c2\managedxp\ma nagedxp\Test.h 77
Trying to create a graphics object this way (Graphics g =
this->CreateGraphics ();)

Error 1 error C3767: 'System::Drawin g::Graphics::Gr aphics': candidate
function(s) not accessible c:\documents and settings\saul01 \my
documents\visua l studio
2005\projects\c c2\managedxp\ma nagedxp\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******@hotma il.com> wrote in message
news:11******** *************@f 14g2000cwb.goog legroups.com...
Hello Everyone,

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

System::Void Test_Paint(Syst em::Object^ sender,
System::Windows ::Forms::PaintE ventArgs^ e)

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

e->Graphics->DrawRectangle( gcnew Pen(Color::Gree n, 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******@hotma il.com> wrote in message
news:11******** *************@g 47g2000cwa.goog legroups.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
1357
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 at http://www.icat.be/problems.zip ) The code is executed on a timer.tick event: // Draw Using Double Buffering, this works perfectly if the...
2
2911
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 display the remote screen on my own form. my method is use this: Graphics c = this.createGraphics(); c.drawImage(imageparts,xcoodinary,ycoodinary);//...
1
1265
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 possible directly to change that i drawn image over that click button of combo using...
1
2723
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, 0, inttargeted); However, I want the pie chart to be on tab control area and if I try both of the following , Idon't see any pie chart. HELP...
8
12753
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 to me please? A) protected static extern IntPtr GetWindowDC (IntPtr hWnd );
4
6000
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) - http://gidsfiles.googlepages.com/LinedTextBox_withText.jpg The text turns BOLD and the lines kinda get erased because of the text. perhaps i could overide or handle the...
5
3473
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 lond the text is going to be. so i need to set the height and width of the label a cording to the data. un fortunatly i have not been able to...
2
3405
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
2462
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
5343
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 just tried the following code and it is not working properly: Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)...
0
7532
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7461
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7730
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7971
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7491
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6055
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5381
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5101
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3509
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...

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.