are a number of tutorials
for using Visual C++ 2005
on the Microsoft web page. Unfortunately, there do not
appear to be any complete tutorials that walk you through
a drawing tucancode.net step by
step from beginning to end. The following tutorial does
up Visual C++ 2005 and
from the “File” menu, select “New” and then
click on “Project”.
“Project types” click on “CLR” and then under
“Visual studio installed templates” select
“Windows Forms Application”.
a project name and click “OK”.
this point you will see the Visual
C++ IDE window, consisting of a “Solution
Explorer” frame with some pre-existing files already
in place. You will also see “Form1.h[Design]”
window which contains a rudimentary form titled
anywhere on “Form1” and select the
“Properties” item in the context menu. On the
right side of the IDE, you will see a table of Form
on the “Events” icon on top of the “Form1”
properties window (the small thunderbolt). This will
list a series of events that you can write event
the box immediately to the right of “Paint” write
down the name of the Paint event handler, call it
something like “On_paint” and press “Enter”.
This will generate the skeleton for the event handler
in a new tab titled “Form1.h”. This is the header
file that contains all of the class declarations for
the Form. The skeleton for the “On_draw” paint
handler looks like this:
the variable “e” is a handle to the Graphics
object associated with the form. The Graphics
class enables you do draw on Forms.
this point, you can proceed with any one of the
drawing examples given in the Microsoft web page. For
example if you go to http://msdn2.microsoft.com/en-us/library/x1d5a9f2.aspx,
you will see an example of drawing several shapes.
Change the Graphics object handle “e” to “pe”
and enter (i.e. copy and paste) the following code in
your “On_paint” hander:
g = pe->Graphics;
Rectangle rect = Form::ClientRectangle;
smallRect.X = rect.X + rect.Width / 4;
smallRect.Y = rect.Y + rect.Height / 4;
smallRect.Width = rect.Width / 2;
smallRect.Height = rect.Height / 2;
Pen^ redPen = gcnew
redPen->Width = 4;
0, 0, rect.Width, rect.Height);
Pen^ bluePen = gcnew
bluePen->Width = 10;
bluePen, smallRect, 90, 270 );
build and run the program.
UCanCode Advance E-XD++
CAD Drawing and Printing Solution
Source Code Solution for C/C++, .NET V2021 is released!
Contact UCanCode Software
To buy the source code or learn more about with: