home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 September / Chip_2001-09_cd1.bin / zkuste / delphi / kolekce / d56 / RMCTL.ZIP / rmFormEditBinding.pas < prev    next >
Pascal/Delphi Source File  |  2001-06-22  |  2KB  |  80 lines

  1. {================================================================================
  2. Copyright (C) 1997-2001 Mills Enterprise
  3.  
  4. Unit     : rmFormEditBinding
  5. Purpose  : dialog form for choosing key binding combinations
  6. Date     : 10-26-2000
  7. Author   : Ryan J. Mills
  8. Version  : 1.80
  9. ================================================================================}
  10.  
  11. unit rmFormEditBinding;
  12.  
  13. interface
  14.  
  15. {$I CompilerDefines.INC}
  16.  
  17. uses
  18.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  19.   ExtCtrls, StdCtrls, Menus;
  20.  
  21. type
  22.   TrmFrmEditBinding = class(TForm)
  23.     GroupBox1: TGroupBox;
  24.     cbAlt: TCheckBox;
  25.     cbCTRL: TCheckBox;
  26.     cbShift: TCheckBox;
  27.     cbxKey: TComboBox;
  28.     Button1: TButton;
  29.     Button2: TButton;
  30.   private
  31.     function GetBinding: TShortcut;
  32.     procedure SetBinding(const Value: TShortcut);
  33.     { Private declarations }
  34.   public
  35.     { Public declarations }
  36.     property Binding:TShortcut read GetBinding write SetBinding default scNone;
  37.   end;
  38.  
  39. implementation
  40.  
  41. {$R *.DFM}
  42.  
  43. { TrmFrmEditBinding }
  44.  
  45. function TrmFrmEditBinding.GetBinding: TShortcut;
  46. var
  47.    wKey : Word;
  48.    wShift : TShiftState;
  49. begin
  50.   if cbxKey.ItemIndex = 0 then
  51.      result := scNone
  52.   else
  53.   begin
  54.      ShortCutToKey(TextToShortCut(cbxKey.Text), wKey, wShift);
  55.      wShift := [];
  56.      if cbAlt.checked then
  57.         wShift := wShift + [ssAlt];
  58.      if cbCtrl.checked then
  59.         wShift := wShift + [ssCtrl];
  60.      if cbShift.checked then
  61.         wShift := wShift + [ssShift];
  62.  
  63.      result := ShortCut(wKey, wShift);
  64.   end;
  65. end;
  66.  
  67. procedure TrmFrmEditBinding.SetBinding(const Value: TShortcut);
  68. var
  69.    wKey : Word;
  70.    wShift : TShiftState;
  71. begin
  72.    ShortCutToKey(Value, wkey, wShift);
  73.    cbAlt.checked := (ssAlt in wShift);
  74.    cbCTRL.checked := (ssCtrl in wShift);
  75.    cbShift.checked := (ssShift in wShift);
  76.    cbxKey.ItemIndex := cbxKey.items.IndexOf(ShortCutToText(Shortcut(wKey, [])));
  77. end;
  78.  
  79. end.
  80.