Solved

"Resources"

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

760 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now