如何知道鼠标指针是否移到窗口的最顶部或最底部??

解决方案 »

  1.   

    procedure TForm1.Timer1Timer(Sender: TObject);
    var
      p: TPoint;
    begin
      p := ScreenToClient(Mouse.CursorPos);
      if p.Y<5 then 
        ShowMessage('到了顶部');
    end;
      

  2.   

    var y:integer;
    begin
      with Form1 do //Form1是你的窗口
       begin
         y:=ScreenToClient(Mouse.CursorPos).Y;
         if y<=0 then ShowMessage('鼠标在窗口顶部')
           else
            if y>=ScreenToClient(Point(0,Top+Height)).Y then
             ShowMessage('鼠标在窗口底部')
             else  ShowMessage('鼠标在窗口中')
       end;
    end;