在傳遞給WindowFromPoint的點處,在TWinControl的MouseMove事件中調用WindowFromPoint會導致MouseOver事件。這是一個VCL錯誤?有人知道是否有解決方法?爲什麼在MouseMove事件中調用WindowFromPoint時突出顯示窗體的系統按鈕?
這裏的演示代碼:
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
我用Delphi XE2在Windows 7專業版64位。我也可以使用Delphi 7複製。
WindowFromPoint是Windows API。所以似乎不是一個VCL問題。 –
@TLama - 實際上,表單可以是任意大小,但光標必須在系統按鈕正下方40像素或更少。 – norgepaul
也許這篇文章來自雷蒙德陳是相關的:http://blogs.msdn.com/b/oldnewthing/archive/2011/02/18/10131176.aspx –