我想在子窗體關閉的時候,mdi主窗體執行一個事件,但是因為子窗體比較多,又不好寫在子窗體的事件裡面,請問如何在主窗體裡面獲取子窗體關閉的消息,還有最小化等等,拜託各位高手幫忙,特急!!!
解决方案 »
- Delphi中,自定义函数,过程放在什么地方,有没有严格的要求的?
- 用delphi写个用户注册的程序。
- about c to delphi ?
- 如何在窗体中按以下方式显示局域网中各个计算机,并当用鼠标点击任何一台电脑,该计算机名将被赋予给一个变量,以供调用?
- 窗口上的所有东西都颜色渐变
- 高手帮忙!!
- 怎样知道IP地址是本地的,或是远程主机的,请教!!
- 哪个大哥知道,哪里有delphi 5 的下载??给个地址就好了一定给分!急用
- delphi7开发浏览器设置为默认浏览器
- 请问各位大虾:在delphi中是否有象vb中的StrReverse,就是将字符串倒转过来
- 为何我设置系统钩子不成功?知道的一定帮忙,我都快疯了。
- 请问如何实现语音的在线传输与接收???
主窗口得到消息就可以处理事情。当然这个要你自己写了
procedure TfrmMainFrame.WMParentNotify(var Msg: TWMParentNotify);
begin
if msg.Event=WM_DESTROY then //msg.Event总是为513。若是2,则是子窗体释放事件。
begin
showmessage('Child closed!');
end;
end;
function HookClientProc(hWnd: HWND;
uMsg: UINT;
wParam: WPARAM;
lParam: LPARAM): Integer;
begin
if uMsg = WM_MDIDESTROY then
ShowMessage('WM_MDIDESTROY');
Result := DefMDIChildProc(hWnd, uMsg, wParam, lParam)
end; hwndClient := Self.ClientHandle;
lpfnClient := GetWindowLong(hwndClient, GWL_WNDPROC);
SetWindowLong(hwndClient, GWL_WNDPROC, LPARAM(@HookClientProc));
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus;type
TForm1 = class(TForm)
MainMenu1: TMainMenu;
New1: TMenuItem;
procedure New1Click(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}uses Unit2;var
lpfnClient: Pointer;function HookClientProc(hWnd: HWND; uMsg: UINT; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall;
begin
if uMsg = WM_MDIDESTROY then
ShowMessage('WM_MDIDESTROY');
Result := CallWindowProc(Pointer(lpfnClient), hWnd, uMsg, wParam, lParam)
end;procedure TForm1.New1Click(Sender: TObject);
begin
with TForm2.Create(Self) do
begin
Visible := True;
end;
end;procedure TForm1.FormDestroy(Sender: TObject);
begin
SetWindowLong(Self.ClientHandle, GWL_WNDPROC, Integer(lpfnClient));
end;procedure TForm1.FormCreate(Sender: TObject);
begin
lpfnClient := Pointer(GetWindowLong(Self.ClientHandle, GWL_WNDPROC));
SetWindowLong(Self.ClientHandle, GWL_WNDPROC, LPARAM(@HookClientProc));
end;end.