home *** CD-ROM | disk | FTP | other *** search
/ Chip 1999 January / Chip_1999-01_cd.bin / zkuste / delphi / D1 / DRBOBC.ZIP / PICTEDIT.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1995-12-12  |  1.1 KB  |  46 lines

  1. unit PictEdit;
  2. interface
  3. uses DsgnIntf;
  4.  
  5. Type
  6.   TPictureEditor = class(TClassProperty)
  7.   public
  8.     function GetAttributes: TPropertyAttributes; override;
  9.     procedure Edit; override;
  10.   end;
  11.  
  12.   procedure Register;
  13.  
  14. implementation
  15. uses SysUtils, Controls, Graphics, TypInfo, ImageFrm;
  16.  
  17.   function TPictureEditor.GetAttributes: TPropertyAttributes;
  18.   begin
  19.     Result := [paDialog]
  20.   end {GetAttributes};
  21.  
  22.   procedure TPictureEditor.Edit;
  23.   begin
  24.     with TImageForm.Create(nil) do
  25.     try
  26.       ImageDrBob.Picture := TPicture(GetOrdValue);
  27.       if ShowModal = mrOk then
  28.       begin
  29.         if (GetPropType^.Name = 'TPicture') then
  30.           SetOrdValue(LongInt(ImageDrBob.Picture))
  31.         else { Bitmap }
  32.           SetOrdValue(LongInt(ImageDrBob.Picture.Bitmap))
  33.       end
  34.     finally
  35.       Free
  36.     end
  37.   end {Edit};
  38.  
  39.   procedure Register;
  40.   begin
  41.     RegisterPropertyEditor(TypeInfo(TPicture), nil,
  42.                            '', TPictureEditor);
  43.     RegisterPropertyEditor(TypeInfo(TBitmap), nil,
  44.                            '', TPictureEditor)
  45.   end;
  46. end.