请问怎么释放窗体句柄?在线等待。(10分)

  • 主题发起人 wphoenix1213
  • 开始时间
W

wphoenix1213

Unregistered / Unconfirmed
GUEST, unregistred user!
我激活的是一个windows窗体。
 
//出自Delphi4开发人员指南
//模式
if not Assigned(SomeForm) then
SomeForm := TSomeForm.Create(Application);
try
SomeForm.ShowModal;
finally
SomeForm.Free;
SomeForm := nil;
end;

//非模式
if not Assigned(SomeForm) then
SomeForm := TSomeForm.Create(Application);
SomeForm.Show;
//窗口Close事件中
Action := caFree;
//Destory中
SomeForm := nil;
 
不懂,具体一点
 
我用setactivewindow/setforegroundwindow函数激活了其他的windows窗体,
它一直处于最前,程序关闭了也是这样,不知道该怎么办?
 
DestroyWindow
 
你设置窗体再最前端,本退出前要将其他窗体设置成正常状态呀
 
to pcexplorer:
我有点笨,请问怎么设置成正常态呀?
 
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure FormClose(Sender: TObject;
var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
Wnd: THandle;
begin
Wnd := FindWindow(nil, '代码.txt - 记事本');
SetWindowPos(Wnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_SHOWWINDOW or SWP_NOSIZE
or SWP_NOMOVE);
SetForegroundWindow(Wnd);
end;

procedure TForm1.FormClose(Sender: TObject;
var Action: TCloseAction);
var
Wnd: THandle;
begin
Wnd := FindWindow(nil, '代码.txt - 记事本');
SetWindowPos(Wnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE or SWP_NOSIZE
or SWP_NOMOVE);
end;

end.
 
接受答案了.
 
closehandle(wnd);
 
顶部