A
adamc
Unregistered / Unconfirmed
GUEST, unregistred user!
我想在应用程序执行中浮出一个窗口Form1,Form1单元如下:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, RzButton, StdCtrls;
type
TForm4 = class(TForm)
RzToolButton1: TRzToolButton;
procedure RzToolButton1Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
protected
procedure CreateParams(var Params: TCreateParams); override;
public
{ Public declarations }
end;
procedure ShowMyMsgWindow;
{* 以非模态方式显示动态提示窗口,参数为提示内容和提示类型}
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure ShowMyMsgWindow;
begin
with TForm1.Create(nil) do
begin
ShowWindow(Handle, SW_SHOWNOACTIVATE); // 窗体不活跃
SetWindowPos(Handle, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE or
SWP_NOACTIVATE or SWP_NOSIZE or SWP_NOOWNERZORDER); // 窗体显示在任务栏后面
end;
end;
procedure TForm4.CreateParams(var Params: TCreateParams);
begin
inherited;
Params.Style := Params.Style or WS_BORDER;
Params.ExStyle := WS_EX_DLGMODALFRAME or WS_EX_TOPMOST;
end;
procedure TForm4.RzToolButton1Click(Sender: TObject);
begin
close;
end;
procedure TForm4.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action := caFree; // 关闭时释放
end;
procedure TForm4.FormDestroy(Sender: TObject);
begin
Form1 := nil;
end;
end.
我在另一窗口中有一edit,在edit的Enter时间中调用ShowMyMsgWindow过程浮出Form1,可以实现,但在edit的Exit中关闭Form1,代码如下:
if form1<>nil then
SendMessage(handle_1,WM_CLOSE,0,0);
但窗口仍显示,不会消失,请问如何解决?谢谢!
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, RzButton, StdCtrls;
type
TForm4 = class(TForm)
RzToolButton1: TRzToolButton;
procedure RzToolButton1Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
protected
procedure CreateParams(var Params: TCreateParams); override;
public
{ Public declarations }
end;
procedure ShowMyMsgWindow;
{* 以非模态方式显示动态提示窗口,参数为提示内容和提示类型}
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure ShowMyMsgWindow;
begin
with TForm1.Create(nil) do
begin
ShowWindow(Handle, SW_SHOWNOACTIVATE); // 窗体不活跃
SetWindowPos(Handle, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE or
SWP_NOACTIVATE or SWP_NOSIZE or SWP_NOOWNERZORDER); // 窗体显示在任务栏后面
end;
end;
procedure TForm4.CreateParams(var Params: TCreateParams);
begin
inherited;
Params.Style := Params.Style or WS_BORDER;
Params.ExStyle := WS_EX_DLGMODALFRAME or WS_EX_TOPMOST;
end;
procedure TForm4.RzToolButton1Click(Sender: TObject);
begin
close;
end;
procedure TForm4.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action := caFree; // 关闭时释放
end;
procedure TForm4.FormDestroy(Sender: TObject);
begin
Form1 := nil;
end;
end.
我在另一窗口中有一edit,在edit的Enter时间中调用ShowMyMsgWindow过程浮出Form1,可以实现,但在edit的Exit中关闭Form1,代码如下:
if form1<>nil then
SendMessage(handle_1,WM_CLOSE,0,0);
但窗口仍显示,不会消失,请问如何解决?谢谢!