Recent

Author Topic: Embed Resources  (Read 4655 times)

sky_khan

  • Guest
Embed Resources
« on: June 07, 2017, 06:07:57 pm »
Greetings,

I've wrote my first Lazarus component
It allows you to embed any resource file as form resource. It's content is modifiable on runtime. If you save modified content, they will be stored in application data folder as user-specific or global according to individual item's scope property. So it's items can also be used for user modifiable configuration.

Let me know if you encounter a bug.
Feel free to include it in lazarus-ccr or even lazarus itself.

Note: There are some unfinished work yet, as it does not display all kind of resources but just text and image so far but I wanted that it is tested.
« Last Edit: June 07, 2017, 09:41:42 pm by SkyKhan »

Handoko

  • Hero Member
  • *****
  • Posts: 5545
  • My goal: build my own game engine using Lazarus
Re: Embed Resources
« Reply #1 on: June 07, 2017, 08:22:17 pm »
Thank you for sharing your work.

I opened and tried to compile khnembedrsc.lpk and I got an error. See the image. What is the different between khnembedrsc and khnembedsrc_dsn?

I am using Ubuntu Mate 16.10 and Lazarus 1.6.4 FPC 3.0.2 x86_64-linux-gtk 2.

jc99

  • Hero Member
  • *****
  • Posts: 553
    • My private Site
Re: Embed Resources
« Reply #2 on: June 07, 2017, 08:44:17 pm »
Thank you for sharing your work.

I opened and tried to compile khnembedrsc.lpk and I got an error. See the image. What is the different between khnembedrsc and khnembedsrc_dsn?

I am using Ubuntu Mate 16.10 and Lazarus 1.6.4 FPC 3.0.2 x86_64-linux-gtk 2.
That's a Trick I also use to store number, and indices in the (T)Object field.
but to circumvent this error I do it like this:
Code: [Select]
sl.AddObject(aText,TObject(Ptrint(aInteger)));That way the (32-bit)integer is converted to Machine-Size-Integer(64-bit) in your case, and then stored as a pointer.

the given example should look like:
Code: [Select]
Procedure AddExt(const ext:string: rtype: TEmbedResourceType);
begin
  RscExtMap.AddObject(ext,TObject(PtrInt(Ord(rtype))));
end;


On the reverse way you also use PtrInt as an intermediate:
Code: [Select]
aInteger := PtrInt(sl.Objects[aIndex]);
« Last Edit: June 07, 2017, 08:50:56 pm by jc99 »
OS: Win XP x64, Win 7, Win 7 x64, Win 10, Win 10 x64, Suse Linux 13.2
Laz: 1.4 - 1.8.4, 2.0
https://github.com/joecare99/public
'~|    /''
,_|oe \_,are
If you want to do something for the environment: Twitter: #reduceCO2 or
https://www.betterplace.me/klimawandel-stoppen-co-ueber-preis-reduzieren

sky_khan

  • Guest
Re: Embed Resources
« Reply #3 on: June 07, 2017, 08:48:59 pm »
Yeah, It is an 64 bit incompatibility that I didnt notice because I use 32 bit compiler and didnt even try compile this for 64 bit. Please change it as TObject(PtrInt(Ord(rtype)))

Handoko

  • Hero Member
  • *****
  • Posts: 5545
  • My goal: build my own game engine using Lazarus
Re: Embed Resources
« Reply #4 on: June 07, 2017, 09:01:42 pm »
@jc99

Thank you for the explanation.

@SkyKhan

It's working now. So far no problem found.
« Last Edit: June 07, 2017, 09:03:46 pm by Handoko »

sky_khan

  • Guest
Re: Embed Resources
« Reply #5 on: June 07, 2017, 09:27:32 pm »
Nice :) Thanks for testing.

Edit: Attachment in first post is updated to include that bugfix.
« Last Edit: June 07, 2017, 09:50:19 pm by SkyKhan »

sky_khan

  • Guest
Re: Embed Resources
« Reply #6 on: June 07, 2017, 10:55:48 pm »
What is the different between khnembedrsc and khnembedsrc_dsn?
Sorry, I have not paid attention this question.
As you know, there is 2 packages. khnembedsrc.lpk is runtime package which includes TEmbedResources component.
khnembedsrc_dsn.lpk is designtime package and it registers my (extended) collection property editor which gives you the chance of adding resources/contents to TEmbedResources at designtime in Lazarus.
« Last Edit: June 08, 2017, 02:25:29 am by SkyKhan »

 

TinyPortal © 2005-2018