zoukankan      html  css  js  c++  java
  • Api 函数: GetCursorPos 与转换

    //获取鼠标在窗体中的当前位置
    procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    var
      str: string;
    begin
      str := Format('%d,%d',[X,Y]);
      ShowMessage(str);
    end;
    
    //用 GetCursorPos 获取的是鼠标相对与屏幕的位置 var ps: TPoint; str: string; begin GetCursorPos(ps); str := Format('%d,%d',[ps.X,ps.Y]); ShowMessage(str); end;
    //但通过 ScreenToClient 方法可以转换过来 var ps: TPoint; str: string; begin GetCursorPos(ps); ps := ScreenToClient(ps); str := Format('%d,%d',[ps.X,ps.Y]); ShowMessage(str); end;
    // ClientToScreen 函数 procedure TForm1.FormMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); var str: string; ps: TPoint; begin {显示当前鼠标位置, 这是相对于窗体的} str := Format('%d,%d',[X,Y]); ShowMessage(str); {通过 ClientToScreen 函数可以得到当前鼠标相对于屏幕的位置} ps := point(X,Y); ps := ClientToScreen(ps); str := Format('%d,%d',[ps.X, ps.Y]); ShowMessage(str); end;
  • 相关阅读:
    python--异常处理
    Codeforces 1499D
    Codeforces 1263E
    Codeforces 1493D
    Codeforces 1492D
    Codeforces 1490G
    Codeforces 1487E
    Codeforces 1485D
    Codeforces 1485C
    P6917 [ICPC2016 WF]Balanced Diet
  • 原文地址:https://www.cnblogs.com/del/p/1049036.html
Copyright © 2011-2022 走看看