大佬教程收集整理的这篇文章主要介绍了windows – 为什么在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
我在Windows 7 Pro 64bit上使用Delphi XE2.我也可以使用Delphi 7重现.
因此,对于解决方法,您可以从线程调用WindowFromPoint.下面的简单示例,并非真正的后台线程,因为代码等待它完成:
type TGetWndThread = class(TThread) private FPoint: TPoint; protected procedure Execute; override; constructor Create(Aowner: TComponent; Point: TPoint); end; constructor TGetWndThread.Create(Aowner: TComponent; Point: TPoint); begin FPoint := Point; inherited Create; end; procedure TGetWndThread.Execute; begin ReturnValue := WindowFromPoint(FPoint); end; .. var Wnd: HWND; Thr: TGetWndThread; begin Thr := TGetWndThread.Create(nil,Point(Mouse.cursorPos.X,Mouse.cursorPos.Y - 40)); Wnd := Thr.WaitFor; Thr.Free; .. // use Wnd
以上是大佬教程为你收集整理的windows – 为什么在MouseMove事件中调用WindowFromPoint时,窗体的系统按钮会突出显示?全部内容,希望文章能够帮你解决windows – 为什么在MouseMove事件中调用WindowFromPoint时,窗体的系统按钮会突出显示?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。