New Component Suggestion

Please post bug reports, feature requests, or any question regarding the DELPHI AREA products here.

New Component Suggestion

Postby w2m » March 29th, 2009, 2:53 pm

Resource file (*.res) reader writer

The following units are the only code I can find to read and write res files in Delphi 2009.
http://www.btinternet.com/~wilsoncpw/d12runtimepackages.zip

Unfortunately there is no documentation for the resource file units.

I have a demo that I can provide that uses these units to fill a TListview with cursor groups and cursors loaded from a res file, but I can not figure out how to get the index of a cursor in a cursor group when I try to add the contents of the res file to a TTreeview.

If you have an index to a cursor group and the number of cursors in the group how can you get the index of the cursors contained in the group?

I thought it would be a good idea for such a component because:
1. there is little information is available for Delphi and res files
2. no commercial components are available to read and write res files
3. Delphi does not ship with a resource editor.

To keep things simple to start the component could be developed to read and write graphics files but then expanded to include other resource types later if there was interest.
Initial development could include support for Cursors, Icons and bitmaps.

I am willing to help develop and test the component.

Regards,

Bill
w2m
w2m
Senior Member
Senior Member
 
Posts: 76
Joined: March 8th, 2003, 7:11 pm
Location: New York, USA

Re: New Component Suggestion

Postby Kambiz » March 30th, 2009, 1:25 pm

I have already written a unit containing a set of classes for reading/writing .res files. You can find the unit (Win32Res) and its usage in the Actor Editor of the Office Assistant package.

However, this unit does not contain methods for interpreting the resources. You have to use Windows API to manage a resource after loading.
Attachments
Win32Res.zip
A set of classes for reading/writing .res files.
(4.37 KiB) Downloaded 70 times
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2408
Joined: March 7th, 2003, 7:10 pm

Re: New Component Suggestion

Postby w2m » March 30th, 2009, 2:13 pm

Kambiz,

Thank you.

But do you know how to get the index of a cursor in a cursor group when adding the contents of the res file to a TTreeview.

Cursor Group 1
Cursor 1 32x 32 (2 color) - how to set and get the index of cursors within a cursor group
Cursor 2 32 x 32 (2 color) - how to set and get the index of cursors within a cursor group
Cursor Group 2
Cursor 1 32 x 32 (256 color) - how to set and get the index of cursors within a cursor group
Cursor 2 32 x 32 (256 color) - how to set and get the index of cursors within a cursor group

When I click on any Cursor Group in the tree the correct cursor is shown, but when I click on the cursor itself the wrong cursor is shown so the index in the tree is not correct.
When loading cursors how can you figure out which cursors are the child of a cursor group?
How to set the index of the cursor when adding a cursor node to a cursor group node when you fill the treeview?

When I load a res file contents into a TListview the order is:
Cursor 1
Cursor 2
Cursor 3
Cursor 4
Cursor 5
Cursor Group 1
Cursor Group 2
Cursor Group 3
There is a method to find out how many cursors there are for a Cursor Group, but no way to find out which of the cursors are in what group.
Which cursors are in Group1, and which cursors are in Group 2 and Group3?

In this example Cursor Group 1 has 2 cursors, Cursor Group 2 has 2 cursors and Cursor Group 3 has 1 cursor.

Do you assume that the answer is:

Cursor Group 1
Cursor 1
Cursor 2
Cursor Group 2
Cursor 3
Cursor 4
Cursor Group 3
Cursor 5

Sorry to bother you with this but I just can not seem to fill the Treeview correctly with Cursor Groups and Cursors with the proper resource index so that when I click on a treeview node it loads the appropriate cursor group or cursor baised on its resource index.

Thanks,

Bill
w2m
w2m
Senior Member
Senior Member
 
Posts: 76
Joined: March 8th, 2003, 7:11 pm
Location: New York, USA

Re: New Component Suggestion

Postby Kambiz » March 30th, 2009, 9:53 pm

Because you asked only about cursors, I guess you know how to manage icons in a group. Icons and cursors have common APIs.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2408
Joined: March 7th, 2003, 7:10 pm

Re: New Component Suggestion

Postby w2m » March 30th, 2009, 10:50 pm

Kambiz:

I did not ask about icons because I wanted to keep my question simple as possible. I was hoping that if I understood the API for cursors, understanding Icons should not be too hard.
Are you looking to answer my question?

I tried various ways to load the cursors into a cursor group all day today.... with Colin Wilson's Resource Editor Runtime units but still no success.

I have attached the demo I am working on. All of the resource units are from Colin Wilson's Resource Editor Runtime units for Delphi 2009.
There are a few small cursor res files included. The demo can read the files ok but when you save as the res file becomes corrupted. When you click on a cursor group in the treeview the correct cursor is loaded. When you click on a cursor node the incorrect cursor is loaded.

Thanks,

Bill
Attachments
ResourceEditor.zip
Demo source code
(686 KiB) Downloaded 83 times
w2m
w2m
Senior Member
Senior Member
 
Posts: 76
Joined: March 8th, 2003, 7:11 pm
Location: New York, USA

Re: New Component Suggestion

Postby Kambiz » March 31st, 2009, 1:00 pm

PalUtils and cmpColorSelector units are missing!

Besides that, there are some components to be installed but there is no package. Looking at the code and finding components and adding Register function for each one takes more or less one hour. Could you please include the package and registration unit too?
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2408
Joined: March 7th, 2003, 7:10 pm

Re: New Component Suggestion

Postby w2m » March 31st, 2009, 2:01 pm

Kambiz,

Sorry for the missing files. The 3 components used in the demo are from a 2 other much larger packages so I created a new one that just has the 3 components used in the demo. It is called ResEditorD12Package.dpk. I installed it here and recompiled the demo without a problem. If there is anything else you need let me know.

Regards,

Bill
Attachments
ResourceEditorWithComponents.zip
Resource Editor with Source and component files and Package
(720.15 KiB) Downloaded 87 times
w2m
w2m
Senior Member
Senior Member
 
Posts: 76
Joined: March 8th, 2003, 7:11 pm
Location: New York, USA

Re: New Component Suggestion

Postby Kambiz » March 31st, 2009, 3:38 pm

Sorry, still one file is missed: mxs.inc
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2408
Joined: March 7th, 2003, 7:10 pm

Re: New Component Suggestion

Postby w2m » March 31st, 2009, 4:10 pm

Sorry. Here is the file.

Bill
Attachments
mxs.zip
Mxs.inc
(367 Bytes) Downloaded 72 times
w2m
w2m
Senior Member
Senior Member
 
Posts: 76
Joined: March 8th, 2003, 7:11 pm
Location: New York, USA

Re: New Component Suggestion

Postby Kambiz » March 31st, 2009, 4:25 pm

The missing file was not important. I could compile the project.

The code is very complex, and there are plenty of AV exceptions that makes tracing difficult. However, seems if you do not sort resources, cursors place in the right group.

The AV exceptions are because of pointers no longer available. You must release all buffers (Node.Data) allocated for resources before loading new resources, and clear all references to them.

In my point of view, it is more convenient to assign ResourceDetails to Node.Data instead of allocating NodeData record.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2408
Joined: March 7th, 2003, 7:10 pm

Re: New Component Suggestion

Postby w2m » March 31st, 2009, 4:51 pm

Kambiz,

Yes the original source is very complex. After studing his source for about a month the XN Resource editor loads all different kinds of resources. Each resource has a form assoiated with the resource type. The code has about 20 forms just to display and edit resources. This is why I thought I would try to get it to work with just graphics at first.

The XN Resource editor also uses an enhanced TExVirtualTreeview with a Node Type property. think the source is in your res editor folder. The XN resource editor displays cursors by using the TExVirtualTreeview node type as well as form objects in TExVirtualTreeview events to load the cursor for display. For this reason I can not figure out how the code gets the number of cursors for a cursor group and then adds a node to the tree for each cursor in the group. The Load Tree button click try to use a conviluted way to load cursors for each node, but right now it loads all cursors for each group cursor node.

As far as exceptions I do not see any exceptions here at all when I only open resource file with cursors in them. There are about 3 different cursor only res files in the source folder.

What I see here with cursor only res files is that when I load the resource types into the TListview (located on the page control) everything works great. When you select a cursor the correct cursor is shown. When you select a cursor group the correct cursor is shown. The only problem I see with the demo here is when filling the treeview with cursor groups and cursors for each cursor group node. If you select a cursor node in the tree the correct cursor is shown, but if you select a cursor the incorrect corsor is shown.

In fact right now I think each node of the tree is filled with each of cursors in the res file and not just the cursors for the node.

Can you see anyway to determine which cursors are supposed to go with each group.

Finally, when I edit a cursor and then save it as... the res file is nearly empty and corrupt.

This is why I suggested for you to build a res file component to read and write graphics res files.

I am willingto assist you if you think you may be able to do it.

Regards,
w2m
w2m
Senior Member
Senior Member
 
Posts: 76
Joined: March 8th, 2003, 7:11 pm
Location: New York, USA

Re: New Component Suggestion

Postby Kambiz » April 4th, 2009, 12:32 pm

Making a set of components for easy editing of resources is a very time consuming task. I don't have such amount of free time otherwise I start working on SimpleGraph.

Personally, when I need a res file, I write its rc file manually and compile it by command line resource compiler.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2408
Joined: March 7th, 2003, 7:10 pm


Return to DELPHI AREA Products

Who is online

Users browsing this forum: No registered users and 2 guests

cron