I have a mistake and I don’t know why I got it ...
So: I have a new component based on sAlphaButton. This has an ImageList property, and my component extends this button with its own Hungarian captions / images.
I used LoadRes to get predefined images.
Watch this:
procedure TScrollPNGButton.LoadAsImageListFromRes(ResNames : TStrings; IL : TsAlphaImageList);
var
s : string;
i : integer;
begin
IL.CLear;
for i := 0 to ResNames.Count - 1 do begin
s := ResNames[i];
AddImageFromRes(hInstance, IL, s, ifPNG);
end;
end;
procedure TScrollPNGButton.LoadResToImageList;
var
sl : TStringList;
begin
sl := TStringList.Create;
try
sl.Text :=
Trim(
'scrollpngbutton_ok'
'scrollpngbutton_cancel'
'scrollpngbutton_close'
'scrollpngbutton_yes'
'scrollpngbutton_no'
'scrollpngbutton_refresh'
'scrollpngbutton_print'
'scrollpngbutton_email'
'scrollpngbutton_add'
'scrollpngbutton_delete'
'scrollpngbutton_edit'
''
);
LoadAsImageListFromRes(sl, FImgs);
finally
sl.Free;
end;
end;
constructor TScrollPNGButton.Create(aOwner : TComponent);
begin
inherited Create(aOwner);
FImgs := TsAlphaImageList.Create(nil);
inherited Images := FImgs;
LoadResToImageList;
end;
It works well when I use it from code. But when I registered it and I try to enter a form, I got an error:
Error Resource scrollpngbutton_ok not found. Ok
I don’t understand this, because I put {$ R * .res}, and from the code it works. Why is the resource not found? Failed to create creation or what?
, Loaded; , Loaded .