El siguiente código hará un beep solo si sales del formulario. Si el ratón se coloca sobre una imagen o un control en dicho formulario, no sonará:
Código Delphi
[-]
type
TForm1 = class(TForm)
private
procedure CMMouseLeave(var Message: TMessage); message CM_MOUSELEAVE;
end;
procedure TForm1.CMMouseLeave(var Message: TMessage);
var
P: TPoint;
H: cardinal;
begin
GetCursorPos(P);
H:= WindowFromPoint(P);
if not ((H = Handle) or (GetParent(H) = Handle)) then beep;
end;
Saludos.