Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delphi: how to handle click on PageControl's empty space?

Tags:

delphi

I'm using Delphi 7. I want to react on click(left) on empty space of PageControl -- on area righter than the last tab shown. How can i do that?Form with pagecontrol

like image 360
Prog1020 Avatar asked Jan 11 '13 17:01

Prog1020


1 Answers

You can handle the click at the parent control of the PageControl. F.i. if the PageControl is placed on a form, the form's 'MouseDown' events will be called for that specified region. The reason is that the PageControl returns HTTRANSPARENT for hit test messages for that region, so the mouse messages is directed to the control beneath it.

If that's not OK, you can change how WM_NCHITTEST is handled, for example by subclassing the control, or in a derived control:

type
  TMyPageControl = class(TPageControl)
  protected
    procedure WMNCHitTest(var Message: TWMNCHitTest); message WM_NCHITTEST;
  end;

procedure TMyPageControl.WMNCHitTest(var Message: TWMNCHitTest);
begin
  inherited;
  if Message.Result = HTTRANSPARENT then
    Message.Result := HTCLIENT;
end;

then, the control's OnMouseDown event will be fired. Of course you could test for the region before modifying the message's return value, this example was only to show how it would work.

like image 168
Sertac Akyuz Avatar answered Oct 24 '22 22:10

Sertac Akyuz