I was asked to program the ability to click on the image in Excel and add a figure on top of it (this is a body diagram for a physiotherapist, the form will indicate the patient's pain site). My code does this OK using the ActiveX control's mouse control event:
Private Sub bodypic_MouseDown(ByVal Button As Integer, _
ByVal Shift As Integer, ByVal x As Single, ByVal y As Single)
ClickShape x, y
End Sub
Sub ClickShape(x As Single, y As Single)
Dim shp As Shape
Dim cursor As Point
Set shp = ActiveSheet.Shapes.AddShape(msoShapeMathMultiply, x + ActiveSheet.Shapes("bodypic").Left, _
y + ActiveSheet.Shapes("bodypic").Top, 26, 26)
With shp.Fill
.ForeColor.RGB = RGB(255, 0, 0)
.BackColor.RGB = RGB(255, 0, 0)
End With
shp.Line.Visible = False
End Sub
The problem is that when the mouse cursor is over the chart, the form is not visible. Only when the mouse moves away from the chart does a shape appear.
I tried various methods to refresh the screen by selecting a cell, even changing the cursor position using the SetCursor method in lib user32 . Nothing seems to work, except that the user is actually moving the mouse.
: ActiveX 200 x 500 , jpeg- , .