ActiveX Dll to draw circles on Picture box

Posted on 2002-05-12
Last Modified: 2012-06-21
I need a ActiveX Dll code to draw circles on a Picture box. I also need sample code show how to implement the ActiveX Dll code using a Standard Exe. I need this in a hurry so I posted 200 points.
Question by:mcdonald_g
  • 2
LVL 43

Expert Comment

ID: 7005597
Why not use the standard .Circle method of the picture box control?

Circle Method

Draws a circle, ellipse, or arc on an object.


object.Circle [Step] (x, y), radius, [color, start, end, aspect]

The Circle method syntax has the following object qualifier and parts:

Part Description
object Optional.Object expression that evaluates to an object in the Applies To list. If object is omitted, the Form with thefocus is assumed to be object.
Step Optional.Keyword specifying that the center of the circle, ellipse, or arc is relative to the current coordinates given by the CurrentX and CurrentY properties of object.
(x, y) Required. Single values indicating the coordinates for the center point of the circle, ellipse, or arc. The ScaleMode property of object determines the units of measure used.
radius Required. Single value indicating the radius of the circle, ellipse, or arc. The ScaleMode property of object determines the unit of measure used.
color Optional. Long integer value indicating the RGB color of the circle's outline. If omitted, the value of the ForeColor property is used. You can use the RGB function or QBColor function to specify the color.
start, end Optional. Single-precision values. When an arc or a partial circle or ellipse is drawn, start and end specify (in radians) the beginning and end positions of the arc. The range for both is –2 pi radians to 2 pi radians. The default value for start is 0 radians; the default for end is 2 * pi radians.
aspect Optional. Single-precision value indicating the aspect ratio of the circle. The default value is 1.0, which yields a perfect (non-elliptical) circle on any screen.


To fill a circle, set the FillColor and FillStyle properties of the object on which the circle or ellipse is drawn. Only a closed figure can be filled. Closed figures include circles, ellipses, or pie slices (arcs with radius lines drawn at both ends).

When drawing a partial circle or ellipse, if start is negative, Circle draws a radius to start, and treats the angle as positive; if end is negative, Circle draws a radius to end and treats the angle as positive. The Circle method always draws in a counter-clockwise (positive) direction.

The width of the line used to draw the circle, ellipse, or arc depends on the setting of the DrawWidth property. The way the circle is drawn on the background depends on the setting of the DrawMode and DrawStyle properties.

When drawing pie slices, to draw a radius to angle 0 (giving a horizontal line segment to the right), specify a very small negative value for start, rather than zero.

You can omit an argument in the middle of the syntax, but you must include the argument's comma before including the next argument. If you omit an optional argument, omit the comma following the last argument you specify.

When Circle executes, the CurrentX and CurrentY properties are set to the center point specified by the arguments.

This method cannot be used in an With…End With block.
LVL 69

Expert Comment

by:Éric Moreau
ID: 7005800
please use your other question!!!
LVL 69

Accepted Solution

Éric Moreau earned 200 total points
ID: 7007485
I have change this method of your class:

Public Sub Draw(ByRef fMyForm As Object)

 fMyForm.Picture1.ForeColor = ForeColor
 ' Set other drawing attributes.
 With fMyForm.picCanvas
     .FillStyle = FillStyle
     .FillColor = FillColor
     .DrawWidth = DrawWidth
     .DrawStyle = DrawStyle
 End With

 ' Draw the object.
 fMyForm.Picture1.Circle (X0, Y0), Radius, fMyForm.Picture1.ForeColor
End Sub

And I places this into a new standard EXE after having added a command button (command1), 2 picture
box (picture1 and piccanvas) and after having set a reference to your DLL.

Option Explicit

Private Sub Command1_Click()
Dim x As Project1.Class1

   Set x = New Project1.Class1
   With x
       .X0 = 1000
       .Y0 = 1000
       .ForeColor = vbBlack
       .FillColor = vbRed
       .Radius = 500
       .Draw Me
   End With
End Sub

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now