Results 1 to 2 of 2

Thread: DLL Component Problem

  1. #1

    DLL Component Problem

    Hi, I am currently making myself a DLL whereby I have a procedure which adds images to an ImageList on a form. To do this I am creating a TFileListBox component using the following :

    [pascal]procedure LoadImages (AppDirectory : String; AppTiles : TImageList; Form1 : TForm);
    var
    ImageCount : Integer;
    AOwner : TComponent;
    ImagePreLoad : TFileListBox;
    begin
    ImagePreLoad := TFileListBox.Create(AOwner);
    ImagePreLoad.Parent := Form1;
    ImagePreLoad.Directory := AppDirectory+'Images\';
    ImagePreLoad.Mask := '.bmp';

    for ImageCount := 0 to ImagePreLoad.Items.Count -1 do
    begin
    AppTiles.Items.Add;
    AppTiles.Items[ImageCount].Picture.LoadFromFile(AppDirectory+
    'Images\'+ImagePreLoad.Items[ImageCount]);
    end;

    ImagePreLoad.Free;
    end;

    exports
    LoadImages;[/pascal]

    This method seems to work fine while creating the component from the main source file, but when I try to create it from the DLL it brings up an error saying "TFont cannot be assigned to a TFont". I have tried assigning a font to the component but I have no luck with that. Any Ideas?

    For reference the call is made using the following :

    [pascal]procedure LoadImages (AppDirectory : String;AppTiles : TImageList; Form1 : TForm); external 'MyDLL.DLL';

    procedure TForm1.RandomProcedure (Sender : TObject);
    var
    AppDirectory : String;
    begin
    AppDirectory := ExtractFilePath(Application.ExeName);
    LoadImages (AppDirectory, AppTiles, Form1);
    end;[/pascal]

  2. #2

    DLL Component Problem

    1) include ShareMem unit @ uses clause in both dll and application
    2) build with packages: project/options/packages/Runtime packages/Build with...
    There are only 10 types of people in this world; those who understand binary and those who don't.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •