⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 peekmessageu.pas

📁 DelphiWin32核心API参考光盘内容.是学习书籍中的源码,便于学习.
💻 PAS
字号:
unit PeekMessageU;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TForm1 = class(TForm)
    procedure FormMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var
  CurMouse: TPoint;      // identifies the mouse position in client coordinates
  TheMessage: TMSG;      // the message information structure
begin
  {if the left button was not clicked, don't start tracking the mouse}
  if Button <> mbLeft then Exit;

  {indicate that the mouse is being tracked}
  Caption := 'PeekMessage Example  -  Mouse is being tracked';

  {this causes the program to go into a tight loop that will exit
   only when the right mouse button is clicked}
  while not PeekMessage(TheMessage, Handle, WM_RBUTTONDOWN,
                        WM_RBUTTONDOWN, PM_NOREMOVE) do
  begin
    {get the current mouse cursor position in screen coordinates}
    GetCursorPos(CurMouse);

    {translate this into client coordinates}
    CurMouse := Form1.ScreenToClient(CurMouse);

    {draw a line to the new mouse position}
    Canvas.LineTo(CurMouse.X, CurMouse.Y);
  end;

  {the loop has ended, indicate that the mouse is no longer being tracked}
  Caption := 'PeekMessage Example  -  Mouse not tracked';
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -