PDA

View Full Version : DLL Component Problem



tronied
01-05-2003, 09:56 AM
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 :

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;

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 :

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;

Clootie
01-05-2003, 03:50 PM
1) include ShareMem unit @ uses clause in both dll and application
2) build with packages: project/options/packages/Runtime packages/Build with...