Solved

"Resources"

Posted on 1997-04-01
1
256 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

726 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