473,320 Members | 1,832 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,320 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 9179
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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.