如何给程序设置块捷键
在主窗体按下Ctrl+1,Ctrl+2,Ctrl+3,分别打开Form1,Form2,Form3
如果是在OnKeyPress中写那么Ctrl+1,Ctrl+2,Ctrl+3,都应该怎么表示?

解决方案 »

  1.   

    主窗体的菜单的ShortCut里设置这分得来全不费工夫
      

  2.   

    工程文件中运行
    procedure TShortCutClass.ShowCaculator(var Msg: TWMKey; var Handled: Boolean);
    begin
      RunAutoQry(Msg.CharCode);
      RunHelp(Msg.CharCode);
    end;
    {$R *.RES}
    begin
      Application.Initialize;
      ShortCutClass := nil;
      Application.onShortCut := ShortCutClass.ShowCaculator;
    //////////
    公共pas单元
    procedure RunAutoQry(Key: Word);//调
    begin
      if Key = 119 then
      begin
        if (G_HaveRunAuotQry = 0) and (G_HaveEnterMain = 1)  then
        begin
          G_HaveRunAuotQry := 1;
          Application.CreateForm(TfrmAutoQry2, frmAutoQry2);
          frmAutoQry2.ShowModal;
          frmAutoQry2.Free;
          frmAutoQry2 := nil;
          G_HaveRunAuotQry := 0;
        end;
      end;
    end;
      

  3.   

    如何用ShortCuti来实现,请讲详细点。
      

  4.   

    放个菜单,设置ShortCut不就行了?用KeyPress事件也可以,或者RegistryHotkey();