home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 June / Chip_2002-06_cd1.bin / zkuste / delphi / kolekce / d6 / rxlibsetup.exe / {app} / units / HINTPROP.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  2002-02-19  |  2.1 KB  |  84 lines

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