By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,456 Members | 1,952 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,456 IT Pros & Developers. It's quick & easy.

Draw Ellipse in Access Image Control

P: n/a

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
Share this Question
Share on Google+
5 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.