Javid
Javid

Reputation: 2935

How to set methods when our class is not created?

hi there Let me explain it for you. I working on a big project and it has lots of forms. I don't want it to use much RAM so I tried destroying the forms when they are closed using Action:=caFree and creating them using Application.CreateForm(TFrmX, FrmX) and it works fine. This application is multi-language so it loads form components caption and text from an external file. I had no other choice but loading the file to the memory and replacing the strings each time the form is created. As you know this makes the form creation a bit slower but i don't know how to change the class itself on runtime so that I replace the captions and texts on application load and simply create the forms and this way the app doesn't have to replace them as forms are created; Like this (just an example, it doesn't work!): TfrmX.Label1.Caption := 'sth'

What can I do?

Upvotes: 0

Views: 154

Answers (3)

Birger
Birger

Reputation: 4353

Since the Delphi Localization utilities are rather spartanian you might want to have a look at http://dxgettext.po.dk. We use it for several projects and it works great! Just add an extra plain text file to your installation for eacht translation that you want. This also makes it very easy for users to make their own translations.

Upvotes: 2

Tim Jarvis
Tim Jarvis

Reputation: 18815

Delphi supports internationalisation, I think that you would be better off having a look at the tools and techniques that are already available rather than try and come up with your own mechanism.

Have a look at Bruce McGee's answer to this question...Thats a good start.

Delphi and i18n

If you do want to continue to roll your own solution, then what I would be inclined to do is simply set your text properties on the instance after creation.

Upvotes: 1

David Heffernan
David Heffernan

Reputation: 612954

This cannot be done. Code like that you have given can only be run on instances and not on class references.

Upvotes: 0

Related Questions