472,353 Members | 2,062 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,353 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 8989
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...
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...
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...
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...
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...
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 -...
1
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...

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.