可不可以用Hook拦截消息,然后给Application 发送SW_SHOW或者是SW_RESTORE.

解决方案 »

  1.   

    吧窗体的keypreview设为true,然后就可以通过form的onkeypress这些事件判断什么键被按下了,然后处理相应的事件。
    但是象f1这样的键,由于是系统占用了,所以要使用registerhotkey方法去定义。
      

  2.   

     1.WM_SETHOTKEY
     2.registerhotkey
      

  3.   

    //转贴:RegisterHotKey函数原型及说明:
    BOOL RegisterHotKey(
      HWND hWnd,         // window to receive hot-key notification
      int id,            // identifier of hot key
      UINT fsModifiers,  // key-modifier flags
      UINT vk            // virtual-key code);
    参数 id为你自己定义的一个ID值,对一个线程来讲其值必需在0x0000 - 0xBFFF范围之内,对DLL来讲其值必需在0xC000 - 0xFFFF 范围之内,在同一进程内该值必须唯一
    参数 fsModifiers指明与热键联合使用按键,可取值为:MOD_ALT MOD_CONTROL MOD_WIN MOD_SHIFT
    参数 vk指明热键的虚拟键码 
    首先(举个例子):  
      RegisterHotKey(handle,globaladdatom('hot key'),MOD_ALT,vk_f12);
    然后在form中声明一个函数(过程):
      procedure hotkey(var msg:tmessage);message wm_hotkey;
    过程如下:
    procedure TForm1.hotkey(var msg:tmessage);
    begin
      if (msg.LParamHi=VK_F12) and (msg.LParamLo=MOD_ALT) then
      begin
       form1.show;
       SetForegroundWindow(handle);
      end;
    end;
    这样,不管你在什么地方,按ALT+F12(可根据需要更改),你程序的窗口就会显示出来。
    当然,你要GlobalDeleteAtom;unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;type
      TForm1 = class(TForm)
        procedure FormCreate(Sender: TObject);
        procedure FormDestroy(Sender: TObject);
      private
        { Private declarations }
        aatom:atom;
        procedure hotkey(var msg:tmessage);message wm_hotkey;
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.DFM}procedure TForm1.FormCreate(Sender: TObject);
    begin
      aatom:=globaladdatom('hot key');
      RegisterHotKey(handle,aatom,MOD_ALT,vk_f12);
    end;procedure TForm1.hotkey(var msg:tmessage);
    begin
      if (msg.LParamHi=VK_F12) and (msg.LParamLo=MOD_ALT) then
        SetForegroundWindow(handle);
    end;    procedure TForm1.FormDestroy(Sender: TObject);
    begin
     globalDeleteatom(aatom);
    end;end.
      

  4.   

    dos下面曾经有个image软件,他的热键是同时按住ctrl+alt,再安顺序按s,d,x
    弹出窗口.如果要实现,该怎么呢?
      

  5.   

    我试了一下,按ALT+F12怎么看不出效果呢?