如何判断鼠标焦点是否在指定窗体上,如果不在指定窗体上则指定窗体关闭?(在线) 想实现鼠标在指定窗体外的屏幕的任何位置点击后就关闭指定窗体的效果,不知道如何实现? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 Mouse Hook用WindowFromPoint(MOUSEHOOKSTRUCT.pt)与窗体句柄对比,不一样就PostMessage(Form1.Hanldw, WM_CLOSE, 0, 0); 拦截窗体的消息,如果 (Message.Msg = WM_NCACTIVATE) and (Message.WParam = 0)就Close。可惜这帖子发在非技术区了,郁闷。 ccrun(老妖)(www.ccrun.com) 抢分心切啊人家问的是鼠标点击窗体外任何位置才close嘛您那个好像随便按个ALT+TAB也能close吧?呵呵。1楼的方法可行。 阿日。。出来。。转帖子了。。推荐LZ使用Mouse Hook。 interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;type TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } procedure UP_Locus(var Message:TMessage); message WM_ACTIVATEAPP; public { Public declarations } end;var Form1: TForm1;implementationuses Unit2;{$R *.dfm}procedure TForm1.UP_Locus(var Message:TMessage);begin if (message.WParam=0) and (message.Msg=WM_ACTIVATEAPP) then begin self.Caption:='lost'; end else begin self.Caption:='get'; end;end;//刚学会的end. if ActiveForm.name <> sbform then sbform.close; 同意 fim(阿初) 的观点。记得有个api可以获得窗体的句柄。 spcomm只能接收1024个字节的数据,请达人指教! 大家好,我想问一个关于TLabel的问题! 如何在一个窗体中调用另一个窗体中的子窗体 怎样在delphi中动态新建MS Access 的数据表,以及数据库别名? 关于OOB的问题,请教诸位 一个送分的问题,可是小弟我卡住了! 当鼠标移开的时候,使它的颜色恢复成原来的样式,音乐也停止?????/ delphi如何调用附件中的画图功能? 谁用过InterBase数据库,能说说体会吗?我有一个项目准备采用它 修改注册表的问题 怎样利用DELPHI实现C/S结构 超级难题:如何取出下级所有部门代码
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
procedure UP_Locus(var Message:TMessage); message WM_ACTIVATEAPP;
public
{ Public declarations }
end;var
Form1: TForm1;implementationuses Unit2;{$R *.dfm}
procedure TForm1.UP_Locus(var Message:TMessage);
begin
if (message.WParam=0) and (message.Msg=WM_ACTIVATEAPP) then
begin
self.Caption:='lost';
end
else
begin
self.Caption:='get';
end;
end;
//刚学会的
end.