在Delphi中如何使用RC文件中的字符串表
2006-02-04 13:37:34 来源:WEB开发网核心提示:在Delphi中如何使用RC文件中的字符串表 原作作者:wangzhidong(Steven Bob)时间:2002年3月25日星期一 首先用Notepad或Resource workshop 4.5建立RC文件,结构如下 /rcdemo.rcPRoduced by Borland Resource Workshop*
在Delphi中如何使用RC文件中的字符串表
原作作者:wangzhidong(Steven Bob) 时间:2002年3月25日星期一 首先用Notepad或Resource workshop 4.5建立RC文件。 结构如下/**************************************************************************** rcdemo.rc PRoduced by Borland Resource Workshop *****************************************************************************/ #include "urcdemo.pas" STRINGTABLE { IDS_HELLO, "I am glad to see you." IDS_RC, "This programming is created by %s." } |
(**************************************************************************** urcdemo.pas produced by Borland Resource Workshop *****************************************************************************) unit urcdemo; interface const IDS_HELLO = 2; IDS_RC = 1; implementation end. |
unit ufmRCDemo; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) GroupBox1: TGroupBox; Button1: TButton; Button2: TButton; GroupBox2: TGroupBox; Button3: TButton; Button4: TButton; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Button3Click(Sender: TObject); procedure Button4Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation uses urcdemo; {$R rcdemo.rc} {$R *.dfm} {利用windows API} procedure TForm1.Button1Click(Sender: TObject); var arystr: array [0..255] of char; begin windows.LoadString(hInstance, IDS_RC, arystr, sizeof(arystr)); ShowMessage(arystr); end; procedure TForm1.Button2Click(Sender: TObject); var arystr: array [0..255] of char; begin windows.LoadString(hInstance, IDS_Hello, arystr, sizeof(arystr)); ShowMessage(arystr); end; {利用Delphi原生函数} procedure TForm1.Button3Click(Sender: TObject); begin ShowMessage(LoadStr(IDS_Hello)); end; procedure TForm1.Button4Click(Sender: TObject); begin ShowMessage(LoadStr(IDS_RC)); end; end. |
[]
赞助商链接