Beginning Visual Basic: A Step by Step Computer Programming Tutorial by Philip Conrod & Lou Tylee
Author:Philip Conrod & Lou Tylee [Conrod, Philip]
Language: eng
Format: azw3
ISBN: 9781937161675
Publisher: Kidware Software LLC
Published: 2017-06-25T04:00:00+00:00
Graphics Objects
You need to tell Visual Basic that you will be using graphics methods with the panel control. To do this, you convert the panel control to something called a graphics object. Graphics objects provide the “surface” for graphics methods. Creating a graphics object requires two simple steps. We first declare the object using the standard Dim statement. If we name our graphics object MyGraphics, the form is:
Dim MyGraphics As Graphics
This declaration is placed in the general declarations area of the code window, along with our usual variable declarations. Once declared, the object is created using the CreateGraphics method:
MyGraphics = ControlName.CreateGraphics()
where ControlName is the name of the control hosting the graphics object (in our work, the Name property of the panel control). We will create this object in the form Load event of our projects.
Once a graphics object is created, all graphics methods are applied to this newly formed object. Hence, to apply a graphics method named GraphicsMethod to the MyGraphics object, use:
MyGraphics.GraphicsMethod(Arguments)
where Arguments are any needed arguments, or information needed by the graphics method.
There are two important graphics methods we introduce now. First, after all of your hard work drawing in a graphics object, there are times you will want to erase or clear the object. This is done with the Clear method:
MyGraphics.Clear(Color)
This statement will clear a graphics object (MyGraphics) and fill it with the specified Color. We will look further at colors next. The usual color argument for clearing a graphics object is the background color of the host control (ControlName), or:
MyGraphics.Clear(ControlName.BackColor)
Once you are done drawing to an object and need it no longer, it should be properly disposed to clear up system resources. To do this with our example graphics object, use the Dispose method:
MyGraphics.Dispose()
This statement is usually placed in the form FormClosing event procedure.
Our drawing will require colors and objects called pens, so let’s take a look at those concepts. Doesn’t it make sense we need pens to do some drawing?
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Deep Learning with Python by François Chollet(12577)
Hello! Python by Anthony Briggs(9916)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(9796)
The Mikado Method by Ola Ellnestam Daniel Brolund(9779)
Dependency Injection in .NET by Mark Seemann(9340)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8301)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7763)
Grails in Action by Glen Smith Peter Ledbrook(7697)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7557)
Becoming a Dynamics 365 Finance and Supply Chain Solution Architect by Brent Dawson(7093)
Microservices with Go by Alexander Shuiskov(6861)
Practical Design Patterns for Java Developers by Miroslav Wengner(6779)
Test Automation Engineering Handbook by Manikandan Sambamurthy(6721)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6419)
Angular Projects - Third Edition by Aristeidis Bampakos(6131)
The Art of Crafting User Stories by The Art of Crafting User Stories(5654)
NetSuite for Consultants - Second Edition by Peter Ries(5588)
Demystifying Cryptography with OpenSSL 3.0 by Alexei Khlebnikov(5396)
Kotlin in Action by Dmitry Jemerov(5066)
