在 TWinControl 的 MouseMove 事件中调用 WindowFromPoint 会在传递给 WindowFromPoint 的点处引发 MouseOver 事件。这是一个 VCL 错误吗?有人知道是否有解决方法吗?
这是演示代码:
unit Unit7;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
type
TForm7 = class(TForm)
Button1: TButton;
procedure Button1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form7: TForm7;
implementation
{$R *.dfm}
procedure TForm7.Button1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
WindowFromPoint(Point(Mouse.CursorPos.X, Mouse.CursorPos.Y - 40));
end;
end.
DFM:
object Form7: TForm7
Left = 0
Top = 0
Caption = 'Form7'
ClientHeight = 40
ClientWidth = 116
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Button1: TButton
Left = 24
Top = 7
Width = 75
Height = 25
Caption = 'Button1'
TabOrder = 0
OnMouseMove = Button1MouseMove
end
end
我在 Windows 7 Pro 64bit 上使用 Delphi XE2。我也可以使用 Delphi 7 进行复制。