473,389 Members | 1,072 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,389 software developers and data experts.

Draw Ellipse in Access Image Control


I have tweaked the PictureBox97.mdb (Stephen Lebans <www.lebans.com>)
code to nicely draw lines, rectangles and circles to the specs that I
input.
I'm at a loss though with trying to setup an Ellipse Drawing Function.
The following code I found on Google works in VB5 and draws an ellipse
shape no problem using the Circle Method.

Private Sub cmdDrawEllipse_Click()
Dim X As Long, Y As Long
Dim ElipseWidth As Integer, ElipseHeight As Integer
X = 2000
Y = 1000
ElipseWidth = 1200
ElipseHeight = 600
Circle (X, Y), ElipseWidth, , , , ElipseHeight / ElipseWidth
End Sub

The procedure will not work however in Access. I get a compile error
"Method or Data Member not found"
I suspect it might be something simple such as correctly creating a
Sub similar to Sub DrawCircle() in the PictureBox97.mdb clsPictureBox
module.
I have fiddled around with it (see below) but to no avail.
Can anybody spot the problem and give me a few hints?

Thanks for any help;

Lou Oosterhoff
Public Sub DrawEllipse((LeftX As Long, TopY As Long), radius As
Long,,,,aspect As Long))

Dim hNewPen As Long
Dim hOldPen As Long

Dim hNewBrush As Long
Dim hOldBrush As Long

hNewPen = apiCreatePen(PS_SOLID, m_DrawWidth, m_ForeColor)

If TempFillColor <0 Then
hNewBrush = apiCreateSolidBrush(TempFillColor)
Else
' Use FillColor Prop
hNewBrush = apiCreateSolidBrush(m_FillColor)
End If

hOldPen = SelectObject(m_hDC, hNewPen)
hOldBrush = SelectObject(m_hDC, hNewBrush)

apiEllipse m_hDC, LeftX, TopY, LeftX + diameter, TopY + diameter

Call SelectObject(m_hDC, hOldPen)
Call DeleteObject(hNewPen)

Call SelectObject(m_hDC, hOldBrush)
Call DeleteObject(hNewBrush)

Me.DIBtoPictureData

End Sub


Stephen Lebans wrote:
..................
As for your second question, just use on the GDI Ellipse drawing API's to
render the ellipse onto the PictureBox's hDC. I'm sure if you search on
GoogleGRoups you will be able to find existing VB source code demonstrating
how to use the API's to draw an ellipse.

Stephen Lebans
St*****@lebans.com
www.lebans.com
-----Original Message-----
From: we*******@lebans.com [mailto:we*******@lebans.com]
Sent: Monday, February 12, 2007 11:24 PM
To: st*****@lebans.com
Subject: Re:Feedback on your Access Web site

************************************************** **************************
***
Category: Products
Name: Lou Oosterhoff
Email: lg*@golden.net
Remote Name: 69.63.49.152

Comments:

Is there a version of ReportToPDF that works with A97?

Could pictureBoxA97 create ellipse curves?

Thanks


Feb 24 '07 #1
5 9190
Email me your MDB and I'll have a quick look at it.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
<lg********@gmail.comwrote in message
news:11**********************@h3g2000cwc.googlegro ups.com...
>
I have tweaked the PictureBox97.mdb (Stephen Lebans <www.lebans.com>)
code to nicely draw lines, rectangles and circles to the specs that I
input.
I'm at a loss though with trying to setup an Ellipse Drawing Function.
The following code I found on Google works in VB5 and draws an ellipse
shape no problem using the Circle Method.

Private Sub cmdDrawEllipse_Click()
Dim X As Long, Y As Long
Dim ElipseWidth As Integer, ElipseHeight As Integer
X = 2000
Y = 1000
ElipseWidth = 1200
ElipseHeight = 600
Circle (X, Y), ElipseWidth, , , , ElipseHeight / ElipseWidth
End Sub

The procedure will not work however in Access. I get a compile error
"Method or Data Member not found"
I suspect it might be something simple such as correctly creating a
Sub similar to Sub DrawCircle() in the PictureBox97.mdb clsPictureBox
module.
I have fiddled around with it (see below) but to no avail.
Can anybody spot the problem and give me a few hints?

Thanks for any help;

Lou Oosterhoff
Public Sub DrawEllipse((LeftX As Long, TopY As Long), radius As
Long,,,,aspect As Long))

Dim hNewPen As Long
Dim hOldPen As Long

Dim hNewBrush As Long
Dim hOldBrush As Long

hNewPen = apiCreatePen(PS_SOLID, m_DrawWidth, m_ForeColor)

If TempFillColor <0 Then
hNewBrush = apiCreateSolidBrush(TempFillColor)
Else
' Use FillColor Prop
hNewBrush = apiCreateSolidBrush(m_FillColor)
End If

hOldPen = SelectObject(m_hDC, hNewPen)
hOldBrush = SelectObject(m_hDC, hNewBrush)

apiEllipse m_hDC, LeftX, TopY, LeftX + diameter, TopY + diameter

Call SelectObject(m_hDC, hOldPen)
Call DeleteObject(hNewPen)

Call SelectObject(m_hDC, hOldBrush)
Call DeleteObject(hNewBrush)

Me.DIBtoPictureData

End Sub


Stephen Lebans wrote:
.................
>As for your second question, just use on the GDI Ellipse drawing API's to
render the ellipse onto the PictureBox's hDC. I'm sure if you search on
GoogleGRoups you will be able to find existing VB source code
demonstrating
how to use the API's to draw an ellipse.

Stephen Lebans
St*****@lebans.com
www.lebans.com
-----Original Message-----
From: we*******@lebans.com [mailto:we*******@lebans.com]
Sent: Monday, February 12, 2007 11:24 PM
To: st*****@lebans.com
Subject: Re:Feedback on your Access Web site

************************************************* ***************************
***
Category: Products
Name: Lou Oosterhoff
Email: lg*@golden.net
Remote Name: 69.63.49.152

Comments:

Is there a version of ReportToPDF that works with A97?

Could pictureBoxA97 create ellipse curves?

Thanks



Feb 24 '07 #2
On Feb 24, 4:22 pm, "Stephen Lebans" <ForEmailGotoMy.WebSite.-
WWWdotlebansdot...@linvalid.comwrote:
Email me your MDB and I'll have a quick look at it.

--

HTH
Stephen Lebanshttp://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
Thanks Stephen,
The DrawEllipse works like a charm.
I would be curious to know if PictureBox is able to draw closed
segments of a circle or ellipse like a half circle or pie slice.
I discovered I can draw arcs using the apiArc Function.
The arcs are not closed however so the fill function will not work.
Is there a way to connect the points on the arc with a straight line
to allow fill?
Can you also breifly descride the plotting points of the apiArc
Function?
I think x1, y1 & x2, y2 are clear to me but what about x3, y3 & x4,
y4 ?
Or can the Circle and Ellipse function be modified to draw segments?
Thanks again

'-------------arc Function----------------------
Public Sub DrawArc(x1 As Long, y1 As Long, x2 As Long, y2 As Long, x3
As Long, _
y3 As Long, x4 As Long, y4 As Long, Optional TempFillColor As Long =
0)

Dim hNewPen As Long
Dim hOldPen As Long

Dim hNewBrush As Long
Dim hOldBrush As Long

hNewPen = apiCreatePen(PS_SOLID, m_DrawWidth, 0) ' m_ForeColor)

If TempFillColor <0 Then
hNewBrush = apiCreateSolidBrush(TempFillColor) 'TempFillColor)
Else
' Use FillColor Prop
hNewBrush = apiCreateSolidBrush(m_FillColor)
End If

hOldPen = SelectObject(m_hDC, hNewPen)
hOldBrush = SelectObject(m_hDC, hNewBrush)

apiArc m_hDC, x1, y1, x2, y2, x3, y3, x4, y4

Call SelectObject(m_hDC, hOldPen)
Call DeleteObject(hNewPen)

Call SelectObject(m_hDC, hOldBrush)
Call DeleteObject(hNewBrush)

Me.DIBtoPictureData

End Sub

'------------calling procedure---------------
Private Sub CmdArcs_Click()
Dim x1 As Long, y1 As Long, Color As Long, x2 As Long, y2 As Long, _
x3 As Long, y3 As Long, x4 As Long, y4 As Long
x1 = 200
y1 = 200
x2 = 400
y2 = 400
x3 = 200 '???
x3 = 400 '???
x4 = 400 '???
x4 = 200 '???
Color = 255
pb.DrawArc x1, y1, x2, y2, x3, y3, x4, y4, Color
DoEvents
End Sub

Mar 4 '07 #3
Sorry, scratch the request for description of plotting points.
Playing around some more I figured it out.
However the fill function is still an issue.

the following code draws a half moon arc

Private Sub CmdArcs_Click()
Dim x1 As Long, y1 As Long, Color As Long, x2 As Long, y2 As Long, _
x3 As Long, y3 As Long, x4 As Long, y4 As Long
x1 = 400 ' width of circle
y1 = 400 ' height of circle
x2 = 0 ' left position
y2 = 0 ' top position
x3 = 400 ' right x start point of arc (draw counter-clockwise)
y3 = 200 ' right y start point of arc
x4 = 0 ' finish x point of arc
y4 = 200 ' finish y point of arc
Color = 255
pb.DrawArc x1, y1, x2, y2, x3, y3, x4, y4, Color
DoEvents
End Sub

Mar 4 '07 #4
As mentioned earlier, I don't routinely work with these API's nor do I have
the time to re-read the docs right now. Go onto MSDN and read the docs
yourself.
http://msdn2.microsoft.com/en-us/library/ms533282.aspx

Good luck.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
<lg********@gmail.comwrote in message
news:11**********************@s48g2000cws.googlegr oups.com...
Sorry, scratch the request for description of plotting points.
Playing around some more I figured it out.
However the fill function is still an issue.

the following code draws a half moon arc

Private Sub CmdArcs_Click()
Dim x1 As Long, y1 As Long, Color As Long, x2 As Long, y2 As Long, _
x3 As Long, y3 As Long, x4 As Long, y4 As Long
x1 = 400 ' width of circle
y1 = 400 ' height of circle
x2 = 0 ' left position
y2 = 0 ' top position
x3 = 400 ' right x start point of arc (draw counter-clockwise)
y3 = 200 ' right y start point of arc
x4 = 0 ' finish x point of arc
y4 = 200 ' finish y point of arc
Color = 255
pb.DrawArc x1, y1, x2, y2, x3, y3, x4, y4, Color
DoEvents
End Sub

Mar 4 '07 #5
On Mar 4, 9:34 am, "Stephen Lebans" <ForEmailGotoMy.WebSite.-
WWWdotlebansdot...@linvalid.comwrote:
As mentioned earlier, I don't routinely work with these API's nor do I have
the time to re-read the docs right now. Go onto MSDN and read the docs
yourself.http://msdn2.microsoft.com/en-us/library/ms533282.aspx

Good luck.

--

HTH
Stephen Lebanshttp://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.

<lgeastw...@gmail.comwrote in message

news:11**********************@s48g2000cws.googlegr oups.com...
Sorry, scratch the request for description of plotting points.
Playing around some more I figured it out.
However the fill function is still an issue.
the following code draws a half moon arc
Private Sub CmdArcs_Click()
Dim x1 As Long, y1 As Long, Color As Long, x2 As Long, y2 As Long, _
x3 As Long, y3 As Long, x4 As Long, y4 As Long
x1 = 400 ' width of circle
y1 = 400 ' height of circle
x2 = 0 ' left position
y2 = 0 ' top position
x3 = 400 ' right x start point of arc (draw counter-clockwise)
y3 = 200 ' right y start point of arc
x4 = 0 ' finish x point of arc
y4 = 200 ' finish y point of arc
Color = 255
pb.DrawArc x1, y1, x2, y2, x3, y3, x4, y4, Color
DoEvents
End Sub

Stephen,
Thanks for the link!
I've done the Pie & Chord APIs; and there's so much more there.
You've opened a window of possibilities for me.
Thanks again.

Mar 4 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Nanda | last post by:
hi, try this, bmp=new Bitmap(Width,Height); g=Graphics.FromImage(bmp); g.DrawEllipse(Pens.Red, new Rectangle(0, 0, 100, 100)); g.Save();...
2
by: Klaus Jensen | last post by:
Hi! I need an ASP.net control, which makes it possible for the user to define imagemaps. I show an image, the user can define areas (polygons would be nice, but just rectangles is ok), and I...
4
by: Shalley | last post by:
Hello, there, I have no idea how to draw an ellipse with an rotated angle. For example, the ellipse's center is (20.0, 50.0), two conjugate diameter pairs end-point are (35.0, 35.0), (25.0,...
4
by: Jason Huang | last post by:
Hi, In my C# Windows Form, how do I draw a Line? Thanks for help. Jason
1
by: sunildani | last post by:
write a program to Draw an ellipse's using polynimial equation ((x-h)^2/a^2 + ((y-k)^2)/b^2 =1
2
by: weird0 | last post by:
I wanted to draw an ellipse using c# with System.Drawing.Graphics. I tried out several tutorials and none of them worked and there seems to be something missing. One did execute without any errors...
0
by: Tem | last post by:
I need to draw a black circle using WPF and generate an image file. I used the following but it resulted in a blank file. I cannot figure out what is wrong with it. Thanks, Tem ...
4
by: Slickuser | last post by:
I am trying to draw an ellipse with specify x,y,width, and height for input argument in C# .net (Visual Studio 2005). It seem it will not draw for me. What am I missing? See the code below,...
4
by: annsh | last post by:
Hi On a windows form - I want to be able to allow a user to draw an image (on a graphics tablet). Its for an application for selling carpets - customer comes in and describes room where carpet...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.