mdi子窗口关闭的时候,主窗口产生什么事件?让我知道是哪个子窗体关闭了并却返回此mdichild 窗体的name??? 我的子窗体是打包在dll里面的!子窗体关闭时应该有消息发给主窗体,不然主窗体上的菜单就不会自动更新了!!!兄弟门,指教了!!!
这段是兄弟们给的答案,但是兄弟我有点笨,搞不定,贴出来,帮忙了
在注释的位置 返回关闭 的mdichild的 窗体的name ,有什么好办法没有???unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;type
TForm1 = class(TForm)
procedure FormShow(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
FClientInstance : TFarProc;
FPrevClientProc : TFarProc;
procedure ClientWndProc(var aMessage: TMessage);
end;var
Form1: TForm1;implementation{$R *.dfm}
{ TForm1 }procedure TForm1.ClientWndProc(var aMessage: TMessage);
begin
case aMessage.Msg of
WM_MDICreate :
begin
aMessage.Result := CallWindowProc(FPrevClientProc,ClientHandle, aMessage.Msg, aMessage.wParam, aMessage.lParam);
end;
WM_MDIDESTROY:
begin
aMessage.Result := CallWindowProc(FPrevClientProc,ClientHandle, aMessage.Msg, aMessage.wParam, aMessage.lParam);
showmessage( 'WM_MDIDESTROY' );
///怎么样才能返回关闭的child 窗体的name
end;
else
aMessage.Result := CallWindowProc(FPrevClientProc,ClientHandle, aMessage.Msg, aMessage.wParam, aMessage.lParam);
end;
end;procedure TForm1.FormShow(Sender: TObject);
begin
FPrevClientProc := Pointer(GetWindowLong(ClientHandle, GWL_WNDPROC));
FClientInstance := MakeObjectInstance(ClientWndProc);
SetWindowLong(ClientHandle, GWL_WNDPROC, LongInt(FClientInstance));
end;procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
SetWindowLong(ClientHandle, GWL_WNDPROC, LongInt(FPrevClientProc));
end;end.
这段是兄弟们给的答案,但是兄弟我有点笨,搞不定,贴出来,帮忙了
在注释的位置 返回关闭 的mdichild的 窗体的name ,有什么好办法没有???unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;type
TForm1 = class(TForm)
procedure FormShow(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
FClientInstance : TFarProc;
FPrevClientProc : TFarProc;
procedure ClientWndProc(var aMessage: TMessage);
end;var
Form1: TForm1;implementation{$R *.dfm}
{ TForm1 }procedure TForm1.ClientWndProc(var aMessage: TMessage);
begin
case aMessage.Msg of
WM_MDICreate :
begin
aMessage.Result := CallWindowProc(FPrevClientProc,ClientHandle, aMessage.Msg, aMessage.wParam, aMessage.lParam);
end;
WM_MDIDESTROY:
begin
aMessage.Result := CallWindowProc(FPrevClientProc,ClientHandle, aMessage.Msg, aMessage.wParam, aMessage.lParam);
showmessage( 'WM_MDIDESTROY' );
///怎么样才能返回关闭的child 窗体的name
end;
else
aMessage.Result := CallWindowProc(FPrevClientProc,ClientHandle, aMessage.Msg, aMessage.wParam, aMessage.lParam);
end;
end;procedure TForm1.FormShow(Sender: TObject);
begin
FPrevClientProc := Pointer(GetWindowLong(ClientHandle, GWL_WNDPROC));
FClientInstance := MakeObjectInstance(ClientWndProc);
SetWindowLong(ClientHandle, GWL_WNDPROC, LongInt(FClientInstance));
end;procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
SetWindowLong(ClientHandle, GWL_WNDPROC, LongInt(FPrevClientProc));
end;end.
解决方案 »
- 哪位有最新的HTTPSRVR.DLL
- 我用了themeengine这个组件,TeDBEdit在显示文字的时候光标总在文字的一半停留,急待解决??
- 各位cs侠,请看我的另类问题系列(一)--About table TQuery and dbgrid
- FR报表问题?
- StringGrid中單元格編輯狀態的問題
- 怎么不能加载外部程序?帮我看看。
- Query1经过查询以后就不能编辑了
- 如何在DELPHI中调用EXCEL文件???
- 请问谁知道Delphi7升级补丁的下载地址,回者有分.
- 怎樣實現讓客戶端自動感知到服務器的可執行文件有變化,並下載過來執行。
- quickreport 打印无法分页 使用newpage有错(illegal call to newpage)无法使用
- WebBrowser复制图片到剪贴板问题?急,,急,,,在线等!!!
FOldDestroyEvent := ChildForm.OnDestroy;
childForm.OnDestroy:= OnNewDestroy;
procedure MainForm.OnNewDestroy(Sender: TObject);
begin
ChildName := Sender.Name; // childName在主窗体定义
if assigned(FOldDestroyEvent ) then
FOldDestroyEvent(Sender);
end;
childForm.OnDestroy:= OnNewDestroy;
procedure MainForm.OnNewDestroy(Sender: TObject);
begin
ChildName := Sender.Name;
if assigned(FOldDestroyEvent ) then
FOldDestroyEvent(Sender);
end;
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus, StdCtrls;type
TForm1 = class(TForm)
MainMenu1: TMainMenu;
a1: TMenuItem;
b1: TMenuItem;
aa1: TMenuItem;
bb1: TMenuItem;
Button1: TButton;
Memo1: TMemo;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormShow(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
procedure SetClientClose;
public
{ Public declarations }
FClientInstance : TFarProc;
FPrevClientProc : TFarProc;
FClientDestroy: array of TNotifyEvent;
procedure ClientWndProc(var aMessage: TMessage);
procedure ClientDestroy(Sender: TObject);
end;var
Form1: TForm1;implementationuses Unit2;{$R *.dfm}
procedure TForm1.ClientWndProc(var aMessage: TMessage);
begin case aMessage.Msg of
WM_MDICreate :
begin
aMessage.Result := CallWindowProc(FPrevClientProc,ClientHandle, aMessage.Msg, aMessage.wParam, aMessage.lParam);
SetClientClose;
end;
WM_CLOSE:
begin
aMessage.Result := CallWindowProc(FPrevClientProc,ClientHandle, aMessage.Msg, aMessage.wParam, aMessage.lParam);
end;
WM_MDIDESTROY:
begin
aMessage.Result := CallWindowProc(FPrevClientProc,ClientHandle, aMessage.Msg, aMessage.wParam, aMessage.lParam);
showmessage( 'WM_MDIDESTROY' );
///怎么样才能返回关闭的child 窗体的name
end;
else
aMessage.Result := CallWindowProc(FPrevClientProc,ClientHandle, aMessage.Msg, aMessage.wParam, aMessage.lParam);
end;
end;procedure TForm1.FormShow(Sender: TObject);
begin
FPrevClientProc := Pointer(GetWindowLong(ClientHandle, GWL_WNDPROC));
FClientInstance := MakeObjectInstance(ClientWndProc);
SetWindowLong(ClientHandle, GWL_WNDPROC, LongInt(FClientInstance));
end;procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
SetWindowLong(ClientHandle, GWL_WNDPROC, LongInt(FPrevClientProc));
end;procedure TForm1.ClientDestroy(Sender: TObject);
var
I: Integer;
begin
ShowMessage((Sender as TForm).Name);
for I := 0 to Self.MDIChildCount - 1 do
if Self.MDIChildren[I] = TForm(Sender) then
if Assigned(FClientDestroy[I]) then
FClientDestroy[I](Sender);
end;procedure TForm1.Button1Click(Sender: TObject);
var
I: Integer;
begin
// 创建mdichild
Form2 := TForm2.Create(Self);
end;procedure TForm1.SetClientClose;
var
I: Integer;
ClientForm: TForm;
begin
SetLength(FClientDestroy, Self.MDIChildCount);
for I := 0 to Self.MDIChildCount - 1 do
begin
// 记录所有mdichild的ondestroy事件,并修改
ClientForm := Self.MDIChildren[I];
FClientDestroy[I] := ClientForm.OnDestroy;
ClientForm.OnDestroy := ClientDestroy;
end;
end;procedure TForm1.FormDestroy(Sender: TObject);
begin
SetLength(FClientDestroy, 0);
end;end.