質問

I made a custom component that needs a rather large (say 1MB) UTF8 text to function. For development purposes, I just loaded this from a file. Now I want to get rid of that file. What is the easiest way to store its contents in the component, such that the user of the component needn't bother with this?

First I tried making it string constant, but soon Delphi started to complain in many different ways (too long or too many, out of memory, etc.). When I switched to embedding it as a resource, I found that the resource will not be automatically compiled into the actual application as well, so it's not transparent to the component user...

Update

I got it working if I create a resource file myself, which I manually add to the unit. Then, I still need a pre-build event for it to be actual. The question remains why it doesn't work if I add it to the package, via the Delphi menu, rather than to the unit. And why {$R myresource.res myresource.rc} doesn't compile it automatically as it should...?

Update 2

Apparently the resource script needs to be added to the project for automatic compilation to work.

役に立ちましたか?

解決

Adding the {$R myresource.res} line in the unit containing the component should work.

You can add the myresource.rc file to the component's package to make Delphi generate myresource.res automatically.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top