设置热键,和使用都没什么问题了!
现在有个问题,
当按下键时候:
我要能够使整个应用程序激活,而且处于最大化的状态,有答案就结帖!
速度!在线等!

解决方案 »

  1.   

    使用RegisterHotKey这个..
    详细去看。。
    http://topic.csdn.net/t/20010417/11/98763.html
      

  2.   

    我以前写的一个Demo,里面有你要的功能。{
    单元名称 : 系统热键、程序热键、程序隐藏示例单元
    整 理 者 : LihuaSoft 2006-12-29
    }{
    热键一 : Alt  + Shift + CapsLock  调出隐藏的程序主窗口
    热键二 : Ctrl + Alt   + F9        隐藏程序主窗口
    热键三 : Alt  + Shift + F10       打开一个提示框
    }{
        在windows中规定应用程序热键的唯一标识符取值范围在0x0000~0xBFFF之间,
    动态链接库的取值范围在0xC000~0XFFFF之间。
        热键的辅助按键还包括Mod_Ctrl,Mod_Alt和Mod_Shift,对于windows兼容键盘,
    还包括windows标志键,Mod_Win。
        热键设置成功后,在程序运行过程中如果有预定义的热键被按下,windows系统
    都会给应用程序发送一个wm_hotkey消息。
    }unit Unit_HotKeyDemo;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;type
      TForm_HotKeyDemo = class(TForm)
        Label1: TLabel;
        Label2: TLabel;
        Label3: TLabel;
        procedure FormCreate(Sender: TObject);
        procedure FormClose(Sender: TObject; var Action: TCloseAction);  private
        { Private declarations }    ID1,ID2,ID3: Integer;    procedure WMHotKeyHandle(var Msg : TWMHotKey); message WM_HotKey;  public
        { Public declarations }
      end;var
      Form_HotKeyDemo: TForm_HotKeyDemo;implementation{$R *.dfm}procedure WhenHotKey1Press;
    begin
      showmessage('你按下了 Alt + Shift + CapsLock 组合键,主窗体将显现');
      application.ShowMainForm := true;
      application.MainForm.Show;
      Form_HotKeyDemo.WindowState := wsMaximized;
    end;procedure WhenHotKey2Press;
    begin
      showmessage('你按下了 Ctrl + Alt + F9 组合键,主窗体将隐藏');
      application.ShowMainForm := false;
      application.MainForm.Hide;
    end;procedure WhenHotKey3Press;
    begin
      showmessage('你按下了 Alt + Shift + F10 组合键');
    end;procedure TForm_HotKeyDemo.WMHotKeyHandle(var Msg : TWMHotKey);
    begin
      msg.Result:=1;//该消息已经处理
      if msg.HotKey = ID1 then WhenHotKey1Press;
      if msg.HotKey = ID2 then WhenHotKey2Press;
      if msg.HotKey = ID3 then WhenHotKey3Press;
    end;procedure TForm_HotKeyDemo.FormCreate(Sender: TObject);
    begin  Font.Assign(Screen.MenuFont);
      caption := '系统热键、程序热键、程序隐藏示例';
      label1.Caption := '热键一 : Alt  + Shift + CapsLock  调出隐藏的程序主窗口并最大化';
      label2.Caption := '热键二 : Ctrl + Alt   + F9        隐藏程序主窗口';
      label3.Caption := '热键三 : Alt  + Shift + F10       打开一个提示框';  { 注册 Alt + Shift + CapsLock 组合热键 }
      if FindAtom('LihuaSoftHotKey1') = 0 then
         begin
         ID1:=GlobalAddAtom(pchar('LihuaSoftHotKey1'))-$C000;
         RegisterHotkey(Handle,ID1,MOD_Alt or mod_Shift,$14);
         end;
      { 注册 Ctrl + Alt + F9 组合热键 }
      if FindAtom('LihuaSoftHotKey2') = 0 then
         begin
         ID2:=GlobalAddAtom(pchar('LihuaSoftHotKey2'))-$C000;
         RegisterHotkey(Handle,ID2,MOD_Control or mod_Alt,VK_F9);
         end;
      { 注册 Alt + Shift + F10 组合热键 }
      if FindAtom('LihuaSoftHotKey3') = 0 then
         begin
         ID3:=GlobalAddAtom(pchar('LihuaSoftHotKey3'))-$C000;
         RegisterHotkey(Handle,ID3,MOD_Alt or mod_Shift,VK_F10);
         end;
    end;procedure TForm_HotKeyDemo.FormClose(Sender: TObject;
      var Action: TCloseAction);
    begin
      { 注销热键 }
      if ID1 <> 0 then begin UnregisterHotKey(Handle,ID1); DeleteAtom(ID1); end;
      if ID2 <> 0 then begin UnregisterHotKey(Handle,ID2); DeleteAtom(ID2); end;
      if ID3 <> 0 then begin UnregisterHotKey(Handle,ID3); DeleteAtom(ID3); end;
    end;end.
      

  3.   

    上面代码中Form_HotKeyDemo.WindowState := wsMaximized;这句是根据你的要求(窗体最大化)加上的。如果改为下面这样,是一样的效果:application.MainForm.WindowState := wsMaximized;