全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:2987
推到 Plurk!
推到 Facebook!

Working with KeyBoard Binding

 
axsoft
版主


發表:681
回覆:1056
積分:969
註冊:2002-03-13

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-02-11 14:30:26 IP:61.218.xxx.xxx 未訂閱
Working with KeyBoard Binding    資料來源: www.delphi3000.com    How to set your own shortcut keys while working with delphi editor?  If you want your own piece of shortcut key to perform a certain action for you then this code will help    {Include this unit in a delphi package, and install the package. Now, if you press ctrl + d you will get the 'This was written by Subha Narayanan' in your editor window.     The actual process is very simple. We use the interface TNotifier Object and IOTAkeyboardbinding to create our own interface.     our main key to perform this action is the procedure 'Dupline' }  -------------------------------------------------------------------------------- 
unit DupLineBinding;     interface     uses 
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, 
  menus, ToolsApi;     type 
  TDupLineBinding = class(TNotifierObject, IOTAKeyboardBinding) 
  private 
    { Private declarations } 
  protected 
    { Protected declarations } 
  public 
    { Public declarations } 
    Procedure DupLine(Const Context: IOTAKeyContext; KeyCode: TShortCut; 
               Var BindingResult : TKeyBindingResult); 
    {IOTAKeyBoardBinding} 
    function GetBindingType : TBindingType; 
    function GetDisplayName : string; 
    function GetName : string; 
    procedure BindKeyboard(const BindingServices: IOTAKeyBindingServices);       published 
    { Published declarations } 
  end;     procedure Register;     implementation     procedure Register; 
begin 
  (BorlandIDEServices as IOTAKeyBoardServices).AddKeyBoardBinding(TDupLineBinding.Create); 
end;     function TDupLineBinding.GetBindingType: TBindingType; 
begin 
   Result := btPartial; 
end;     function TDupLineBinding.GetDisplayName ; 
begin 
   Result := 'Subha Line Binding'; {The way it shoudl appear in the delphi ide editor window} 
end;     function TDupLineBinding.GetName ; 
begin 
   Result := 'sn.dupline';  {Should be unique} 
end;     procedure TDupLineBinding.DupLine(Const Context: IOTAKeyContext; KeyCode: TShortCut; Var BindingResult : TKeyBindingResult); 
var ep : IOTAEditPosition; eb : IOTAEditBlock; r, c : Integer; 
begin 
{Actual place where the writting into editor takes place} 
   try 
      ep := Context.EditBuffer.EditPosition; 
      ep.Save; 
      r := ep.Row; 
      c := ep.Column; 
      eb := Context.EditBuffer.EditBlock; 
      ep.MoveBOL; 
      eb.Reset; 
      eb.BeginBlock; 
      eb.Extend(Ep.Row 1, 1); 
      eb.EndBlock; 
      eb.Copy(False); 
      ep.MoveBOL; 
      ep.Paste; 
      ep.Move(r,c); 
   finally 
      ep.Restore; 
   end; 
   BindingResult := krHandled; 
end;     procedure TDupLineBinding.BindKeyboard(const BindingServices: IOTAKeyBindingServices); 
{Here we specify the shortcut key which should do the action} 
begin 
   BindingServices.AddKeyBinding([Shortcut(Ord('D'),[ssCtrl])],DupLine,nil); 
end;         end.
聯盟----Visita網站http://www.vista.org.tw ---[ 發問前請先找找舊文章 ]--- 發表人 - axsoft 於 2003/02/11 14:48:57
系統時間:2017-09-25 3:25:16
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!