zoukankan      html  css  js  c++  java
  • 截断WM_SYSCOMMAND的SC_CLOSE命令(VC与Delphi双版本)

    WM_SYSCOMMAND - 系统命令消息,当点击最大化按钮,最小化按钮,关闭按钮等。都会收到这个消息。常用于窗口关闭时提示用户处理。
    WPARAM - 具体的命令,例如 关闭 SC_CLOSE
    LPARAM - 鼠标的位置
    LOWORD - 低16位 ,水平位置。
    HIWORD - 高16位 ,垂直位置。

    case WM_SYSCOMMAND:
    if( wParam == SC_CLOSE ){
        int nRet = MessageBox( NULL, "是否关闭", "Infor", MB_YESNO );
        if( nRet != IDYES ){
            return 0;
        }else
        {
            PostQuitMessage( 0 );
        }
    }
    break;

    参考:http://blog.csdn.net/kaishang0713/article/category/1732423/2

    ---------------------------------------------------------------------------------

    unit Unit1;
    
    interface
    
    uses
      Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
      Vcl.Controls, Vcl.Forms, Vcl.Dialogs;
    
    type
      TForm1 = class(TForm)
      private
        { Private declarations }
        procedure WndProc(var AMessage:TMessage);override;
      public
        { Public declarations }
      end;
    
    var
      Form1: TForm1;
    
    implementation
    
    {$R *.dfm}
    
    procedure TForm1.WndProc(var AMessage: TMessage);
    begin
      if (AMessage.Msg=WM_SYSCOMMAND) and (AMessage.WParam=SC_CLOSE) then
        Exit
      else
        inherited;
    end;
    
    end.
  • 相关阅读:
    oracle锁分类
    oracle中decode函数
    oracle分区
    oracle处理字符串
    oracle索引分类
    oracle表连接
    oracle处理字符串
    oracle分区
    木马中如何编程实现远程关机
    木马中如何编程实现远程关机
  • 原文地址:https://www.cnblogs.com/findumars/p/4740697.html
Copyright © 2011-2022 走看看