Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

query on resource files containg other files

Status
Not open for further replies.

CADTenchy

Technical User
Dec 12, 2007
237
GB
I've been reading about, and thinking of using, resource files to include with my compiled EXE, things like my support bitmaps etc.

However, I wanted to check something. If I do so, will certain files be created by the exe at runtime, in it's folder?

(source of this query:

quote:

One minor *problem* is that the application creates a mp3 song on a user machine. You could add a code that deletes that file before the application is terminated.

)

I don't mind that, except there's no point then, so it will save me some effort.
But if that only applies to certain file types it would be worth it for me.



Steve (Delphi 2007 & XP)
 
The specific example wrote the MP3 out of the resource to file. If you are accessing the resources from within the loaded library (your EXE, whatever), then there is no need to copy anything out of the resource data to an external file.

----------
Measurement is not management.
 

Thanks Glenn.
I really think I need glasses, I didn't see the extract line of code, or it's clear comment...

I'll press on and try it out now.



Steve (Delphi 2007 & XP)
 
Not that I have anything against resource files, I try to avoid the headache of maintaining them. I use the following to manage images.
Code:
unit ImageUnit;
{$D-}

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ImgList;

type
  TBinaries = class(TForm)
    ImageListToolBar: TImageList;
    ImageListTree: TImageList;
    ImageListTabs: TImageList;
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Binaries: TBinaries;

implementation

{$R *.DFM}

end.
That's all there is to it. to use it, just add ImageUnit to your project. Your app will never see it as a form. Then on any form you have a ToolBar for example, set TollBar1 property "Images" to Binaries.ImageListToolBar
Then set the ToolButton.ImageIndex to the corresponding index within ImageListToolBar. The same method works for the created ImageListTree (for TTreeView) and ImageListTabs (for TTabbedNotebook).

Unit ImageUnit need NOT even be in the uses clause, yet only one instance of each image gets embedded into your application. I find the "ImageList Editor" a more convenient for managing images than Resource editors.

Now is this method any less efficient? I don't know. If anyone knows that it is, I'd appreciate knowing about it.


Roo
Delphi Rules!
 

Just to be sure, if I interpret your suggestion correctly, the unit ImageUnit.pas has a form associated with it named Binaries (in your example), and on that form are the 3 Imagelists referred to in ImageUnit.pas ?


Steve (Delphi 2007 & XP)
 
Yes. And as noted, form Binaries is never shown in the application. It is just used as a container to place the imagelists into. It must however, be included in the auto-create (and hence, uses caluse) of the DPR.

Roo
Delphi Rules!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top