当我们的类没有创建的时候如何设置方法呢?

发布于 2024-10-08 09:41:48 字数 392 浏览 0 评论 0原文

你好呀 让我为你解释一下。我正在做一个大项目,它有很多形式。我不希望它使用太多 RAM,因此我尝试在使用 Action:=caFree 关闭表单时销毁表单,并使用 Application.CreateForm(TFrmX, FrmX) 创建它们> 并且效果很好。 该应用程序是多语言的,因此它从外部文件加载表单组件标题和文​​本。我别无选择,只能将文件加载到内存中并在每次创建表单时替换字符串。如您所知,这使得表单创建速度有点慢,但我不知道如何在运行时更改类本身,以便我在应用程序加载时替换标题和文本并简单地创建表单,这样应用程序就没有在创建表单时替换它们;像这样(只是一个例子,它不起作用!): TfrmX.Label1.Caption := 'sth'

我能做什么?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

人心善变 2024-10-15 09:41:48

由于 Delphi 本地化实用程序相当简单,您可能需要查看 http://dxgettext.po.dk 。我们将它用于多个项目,效果非常好!只需将额外的纯文本文件添加到您的安装中即可获得您想要的每个翻译。这也使得用户可以非常轻松地进行自己的翻译。

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.

与他有关 2024-10-15 09:41:48

Delphi 支持国际化,我认为您最好看看现有的工具和技术,而不是尝试提出自己的机制。

看看布鲁斯·麦吉对这个问题的回答……这是一个好的开始。

Delphi 和 i18n

如果您确实想继续推出自己的解决方案,那么我会倾向于只需在创建后在实例上设置文本属性即可。

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.

巷子口的你 2024-10-15 09:41:48

这是不可能的。您给出的代码只能在实例上运行,而不能在类引用上运行。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文