- How to show AddShape object over Image control?

D

Dan

I am having a problem displaying a shape object over/above an image control.

What I am trying to do is pretty simple - draw a circle on Image_click over
the clicked area (see the code below)

The problem is that the newly added shape object appears behind the image
(and cannot be seen) even though its ZOrder property is set to
msoBringToFront.

Ohh, and by the way could someone suggest why the circles get drawn with an
offset from the mouse pointer. Am I missing something here?


Private Type TPoint
X As Long
Y As Long
End Type

Private Declare Function GetCursorPos Lib "user32.dll" (lpPoint As TPoint)
As Boolean

Private Sub Image1_Click()
Dim point As TPoint
If (GetCursorPos(point)) Then
ThisDocument.Shapes.AddShape(msoShapeOval,point.x,point.y,10,10).Select
Selection.ShapeRange.ZOrder msoBringToFront
Selection.ShapeRange.Fill.Visible = msoFalse
Selection.ShapeRange.Fill.Solid
Selection.ShapeRange.Fill.Transparency = 0#
Selection.ShapeRange.Line.Weight = 2.25
Selection.ShapeRange.Line.DashStyle = msoLineSolid
Selection.ShapeRange.Line.Style = msoLineSingle
Selection.ShapeRange.Line.Transparency = 0#
Selection.ShapeRange.Line.Visible = msoTrue
Selection.ShapeRange.Line.ForeColor.RGB = RGB(255, 0, 0)
Selection.ShapeRange.Line.BackColor.RGB = RGB(255, 255, 255)
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top