computer 版 (精华区)
发信人: aiwa (冰雪), 信区: POPSoft
标 题: DELPHI:菜单的汉化
发信站: 听涛站 (Mon Nov 22 16:31:42 1999), 转信
作者: 王润德
----现在我们经常看到一些软件汉化包,例'晴窗伴侣'是PHOTOSHOP
的汉化包,其实我们只要对WINDOWS的编程熟悉,也可以自己编写某
些软件的汉化包。这样不管软件大小,只要你喜欢就可以给做一个汉
化包。下面的程序是一些主要的步骤。其实你还可以用别的方法来实
现,亲自试试吧。
----在运行程序之前首先生成一个中英文菜单对照表文件,产生时可
以参照该程序自己编制一个获得系统的原菜单内容的程序,然后在之
后输入菜单的汉字内容。其格式如下:
SAVE AS 保存到....
. .
..
EXIT 退出系统
// 程序开始
unit wrdxt;
interface
uses
Windows, Messages, SysUtils, Classes,
Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
ListBox1: TListBox;
ListBox2: TListBox;
procedure Button1Click(Sender: TObject);
procedure FormActivate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
childmenu,mainmenu,c2menu:hmenu;
wndhandle:hwnd;
mystr:pchar;
mainnum,childNUM,c2num:integer;
MYCHAR:STRING;
mm3,mm6:string[19];
mm4,mm5:string;
implementation
{$R *.DFM}
//我用表单的CLICK事件激活,其实用ACTIVE事件会更好
procedure TForm1.Button1Click(Sender: TObject);
var
start1,start2,start3,start4,start5:integer;
begin
//通过标题获得窗口句柄
wndhandle:=findwindow(nil,mystr);
//通过标题获得菜单句柄
mainmenu:=getmenu(wndhandle);
//取得顶行菜单数
mainnum:=getmenuitemcount(mainmenu);
//汉化菜单
for start1:=0 to mainnum do
begin
mm5:=``;
//取得菜单项的标题
getmenustring(mainmenu,start1,PCHAR
(myChAR),20,MF_BYPOSITION);
mm6:=string(pchar(mychar));
for start3:=0 to listbox1.items.count-1 do
begin
mm4:=listbox1.Items[start3];
mm3:= mm4;
if (string(mm6)=trim(mm3)) then
begin
for start4:=21 to length(mm4) do
begin
mm5:=mm5+mm4[start4];
end;
end;
end;
if mm5<>`` then
modifymenu(mainmenu,start1,MF_BYPOSITION,
getmenuitemid(mainmenu,start1),pchar(mm5));
childmenu:=getsubmenu(MAINMENU,start1);
childnum:=getmenuitemcount(childmenu);
//汉化下拉菜单
for start2:=0 to childnum do
begin
mm5:=``;
getmenustring(childmenu,start2,PCHAR
(mychar),20,MF_BYPOSITION);
mm6:=string(pchar(mychar));
for start3:=0 to listbox1.items.count-1 do
begin
mm4:=listbox1.Items[start3];
mm3:= mm4;
if (string(mm6)=trim(mm3)) then
begin
for start4:=21 to length(mm4) do
begin
mm5:=mm5+mm4[start4];
end;
end;
end;
if mm5<>`` then
modifymenu(childmenu,start2,MF_BYPOSITION,
getmenuitemid(childmenu,start2),pchar(mm5));
c2menu:=getsubmenu(childMENU,start2);
c2num:=getmenuitemcount(c2menu);
for start5:=0 to c2num do
begin
mm5:=``;
getmenustring(c2menu,start5,PCHAR
(mychar),20,MF_BYPOSITION);
mm6:=string(pchar(mychar));
for start3:=0 to listbox1.items.count-1 do
begin
mm4:=listbox1.Items[start3];
mm3:= mm4;
if (string(mm6)=trim(mm3)) then
begin
for start4:=21 to length(mm4) do
begin
mm5:=mm5+mm4[start4];
end;
end;
end;
if mm5<>`` then
modifymenu(c2menu,start5,MF_BYPOSITION,
getmenuitemid(c2menu,start5),pchar(mm5));
END;
END;
end;
end;
procedure TForm1.FormActivate(Sender: TObject);
begin
//要汉化的系统的窗口标题
//mystr:=`adobe photoshop`;
mystr:=`frontpage explorer`;
mychar:=` `;
//装入已编辑好的中英文菜单对照文件
listbox1.items.loadfromfile(`myfile2.txt`);
end;
end.
-----------------------------------------------------------
寒彻肌骨,洁如凝脂。
冰雪
※ 来源:.听涛站 bbs.foundernet.edu.[FROM: bbs.foundernet.edu]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:1.014毫秒