home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 September / Chip_2001-09_cd1.bin / zkuste / delphi / kolekce / d6 / RX275D6.ZIP / Units / HINTPROP.PAS < prev    next >
Pascal/Delphi Source File  |  2001-06-24  |  2KB  |  82 lines

  1. {*******************************************************}
  2. {                                                       }
  3. {         Delphi VCL Extensions (RX)                    }
  4. {                                                       }
  5. {         Copyright (c) 1995 AO ROSNO                   }
  6. {                                                       }
  7. {*******************************************************}
  8.  
  9. unit HintProp;
  10.  
  11. interface
  12.  
  13. {$I RX.INC}
  14.  
  15. uses RTLConsts, DesignIntf, DesignEditors, VCLEditors;
  16.  
  17. type
  18.  
  19. { THintProperty }
  20.  
  21.   THintProperty = class(TCaptionProperty)
  22.   public
  23.     function GetAttributes: TPropertyAttributes; override;
  24. {$IFDEF WIN32}
  25.     function GetEditLimit: Integer; override;
  26. {$ENDIF}
  27.     procedure Edit; override;
  28.   end;
  29.  
  30. implementation
  31.  
  32. {$IFDEF WIN32}
  33.  {$D-}
  34. {$ENDIF}
  35.  
  36. uses SysUtils, Classes, {$IFDEF RX_D3} StrLEdit, {$ELSE} StrEdit, {$ENDIF}
  37.   TypInfo, Forms, Controls, rxStrUtils;
  38.  
  39. function THintProperty.GetAttributes: TPropertyAttributes;
  40. begin
  41.   Result := inherited GetAttributes + [paDialog];
  42. end;
  43.  
  44. {$IFDEF WIN32}
  45. function THintProperty.GetEditLimit: Integer;
  46. begin
  47.   if GetPropType^.Kind = tkString then
  48.     Result := GetTypeData(GetPropType)^.MaxLength
  49.   else Result := 1024;
  50. end;
  51. {$ENDIF}
  52.  
  53. procedure THintProperty.Edit;
  54. var
  55.   Temp: string;
  56.   Comp: TPersistent;
  57.   I, Cnt: Integer;
  58. begin
  59.   with TStrEditDlg.Create(Application) do
  60.   try
  61.     Comp := GetComponent(0);
  62.     if Comp is TComponent then
  63.       Caption := TComponent(Comp).Name + '.' + GetName
  64.     else Caption := GetName;
  65.     Temp := GetStrValue;
  66.     Cnt := WordCount(Temp, [#13, #10]);
  67.     for I := 1 to Cnt do
  68.       Memo.Lines.Add(ExtractWord(I, Temp, [#13, #10]));
  69.     Memo.MaxLength := GetEditLimit;
  70.     UpdateStatus(nil);
  71.     if ShowModal = mrOk then begin
  72.       Temp := Memo.Text;
  73.       while (Length(Temp) > 0) and (Temp[Length(Temp)] < ' ') do
  74.         System.Delete(Temp, Length(Temp), 1);
  75.       SetStrValue(Temp);
  76.     end;
  77.   finally
  78.     Free;
  79.   end;
  80. end;
  81.  
  82. end.