Freetutes.com

VB6 beginners tutorial - Learn VB6

Advanced VB6 tutorial - Learn Advanced VB6

VB .NET - Learn Visual Basic .NET

Systems Analysis - System analysis and Design tutorial for Software Engineering

Browse Topics

- Getting started
- Data Types
- Modules
- Operators in VB6
- VB6 Variable
- VB6 Procedures
- VB6 Control Structures
- Loops in VB6
- VB6 Exit Do & With End With
- Arrays in VB6
- User-Defined Data Types
- VB6 Constants
-
VB6 Built-in Functions
- Date and Time in VB6
- VB6 Controls
- TextBox Control
- ComboBox & OptionButton
- Label & Frame
- PictureBox & ImageBox
- Timer Control
- ListBox & ComboBox
- VB6 ScrollBar
- Control Arrays in VB6
- Files controls in VB6
- VB6 CheckBox
- Forms in VB6
- Menus in VB6
- MDI Form in VB6
- InputBox
- MessageBox
- Mouse events
- Mouse Move
- Error Handling
-
Error Handling (2)
-
VB6 Database

You are here: Visual Basic > VB6 (Beginners Tutorial)

Tutorial Main Page | Previous Page | Contents | Next Page

Drawing Ellipses

• There are several DLL routines that support graphic methods. The DLL function Ellipse allows us to draw an ellipse bounded by a pre-defined rectangular region.

• The Declare statement for the Ellipse function is:

Private Declare Function Ellipse Lib "gdi32" Alias "Ellipse" (ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long

Note there are five arguments: hdc is the hDC handle for the region (Form or Picture Box) being drawn to, (X1, Y1) define the upper left hand corner of the rectangular region surrounding the ellipse and (X2,Y2) define the lower right hand corner. The region drawn to must have its ScaleMode property set to Pixels (all DLL drawing routine use pixels for coordinates).

• Any ellipse drawn with this routine is drawn using the currently selected DrawWidth and ForeColor properties and filled according to FillColor and FillStyle.

Quick Example 3 - Drawing Ellipses

  1. Start a new application. Set the form’s ScaleMode property to Pixels.

  2. Use the API Text Viewer to obtain the Declare statement for the Ellipse function and copy it into the General Declarations area:

    Option Explicit
    Private Declare Function Ellipse Lib "gdi32" (ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long

  3. Attach the following code to the Form_Resize event:

    Private Sub Form_Resize()
    Dim RtnValue As Long
    Form1.Cls
    RtnValue = Ellipse(Form1.hdc, 0.1 * ScaleWidth, 0.1 * ScaleHeight, 0.9 * ScaleWidth, 0.9 * ScaleHeight)
    End Sub

  4. Run the application. Resize the form and see how the drawn ellipse takes on new shapes. Change the form’s DrawWidth, ForeColor, FillColor, and FillStyle properties to obtain different styles of ellipses.


  

Tutorial Main Page | Previous Page | Contents | Next Page

   

Home | About Us | Privacy Policy | Contact Us

Copyright © Freetutes.com | All Rights Reserved