title: Why does mouse down block repainting of a component?
body: <p>I am trying to create a custom component that captures mouse events, especially MouseMove.</p>
  
  <p>I derive from <code>TWinControl</code>, but I have also tried with <code>TGraphicControl</code>, <code>TCustomControl</code>, <code>TTrackBar</code>, etc.</p>
  
  <p>My problem is when I hold down the mouse on the component, it is not being repainted.</p>
  
  <p>The <code>Paint()</code> method is not called until I release the mouse button, even if I call <code>Invalidate()</code>.</p>
  
  <p>A TrackBar is the closest component I want to make.  You select the tick, and move it around with the mouse.  But you do not have to release the mouse to see the tick move at the same time (the component is drawn again).</p>
  
  <p>If I directly call <code>Paint()</code>, it works, but the background is not erased.</p>
  
  <p>What am I missing?</p>
  
  <p>EDIT :
  I tried again and i confirm if i held the mouse down, Invalidate(); call are take in account only when i release the mouse.
  Try your self with my code below, paint is only call on release :</p>
  
  <pre><code>__fastcall TMyCustomComponent::TMyCustomComponent(TComponent* Owner)
      : TCustomTransparentControl(Owner)
  {
      mValue = 0;
  }
  
  void __fastcall TMyCustomComponent::MouseDown(System::Uitypes::TMouseButton Button, System::Classes::TShiftState Shift, int X, int Y)
  {
      if (Button == mbLeft)
          {
          mValueStart = 0;        
          }
  }
  
  void __fastcall TMyCustomComponent::MouseMove(System::Classes::TShiftState Shift, int X, int Y)
  {       
      Invalidate();       
  }
  
  void __fastcall TMyCustomComponent::Paint(void)
  {
      TGraphicControl::Paint();   
      Canvas-&gt;Font-&gt;Name = "Arial";
      Canvas-&gt;Font-&gt;Size = 8;
      Canvas-&gt;Font-&gt;Style = TFontStyles() &lt;&lt; fsBold;
      Canvas-&gt;Font-&gt;Color = clInfoText;
      Canvas-&gt;Brush-&gt;Color = clInfoBk;
      Canvas-&gt;FillRect(TRect(0, 0, 104, 21));
      mValue++;
      Canvas-&gt;TextOut(0, 2, AnsiString(mValue));
      Canvas-&gt;Brush-&gt;Color = clBtnShadow; 
  }
  </code></pre>