home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 October / Chip_2001-10_cd1.bin / zkuste / delphi / kolekce / d56 / TDSOFT.ZIP / EditListBox.pas next >
Encoding:
Pascal/Delphi Source File  |  2001-07-27  |  1.3 KB  |  66 lines

  1. unit EditListBox;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   StdCtrls;
  8.  
  9. type
  10.   TEditListBox = class(TListBox)
  11.   private
  12.     { Private declarations }
  13.     procedure WMCHAR (var Mes: TMessage); Message WM_CHAR;
  14.   protected
  15.     { Protected declarations }
  16.   public
  17.     { Public declarations }
  18.     constructor Create(AOwner: TComponent); override;
  19.   published
  20.     { Published declarations }
  21.   end;
  22.  
  23. procedure Register;
  24.  
  25. implementation
  26.  
  27. procedure Register;
  28. begin
  29.   RegisterComponents('TDSoft', [TEditListBox]);
  30. end;
  31.  
  32. { TEditListBox }
  33.  
  34. constructor TEditListBox.Create(AOwner: TComponent);
  35. begin
  36.   inherited;
  37.   Font.Name:='Courier New';
  38.   Font.Size:=10;
  39.  
  40. end;
  41.  
  42. procedure TEditListBox.WMCHAR(var Mes: TMessage);
  43. var
  44.     Position: Byte;
  45. begin
  46.     TForm(Parent).Caption:=IntToStr(Mes.wParam);
  47.  
  48.     if ItemIndex=-1 then Exit;
  49.     Position:=Length(Items[ItemIndex]);
  50.  
  51.   if Position=0 then
  52.       if chr(Mes.wParam) in ['C','D','E','F','G','A','B'] then
  53.         Items[ItemIndex]:=chr(Mes.wParam);
  54.  
  55.   if Position=1 then
  56.   begin
  57.       if chr(Low(Mes.wParam)) = '-' then
  58.         Items[ItemIndex]:=Items[ItemIndex] + 'b';
  59.       if chr(Low(Mes.wParam)) = '+' then
  60.         Items[ItemIndex]:=Items[ItemIndex] + '#';
  61.   end;
  62.  
  63. end;
  64.  
  65. end.
  66.