如题
子窗体form2关闭时,如何发送消息给主窗体,让主窗体接受?同时主窗体的接受消息部分又应该如何实现?

解决方案 »

  1.   

    有关delphi自定义消息,网上有很多,搜一下吧
    http://www.cnitblog.com/shuyezi122/archive/2009/02/02/54136.html
    http://topic.csdn.net/t/20030422/14/1693166.html
    http://www.hackervip.com/Article/HTML/3255.html
    ...
      

  2.   

    子窗体的OnClose或OnCloseQuery或析构函数中,用SendMessage或PostMessage发消息给主窗体(Application.MainForm.Handle),在主窗体中,通过重载WndProc或消息映射或子类化主窗体进行消息的拦截.具体代码请自己google
      

  3.   

    在主窗体先自定义一个消息 主窗体的代码:
    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs;const
      WM_MY_CLOSE = WM_USER + 1234;type
      TFormMain = class(TForm)
      private
        { Private declarations }
        procedure MY_CLOSE(var msg: TMSG); message WM_MY_CLOSE;
      public
        { Public declarations }
      end;var
      FormMain: TFormMain;implementation{$R *.dfm}{ TFormMain }procedure TFormMain.MY_CLOSE(var msg: TMSG);
    begin
      Showmessage('收到消息');
    end;end.发送消息 
    PostMessage(FormMain.Handle, WM_USER + 1234, 0, 0)
      

  4.   

    不需要用消息吧,在close里通知不就行了吗?