Link to home
Start Free TrialLog in
Avatar of MelissaCandyGirl
MelissaCandyGirl

asked on

Problem Installing a component

Hi :)

I've done a component that uses images in an ImageList. I've saved the images into a .RES file with WriteComponentResFile. I also would like to change the icon of my component in the pallet, I heard that I have to open Borland Image Editor and make a .dcr, but can I use a .ico that I already have???

And about that .RES images, how do I put it inside the .dpk to extract it somewhere the component knows how to find?? And, at last, if I don't want users to have access to the source do I have to add just the .dcu in the .dpk. And to allow them to see it add the .pas??
Avatar of Geert G
Geert G
Flag of Belgium image

why not use a form with the imagelist on
then use that form from your code

(you don't need to show the form, it can stay invisible)

i'll whip up a sample
you actually need to create 2 packages:
1 for the runtime
1 for the design time

the first package contains all the functionality of component
the second package is just all the routines to register the component in the Delphi IDE
and off course the component editors

this is a lot of questions
let's start with the runtime package, this should end up with a .bpl file
have you got this far yet ? compiling everything ?
Avatar of MelissaCandyGirl
MelissaCandyGirl

ASKER

Ok, I`ll be waiting for the example because I dont think I got this =p
Actually I don't know how to make .bpl, I was trying to do this with .dpk. Can you help me with that??
i created 2 test units
1 a form with a imagelist
1 a descendant of a TImage which i will use as my component

unit uFormImages;
 
interface
 
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ComCtrls, ImgList;
 
type
  TfrmImages = class(TForm)
    ilComponent: TImageList;
  end;
 
var
  frmImages: TfrmImages;
 
function FormImages(Index: Integer; aBitmap: TBitmap): Boolean;
function FormImagesMax: Integer;
 
implementation
 
{$R *.dfm}
 
var
  mFrmImages: TfrmImages;
 
procedure FormImagesInit;
begin
  if not Assigned(mFrmImages) then
    mFrmImages := TfrmImages.Create(nil);
end;
 
procedure FormImagesDone;
begin
  FreeAndNil(mFrmImages);
end;
 
function FormImages(Index: Integer; aBitmap: TBitmap): Boolean;
begin
  Result := True;
  try
    FormImagesInit;
    mFrmImages.ilComponent.GetBitmap(Index, aBitmap);
  except
    Result := False;
  end;
end;
 
function FormImagesMax: Integer;
begin
  FormImagesInit;
  Result := mFrmImages.ilComponent.Count;
end;
 
initialization
 
finalization
  FormImagesDone;
end.

Open in new window

dfm for uFormImages
object frmImages: TfrmImages
  Left = 0
  Top = 0
  Caption = 'Images'
  ClientHeight = 110
  ClientWidth = 149
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object ilComponent: TImageList
    Left = 24
    Top = 16
    Bitmap = {
      494C010104000600040010001000FFFFFFFFFF00FFFFFFFFFFFFFFFF424D3600
      0000000000003600000028000000400000002000000001002000000000000020
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000B48D8A00B18A
      8700B1888500AF868300AE858200AD838000AB817F00AA807C00A97F7B00A87C
      7900A77B7800A77A7700A6797600000000000000000000000000000000000000
      0000000000000136020001360200013602000136020001360200013602000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000007878780078787800787878007878780078787800787878000000
      0000000000000000000000000000000000000000000000000000B58F8C00FEFE
      FD00FEFEFD00FEFEFD00FEFEFD00FEFEFD00FEFEFD00FEFEFD00FEFEFD00FEFE
      FD00FEFEFD00FEFEFD00A77B780000000000000000000000000000000000034A
      0400038F0A0003A40C00039F0C00039F0C00039F0C00039F0C0003A40C000388
      0A000136020000000000000000000000000000000000E8E8E800E6E6E600E4E4
      E400E1E1E100DFDFDF00DDDDDD00DBDBDB00D9D9D900D7D7D700D6D6D600D5D5
      D500D4D4D400D4D4D400D4D4D400000000000000000000000000000000008080
      8000989898009E9E9E009D9D9D009D9D9D009D9D9D009D9D9D009E9E9E009595
      9500787878000000000000000000000000000000000000000000B7928E00FEFC
      FB00FEFCFB00FEFCFB00FEFCFB00FEFCFB00FEFCFB00FEFCFB00FEFCFB00FEFC
      FB00FEFCFB00FEFCFB00A97D790000000000000000000000000006690C0006A5
      130004A30F00039E0C00039E0C00039E0C00039E0C00039E0C00039E0C0003A4
      0C00039D0C0001360200000000000000000000000000E9E9E900E8E8E800E4E4
      E400E3E3E300E0E0E000DFDFDF00888888008888880088888800888888008888
      880088888800D4D4D400D4D4D4000000000000000000000000008E8E8E00A0A0
      A0009F9F9F009C9C9C009C9C9C009C9C9C009C9C9C009C9C9C009C9C9C009E9E
      9E009C9C9C007878780000000000000000000000000000000000B9949200FEFA
      F600FEFAF600FEFAF600FEFAF600FEFAF600FEFAF600FEFAF600FEFAF600FEFA
      F600FEFAF600FEFAF600AA7F7C00000000000000000006690C000EAB2A000AA4
      1F00049F0F00049F0F00049F0F002BB53B00EBF8EE008ED99600039E0C00039E
      0C00039E0C0003990B00013602000000000000000000EDEDED00EBEBEB00E9E9
      E900E6E6E600E3E3E300E2E2E200DFDFDF00DEDEDE00DBDBDB00DADADA00D7D7
      D700D7D7D700D5D5D500D4D4D40000000000000000008E8E8E00A7A7A700A2A2
      A2009D9D9D009D9D9D009D9D9D00FFFFFF00FFFFFF009E9E9E009C9C9C009C9C
      9C009C9C9C009A9A9A0078787800000000000000000000000000BB979300FEF9
      F400FEF9F400FEF9F400FEF9F400FEF9F400FEF9F400FEF9F400FEF9F400FEF9
      F400FEF9F400FEF9F400AA807D0000000000000000000F952B0011B034000EA9
      2B000DA7260009A41C0013AA280075D18200FFFFFF00FFFFFF008BD99200039E
      0C00039E0C0003A50C00037A08000000000000000000EEEEEE00EDEDED008888
      8800888888008888880088888800888888008888880088888800888888008888
      880088888800D6D6D600D5D5D5000000000000000000A1A1A100AAAAAA00A6A6
      A6009D9D9D009D9D9D00E8E8E800FFFFFF00FFFFFF009F9F9F009C9C9C009C9C
      9C009C9C9C009E9E9E0091919100000000000000000000000000BD999600FEF6
      EF00FEF6EF00FEF6EF00FEF6EF00FEF6EF00FEF6EF00FEF6EF00FEF6EF00FEF6
      EF00FEF6EF00FEF6EF00AD83800000000000039E0C001AB64A0016AF3E0016AF
      3E0013AC35001DB03B001AAF350013AB2A0029B53D00E5F7E700FFFFFF008BD9
      9200039E0C00039E0C0003A50C000136020000000000F2F2F200F0F0F000EDED
      ED00EBEBEB00E8E8E800E7E7E700E4E4E400E3E3E300DFDFDF00DEDEDE00DBDB
      DB00DBDBDB00D8D8D800D7D7D700000000009C9C9C00B0B0B000ACACAC00ACAC
      AC009D9D9D00FFFFFF00FFFFFF00F1F1F100B6B6B600A4A4A4009C9C9C009C9C
      9C009C9C9C009C9C9C009E9E9E00787878000000000000000000BD9B9800FEF5
      ED00FEF5ED00FEF5ED00FEF5ED00FEF5ED00FEF5ED00FEF5ED00FEF5ED00FEF5
      ED00FEF5ED00FDF4EC00AD84810000000000039E0C001CB44E0019B1470019B1
      470028B64E0021B241001EB03C0017AC300014AB2B006DCF7D00FFFFFF00FFFF
      FF004EC45A00039E0C0003A10C000136020000000000F3F3F300F2F2F200EFEF
      EF00EDEDED00EAEAEA00E8E8E800888888008888880088888800888888008888
      880088888800D9D9D900D8D8D800000000009C9C9C00B0B0B000AEAEAE00AEAE
      AE00D7D7D700FFFFFF00FFFFFF00BBBBBB00AAAAAA00A6A6A600A4A4A400A0A0
      A0009F9F9F009C9C9C009D9D9D00787878000000000000000000C09E9B00FEF3
      E800FEF3E800FEF3E800FEF3E800FEF3E800FEF3E800FEF3E800FEF3E800FEF3
      E800FDF2E700FDF1E600AF87840000000000039E0C0031BC63001FB45200FFFF
      FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
      FF00FFFFFF00039E0C00039E0C000136020000000000F6F6F600F5F5F500F2F2
      F200F0F0F000EDEDED00ECECEC00E8E8E800E8E8E800E4E4E400E3E3E300DFDF
      DF00DEDEDE00DCDCDC00DADADA00000000009C9C9C00BBBBBB00B2B2B200FFFF
      FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
      FF00FFFFFF009C9C9C009C9C9C00787878000000000000000000C1A09C00FFF2
      E600FFF2E600FFF2E600FFF2E600FFF2E600FFF2E600FFF2E600FFF2E600FEF1
      E500FEF1E500F9ECDE00B188860000000000039E0C0047C5750024B65600F0FB
      F400FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00D9F3DE00FFFFFF00FFFF
      FF00FFFFFF00039E0C00039E0C000136020000000000F7F7F700F6F6F6008888
      8800888888008888880088888800888888008888880088888800888888008888
      880088888800DDDDDD00DCDCDC00000000009C9C9C00C7C7C700B4B4B400FEFE
      FE00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
      FF00FFFFFF009C9C9C009C9C9C00787878000000000000000000C4A39F00FFEF
      E100FFEFE100FFEFE100FFEFE100FFEFE100FFEFE100FFEFE100FEEEE000FDED
      DF00F8E8D800E5D6C100B38C890000000000039E0C0083D9A40052C97D0038BF
      680037BF670034BC5F0030BB5B002AB750002DB85200FFFFFF00FFFFFF0099E0
      A60013AA2800039E0D0003A30C000136020000000000FAFAFA00F9F9F900F7F7
      F700F5F5F500F2F2F200F1F1F100EDEDED00ECECEC00E9E9E900E8E8E800E4E4
      E400E3E3E300E0E0E000DFDFDF00000000009C9C9C00E0E0E000CCCCCC00BFBF
      BF00BFBFBF00FFFFFF00FFFFFF00F0F0F000B9B9B900B2B2B200AFAFAF00ABAB
      AB00A9A9A9009D9D9D009D9D9D00787878000000000000000000C4A4A100FFEE
      DF00FFEEDF00FFEEDF00FFEEDF00FFEEDF00FFEEDF00FEEDDE00FEEDDE00F7E6
      D500EEDECB00D9C9B100B58E8B0000000000039E0C0088DCA90086DAA50038BF
      680038BF680036BD640034BC600044C26B00D8F3E000FFFFFF00FFFFFF000CA7
      25000AA5200005A0110004A50E000136020000000000FBFBFB00FAFAFA00F8F8
      F800F6F6F600F3F3F300F2F2F200888888008888880088888800888888008888
      880088888800E1E1E100E0E0E000000000009C9C9C00E2E2E200E1E1E100BFBF
      BF00BFBFBF00EFEFEF00FFFFFF00FFFFFF00FFFFFF00B4B4B400A8A8A800A5A5
      A500A3A3A3009E9E9E009F9F9F00787878000000000000000000C6A7A300FFEC
      DA00FFECDA00FFECDA00FFECDA00FFEBDA00FEEBD900FCE9D700F6E3CF00E2D0
      B800D7C6AB00E5D4C100BB989400000000000000000037B557009DE2B80067CF
      8C0038BF680038BF680038BF68005FCC8400FFFFFF0070D18E0016AD3F0011AB
      31000EA728000AAC1F00046B0C000000000000000000FCFCFC00FCFCFC00FAFA
      FA00F9F9F900F7F7F700F5F5F500F2F2F200F0F0F000EEEEEE00ECECEC00E9E9
      E900E8E8E800E4E4E400E3E3E3000000000000000000BCBCBC00EAEAEA00D4D4
      D400BFBFBF00BFBFBF00BFBFBF00FFFFFF00FFFFFF00B8B8B800ABABAB00A8A8
      A800A6A6A600A5A5A5008D8D8D00000000000000000000000000C7A8A400FFEA
      D800FFEAD800FFEAD800FFEAD800FEE9D700FEE9D700F5E1CC00F7EEE400FEFE
      FD00FEF8F200C5A59F00000000000000000000000000039E0C005AC98000BBEB
      CE0073D4960038BF680038BF680037BD660035BC62002FBA590018B0440012AB
      350010A92E00098E1C00034A04000000000000000000FCFCFC00FCFCFC008888
      8800888888008888880088888800888888008888880088888800888888008888
      880088888800E6E6E600E5E5E50000000000000000009C9C9C00CECECE00F6F6
      F600DADADA00BFBFBF00BFBFBF00BEBEBE00BDBDBD00BABABA00ADADAD00A9A9
      A900A7A7A7009B9B9B0080808000000000000000000000000000C8AAA700FFE8
      D300FFE8D300FFE7D200FEE7D200FBE4CE00F3DDC600DFCAAF00FAF6F100DFC6
      BE00D2BAB7000000000000000000000000000000000000000000039E0C0059C9
      7E00A3E3BC00C1EDD100A0E2B80068D08E005CCB840058CA81004FC77A0022BA
      500010982F0006690C00000000000000000000000000FCFCFC00FCFCFC00FCFC
      FC00FCFCFC00FBFBFB00F9F9F900F7F7F700F5F5F500F3F3F300F1F1F100EEEE
      EE00EDEDED00EAEAEA00E8E8E8000000000000000000000000009C9C9C00CECE
      CE00EDEDED00F8F8F800EBEBEB00D5D5D500D0D0D000CECECE00CACACA00B4B4
      B400A2A2A2008E8E8E0000000000000000000000000000000000C9ABA800FFE7
      D100FFE7D100FEE6D000FEE6CF00F3DBC300E9D3B800E5D6C200FAF0E700D9C5
      C40000000000000000000000000000000000000000000000000000000000039E
      0C0035B553009AE1B600B1E9C600ABE6C1009DE2B7006CD393004AC979000F84
      270006680D0000000000000000000000000000000000FCFCFC00FCFCFC00FCFC
      FC00FCFCFC00FCFCFC00FAFAFA00F8F8F800F7F7F700F4F4F400F3F3F300EFEF
      EF00EEEEEE00EBEBEB00E9E9E900000000000000000000000000000000009C9C
      9C00BBBBBB00E9E9E900F2F2F200EFEFEF00EAEAEA00D7D7D700C9C9C9009C9C
      9C008D8D8D000000000000000000000000000000000000000000CAACA900C9AB
      A800C9AAA700C8A8A500C7A8A500C5A6A300C5A5A200CFB4B200E7DAD9000000
      0000000000000000000000000000000000000000000000000000000000000000
      000000000000039E0C00039E0C00039E0C00039E0C00039E0C00039E0C000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000009C9C9C009C9C9C009C9C9C009C9C9C009C9C9C009C9C9C000000
      000000000000000000000000000000000000424D3E000000000000003E000000
      2800000040000000200000000100010000000000000100000000000000000000
      000000000000000000000000FFFFFF0000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      00000000000000000000000000000000C001F81FFFFFF81FC001E0078001E007
      C001C0038001C003C001800180018001C001800180018001C001000080010000
      C001000080010000C001000080010000C001000080010000C001000080010000
      C001000080010000C001800180018001C003800180018001C007C0038001C003
      C00FE0078001E007C01FF81FFFFFF81F}
  end
end

Open in new window

the unit for the component
unit uAnimImage;
 
interface
 
uses Classes, ExtCtrls, Graphics;
 
type
  TAnimImage = class(TImage)
  private
    fTimer: TTimer;
    fImageIndex: Integer;
    procedure SetTimerInterval(const Value: Cardinal);
    procedure SetCycling(const Value: Boolean);
    function GetTimerInterval: Cardinal;
    function GetCycling: Boolean;
    procedure TimerFired(Sender: TObject);
  protected
    procedure DoAnimate; virtual;
  public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
    property TimerInterval: Cardinal read GetTimerInterval write SetTimerInterval default 3000;
    property Cycling: Boolean read GetCycling write SetCycling;
  end;
 
implementation
 
uses SysUtils, uFormImages;
 
{ TAnimImage }
 
constructor TAnimImage.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  fTimer := TTimer.Create(Self);
  fTimer.Enabled := False;
  fTimer.Interval := 3000;
  fTimer.OnTimer := TimerFired;
  fImageIndex := -1;
end;
 
destructor TAnimImage.Destroy;
begin
  fTimer.Enabled := False;
  FreeAndNil(fTimer);
  inherited Destroy;
end;
 
procedure TAnimImage.DoAnimate;
var aBitmap: TBitmap;
begin
  if not (csDestroying in ComponentState) then
  begin
    if not Assigned(Picture.Graphic) or Picture.Graphic.Empty then
      Picture.Graphic := TBitmap.Create;
    Inc(fImageIndex);
    if fImageIndex >= FormImagesMax then
      fImageIndex := 0;
    aBitmap := TBitmap.Create;
    try
      FormImages(fImageIndex, aBitmap);
      Picture.Bitmap.Assign(aBitmap);
    finally
      FreeAndNil(aBitmap);
    end;
    Invalidate;
  end;
end;
 
function TAnimImage.GetCycling: Boolean;
begin
  Result := fTimer.Enabled;
end;
 
function TAnimImage.GetTimerInterval: Cardinal;
begin
  Result := fTimer.Interval;
end;
 
procedure TAnimImage.SetCycling(const Value: Boolean);
begin
  fTimer.Enabled := False;
  if Value then
    TimerFired(Self);
end;
 
procedure TAnimImage.SetTimerInterval(const Value: Cardinal);
var sEnabled: Boolean;
begin
  sEnabled := fTimer.Enabled;
  fTimer.Enabled := False;
  try
    fTimer.Interval := Value;
  finally
    fTimer.Enabled := sEnabled;
  end;
end;
 
procedure TAnimImage.TimerFired(Sender: TObject);
begin
  fTimer.Enabled := False;
  try
    DoAnimate;
  finally
    fTimer.Enabled := True;
  end;
end;
 
end.

Open in new window

and then a project with a test form to put this uAnimImage to use
unit uTest;
 
interface
 
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls, uAnimImage;
 
type
  TForm3 = class(TForm)
    btnTest: TButton;
    procedure btnTestClick(Sender: TObject);
  private
    fimTest: TAnimImage;
  public
    { Public declarations }
  end;
 
var
  Form3: TForm3;
 
implementation
 
{$R *.dfm}
 
procedure TForm3.btnTestClick(Sender: TObject);
begin
  fimTest := TAnimImage.Create(Self);
  with fimTest do
  begin
    Name := 'imTest';
    Parent := Self;
    Left := 176;
    Top := 40;
    Width := 209;
    Height := 161;
    Cycling := True;
  end;
 
end;
 
end.

Open in new window

now we have a starting base for a runtime package

i am using D2009, i don't now what you are using, but in essence this should be the same

right click in the project manager on the project group and add a new package
I save the package  in the same directory as the testing project
(you could put the test project in a lower directory)
then i added the 2 units to this package (uAnimImage and uFormImages)
changed the properties and set  

this is your runtime package

pkgrAnimImage
pkg = package
r = runtime
AnimImage = name of component
package pkgrAnimImage;
 
{$R *.res}
{$ALIGN 8}
{$ASSERTIONS ON}
{$BOOLEVAL OFF}
{$DEBUGINFO ON}
{$EXTENDEDSYNTAX ON}
{$IMPORTEDDATA ON}
{$IOCHECKS ON}
{$LOCALSYMBOLS ON}
{$LONGSTRINGS ON}
{$OPENSTRINGS ON}
{$OPTIMIZATION ON}
{$OVERFLOWCHECKS OFF}
{$RANGECHECKS OFF}
{$REFERENCEINFO OFF}
{$SAFEDIVIDE OFF}
{$STACKFRAMES OFF}
{$TYPEDADDRESS OFF}
{$VARSTRINGCHECKS ON}
{$WRITEABLECONST OFF}
{$MINENUMSIZE 1}
{$IMAGEBASE $400000}
{$RUNONLY}
{$IMPLICITBUILD ON}
 
requires
  rtl,
  vcl;
 
contains
  uAnimImage in 'uAnimImage.pas',
  uFormImages in 'uFormImages.pas' {frmImages};
 
end.

Open in new window

now we need to register this component in the ide

for this, we create a new package, again right click in project manager on project group add new project (package)
we need to add the just created runtime package to this design time package
the previously compiled package should be in the $(BDSCOMMONDIR)\Dcp
which is something like this : C:\Documents and Settings\All Users\Shared Documents\RAD Studio\6.0\Dcp
and off course change to design only
package pkgdAnimImage;
 
{$R *.res}
{$ALIGN 8}
{$ASSERTIONS ON}
{$BOOLEVAL OFF}
{$DEBUGINFO ON}
{$EXTENDEDSYNTAX ON}
{$IMPORTEDDATA ON}
{$IOCHECKS ON}
{$LOCALSYMBOLS ON}
{$LONGSTRINGS ON}
{$OPENSTRINGS ON}
{$OPTIMIZATION ON}
{$OVERFLOWCHECKS OFF}
{$RANGECHECKS OFF}
{$REFERENCEINFO OFF}
{$SAFEDIVIDE OFF}
{$STACKFRAMES OFF}
{$TYPEDADDRESS OFF}
{$VARSTRINGCHECKS ON}
{$WRITEABLECONST OFF}
{$MINENUMSIZE 1}
{$IMAGEBASE $400000}
{$DESIGNONLY}
{$IMPLICITBUILD ON}
 
requires
  rtl,
  pkgrAnimImage;
 
end.

Open in new window

the rest will be for later on

you still need to a unit to Register the component
and a .dcr to change the icon in the IDE

i'll post tonight
If you put the component into a package it is best to use the .RES file of the package to store the icon of the component you want to be displayed into pallete of Delphi IDE instead of .dcr.

The main reason for doing this is to be able to manage with more ease the component icons.
Propably the best free resource editor is XN Resource Editor which can be found at
http://www.wilsonc.demon.co.uk/d10resourceeditor.htm

In the res file of the package you can add a bitmap resource naming it with the component class(all letters must be capital) and designing or copying from clipboard your ico or png or jpg.
Thats at least what i did in my package which can be found in this link
http://www.gtdelphicomponents.gr/wp-content/uploads/2009/07/gtcomponentpack_v_1_0_40.zip
It's open source and freeware.
Reading the pack you will have a good start on how to create packages manage package components icons e.t.c

Just open the .res of the pack with XN Resource Editor and you'll understand the logic that the Delphi IDE uses as far displaying icons into the component pallete.




add this unit to the design time package
then hit install
unit uAnimImageReg;
 
interface
 
procedure Register;
 
implementation
 
uses uAnimImage, Classes;
 
procedure Register;
begin
  RegisterComponents('Samples', [TAnimImage]);
end;
 
end.

Open in new window

tomorrow i'll show the .dcr
Geert_Gruwez, thanks for the attention, but I found out that my component are not between my backup files, I must have deleted it when formatting the hd, so I have to make it all again. I'll wait until you post here how to make de .dcr and then accept you answer so you dont have to wait.

If I have some doubt I'll just open another question ;)
ASKER CERTIFIED SOLUTION
Avatar of Geert G
Geert G
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
off course after compile and install
thanks :)