用鼠标点击的位置判断:
procedure TForm1.StatusBar1Click(Sender: TObject);
var
i: integer;
P : TPoint;
R : TRect;
begin
P.X := Mouse.CursorPos.X;
P.Y := Mouse.CursorPos.Y;
p:=ScreenToClient(p);
R.Top:=StatusBar1.Top;
R.Bottom:=StatusBar1.Top+StatusBar1.Height;
R.Left:=0;
for I := 0 to StatusBar1.Panels.Count - 1 do
begin
if i=StatusBar1.Panels.Count - 1 then
R.Right:=StatusBar1.Width
else
R.Right:=R.Left+StatusBar1.Panels.Width;
if PtInRect (R,P) then begin
Label1.Caption:=StatusBar1.Panels.Text;
break;
end else
Label1.Caption:='';
end;
end;