Solved

"Resources"

Posted on 1997-04-01
1
251 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

749 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