Solved

"Resources"

Posted on 1997-04-01
1
248 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

837 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