title: Mouse down event timing
body: <p>I've been asked to code the ability to click on an image in Excel and add a shape on top of it (it's a body diagram for a physiotherapist, the shape will indicate the site of the patient's pain). My code does this OK by using the mouse down event of an ActiveX image control:</p>
  
  <pre><code>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
  </code></pre>
  
  <hr>
  
  <pre><code>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
  </code></pre>
  
  <p>The problem is that while the mouse cursor is over the diagram the shape is not visible. Only when the mouse is moved off of the diagram does the shape appear.</p>
  
  <p>I've tried <a href="https://stackoverflow.com/questions/3735378/force-a-screen-update-in-excel-vba">various methods</a> to refresh the screen, selecting a cell, even changing the cursor position via the <a href="https://support.microsoft.com/en-gb/help/152969/visual-basic-procedure-to-get-set-cursor-position" rel="nofollow noreferrer">SetCursor method in Lib user32</a>. Nothing seems to work except for the user actually moving the mouse.</p>
  
  <p>To recreate the issue: insert an ActiveX image control roughly 200 x 500 px, add a jpeg image to the control, add the mouse down code to the worksheet and the click shape code to a module.</p>