WM_QUERYENDSESSION 这个东东怎么用啊!有哪位大侠可以告诉我这个截获消息的东东是怎么用的啊!

解决方案 »

  1.   

    结束会话,windows在关闭时会把这个消息广播到每个应用程序中
    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs;type
      TForm1 = class(TForm)
      private
        procedure wm(var wm);message wm_queryendsession;
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}
    procedure TForm1.wm(var wm);
    begin
      showmessage('adf');
      inherited;
    end;
      

  2.   

    Delphi已经封装这个消息了:
    procedure TfrmMenu.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
    begin
        CanClose := true; // false不能关闭.
    end;