zoukankan      html  css  js  c++  java
  • 使用全局热键显示隐藏窗体

    unit Unit1;

    interface

    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs;

    type
      TForm1 
    = class(TForm)
        
    procedure FormCreate(Sender: TObject);
        
    procedure WMHotKey(var Msg: TWMHotKey); message WM_HOTKEY;
      private
        
    { Private declarations }
      public
        
    { Public declarations }
      
    end;

    var
      Form1: TForm1;
      HotKeyId: Cardinal;

    implementation

    {$R *.dfm}

    procedure TForm1.FormCreate(Sender: TObject);
    const
      MOD_ALT 
    = 1;
      MOD_CONTROL 
    = 2;
      VK_R 
    = 82;
    begin
      
    //Ctrl + Alt + S
      try
        HotKeyId :
    = GlobalAddAtom('MyHotKey'- $C000;
        RegisterHotKey(handle, HotKeyId, MOD_CONTROL 
    + MOD_ALT, VK_R);
      except

      
    end;
    end;

    procedure TForm1.WMHotKey(var Msg: TWMHotKey);
    begin
      
    if Msg.HotKey = HotKeyId then
      
    begin
        
    if Application.ShowMainForm then
        
    begin
          Application.ShowMainForm :
    = False;
        
    end else
        
    begin
          Application.ShowMainForm :
    = True;
        
    end;
      
    end;
      
    if Self.Visible then Self.Visible := False
      
    else Self.Visible := True;
    end;

    end.
  • 相关阅读:
    3、生成证书请求文件
    2、申请苹果App ID
    登录iOS Dev Center
    SQL Server 合并行
    asp 月末 月初
    linux
    ASP数组全集,多维数组和一维数组[转]
    oracle 秒
    oracle 存储过程 包 【转】
    linux
  • 原文地址:https://www.cnblogs.com/jxgxy/p/2121086.html
Copyright © 2011-2022 走看看