title: TPageControl tab area OnMouseEnter OnMouseLeave events
body: <p>I need to catch the <strong>"OnMouseEnter"</strong> and <strong>"0nMouseLeave"</strong> for a certain area of the <strong>TPageControl component</strong>. With that specific area I mean <strong>the whole "tab header" rectangle</strong>.</p>
  
  <p>The problem is, that the <strong>page control doesn't catch the messages</strong> (I'm catching internal control messages CM_MOUSEENTER and CM_MOUSELEAVE) <strong>in the "empty" space</strong>.</p>
  
  <p><img src="https://i.stack.imgur.com/MjDNd.png" alt="screenshot"></p>
  
  <p>The aim for me is to draw a small arrow in the right empty side when user hovers in the red framed area (and drawing is just piece of cake) and erase it when leaves this area. And I'm don't care about the overflow of the tabs (which causes to draw scrolling double button) - that will never happen.</p>
  
  <p>Here is the working piece of code, <strong>but it's not the clear solution and I don't like it</strong>. There must be another (more clean) way to do it.</p>
  
  <pre><code>type
    TPageControl = class(ComCtrls.TPageControl)
    protected
      procedure CMMouseLeave(var Message: TMessage); message CM_MOUSELEAVE;
      procedure WMNCHitTest(var Message: TWMNCHitTest); message WM_NCHITTEST;
    end;
  
  procedure TPageControl.CMMouseLeave(var Message: TMessage);
  begin
    inherited;
    Canvas.TextOut(Width - 130, 5, 'CMMouseLeave'); // display result
  end;
  
  procedure TPageControl.WMNCHitTest(var Message: TWMNCHitTest);
  var TabHeaderRect: TRect;
  begin
    if Message.Result = 0 then // if Message.Result = HTNOWHERE ...
      begin
        TabHeaderRect := ClientRect;
        TabHeaderRect.Bottom := Top + 21;
  
        if PtInRect(TabHeaderRect, ScreenToClient(Point(Message.XPos, Message.YPos))) then
          Canvas.TextOut(Width - 130, 5, 'WMNCHitTest   '); // display result
  
        Message.Result := HTCLIENT;
      end
    else
      inherited;
  end;
  </code></pre>