|
To | Do this |
---|---|
Draw on a form. | Create a Graphics object using the form’s CreateGraphics function. For example: Graphics* gr = myForm->CreateGraphics(); Remember to call Dispose on the Graphics object when you’ve finished with it. gr->Dispose(); |
Draw lines and the outlines of shapes. | Create Pen objects, and use them in calls to Graphics class drawing functions. Use the Pens and SystemPens classes to obtain Pens with standard colors. |
Fill shapes. | Create Brush objects, and use them in calls to Graphics class drawing functions. Use the Brushes and SystemBrushes classes to obtain brushes with standard colors. |
Use colors. | Create Color objects, and use them when constructing Pen and Brush objects. |
Display images. | Create a Bitmap object, passing it the name of an image file. Then use the DrawImage function of the Graphics class to render the image. |
Print from an application. | Create a PrintDialog. Create a PrintDocument and assign it to the Document property of PrintDialog. Show the dialog box, and check whether it returns DialogResult::OK. Create a callback function, attach it to the PrintPage event of PrintDocument, and then call the Print function of PrintDocument to print the page. |
|