Solved

"Resources"

Posted on 1997-04-01
1
243 Views
Last Modified: 2010-05-18
I used to program under Borland C++ 4 & 5. We have created
then a Special DLL which contained all dialogs/bitmaps/icons/strings. Naturally, we could easily
change the language by simply replacing the DLL (even on the fly). My question is: how do i make such a an "arrangement" using Delphi, and how do i keep my resources
centered in one DLL and NOWHERE ELSE....
0
Comment
Question by:magid
1 Comment
 
LVL 3

Accepted Solution

by:
sperling earned 50 total points
ID: 1335091
Can't be done automatically.

I suggest you use the 'Tag' property of all components in your delphi program, and give this tag a value corresponding to the resource you've associated it with. Then, write a generic routine that looks through the Components array of a form, and replaces the appropriate values for each component with the resource having the 'Tag' ID.

I've used a similar setup for multilanguage development.
I would've got e.g. a Label with Tag 38, and the string resource 38 would look something like : "The caption|The short hint|The long hint|The help context"

Then, I used a loop something like this

procedure ReadResources (AForm : TForm);
.
.
.
for ndx := 0 to AForm.ComponentCount-1 do begin
  if AForm.Components[ndx].Tag<>0 then begin
    if AForm.Components[ndx] is TLabel then UpdateLabel(TLabel(AForm.Components[ndx]))
    else if ...


And, procedure UpdateLabel:

procedure UpdateLabel (ALabel : TLabel);
.
.
.
  ALabel.Caption := Copy (s, 1, Pos('|', s)-1);
  Delete(s, 1, Pos('|', s));
  ALabel.Hint := Copy (s, 1, Pos('|', s));
  Delete(s, 1, Pos('|', s));
  ALabel.Hint := ALabel.Hint + Copy (s, 1, Pos('|', s)-1);
  Delete(s, 1, Pos('|', s));
  ALabel.HelpContext := StrToIntDef(s, 0);
 

and so on.

Not sure whether this is what you asked, if not, leave me a comment...


Regards,

Erik.
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to convert wav to mp3 in delphi 9 201
Intraweb download file link ? 1 134
How to define IfThen functions in one common unit? 4 54
MS Access from Delphi 31 32
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question