Program For Enlarging Circle VB
Program For Enlarging Circle VB
SPEED
INTRODUCTION
In VB, graphics capabilities are usually associated with drawing lines, boxes, or
otherwise manipulating the display. Graphics are usually created on something, which in the
case of VB is either the printer, the screen, or the picture control. All three represent a surface
to which graphics can be applied. No other control supplied with VB supports the graphics
features. In Visual Basic 6.0, various graphics methods and properties are used to draw on a
Form or PictureBox control. Graphics in Visual Basic 6.0 are based on the Windows
Graphics Device Interface (GDI) APIs.
1. Open a Standard EXE project and name it SmplGrfx. Name the default form
frmMain. Set the form's Caption property to Simple Graphics.
3. Add an Image control to the form by using the same procedures as those described
in step 2 for the PictureBox. Name the Image control imgMain.
4. Size and place the PictureBox and Image controls where it is required to them on
the form
6. Go to the Windows directory and select Bubbles.bmp. When you click the Open
button, this bitmap will appear in the PictureBox.
1
7. Set the value of the AutoSize property of the picMain PictureBox to True. This
enlarges the area of the PictureBox to accommodate the size of the bitmap
Bubbles.bmp.
8. Select the Image control and set the value of the Picture property to the bitmap
Triangles.bmp. (This file is also in the Windows directory.) Do this the same way
you added a picture to the PictureBox. You can't set the AutoSize property, however,
because it isn't supported by the Image control.
2. Add a CommandButton to the form and name it cmdChange. Set the value of the
Caption property to Change the graphic.
picMain.Picture = imgMain.Picture
imgMain.Picture = imgUp.Picture
End Sub
2
Shift As Integer, X As Single, Y As Single)
imgMain.Picture = imgDown.Picture
End Sub
imgMain.Picture = imgUp.Picture
End Sub
6. Set the value of the Visible property for the Image controls imgDown and imgUp to
False.
7. Set the following code in the Click event procedure of the Image control imgMain:
If graphic file has to be loaded into a PictureBox or Image control from hard disk, the
LoadPicture() function can be used:
MyPicture = LoadPicture(strFilePath)
In this syntax,
3
THE CLICK() EVENT PROCEDURE OF THE COMMANDBUTTON
picDisplay.Picture = picBitmap.Picture
picDisplay.Picture = picIcon.Picture
& File1.List(File1.ListIndex)
picDisplay.Picture = LoadPicture(strFilePath)
End If
End Sub
4
The application loads the selected file from disk into the PictureBox picDisplay by using the
LoadPicture() function.
In the project MoreGrfx.vbp, after users assign a picture to the PictureBox picDisplay,
they can decide to distort the picture by clicking the CommandButton cmdDistort. When this
button is clicked, the picture in the PictureBox is assigned to the Picture property of the
Image control imgDistort with the following statements:
imgDistort.Picture = picDisplay.Picture
End Sub
REFERENCES
http://www.vb-helper.com/howto_closeup_map2.html
http://www.vb-helper.com/index_graphics.html
http://uap.unnes.ac.id/ebook/programming%20references/Mastering%20Visual%20Basic%2
06/ch17/ch17.htm