在空白窗體上新增 popupmenu1, 並新增幾個測試用的選單項, 分別命名為: m1、m2、m3、mcn、mbig、men;
啟用 mcn 的 onclick 事件和窗體的 oncreate 事件.
unit unit1;效果圖:inte***ce
uses
windows, messages, sysutils, variants, classes, graphics, controls, forms,
dialogs, stdctrls, menus;
type
tform1 = class(tform)
popupmenu1: tpopupmenu;
m1: tmenuitem;
m2: tmenuitem;
m3: tmenuitem;
mcn: tmenuitem; //caption: 簡體中文
mbig: tmenuitem; //caption: 正體中文
men: tmenuitem; //caption: english
procedure formcreate(sender: tobject);
procedure mcnclick(sender: tobject);
end;
var form1: tform1;
languagelist: tstrings;
implementation
function cn2big(cnstr: string): string;
var len: integer;
begin
len := length(cnstr);
setlength(result, len);
lcmapstring(getuserdefaultlcid, lcmap_traditional_chinese, pchar(cnstr), len, pchar(result), len);
end;
procedure createlanguagelist;
begin
with languagelist do begin
clear;
add('default=預設');
add('fit width=適寬');
add('fit height=適高');
end;
end;
procedure changelanguagelist(langid: integer);
var i: integer;
begin
createlanguagelist;
with languagelist do case langid of
0: exit;
1: for i := 0 to count - 1 do values[names[i]] := cn2big(values[names[i]]);
2: for i := 0 to count - 1 do values[names[i]] := names[i];
end;
end;
procedure tform1.formcreate(sender: tobject);
begin
popupmenu := popupmenu1;
popupmenu1.autohotkeys := mamanual;
mbig.onclick := mcn.onclick;
men.onclick := mcn.onclick;
mcn.tag := 0;
mbig.tag := 1;
men.tag := 2;
mcn.click;
end;
procedure tform1.mcnclick(sender: tobject);
begin
changelanguagelist(tmenuitem(sender).tag);
m1.caption := languagelist.values['default'];
m2.caption := languagelist.values['fit width'];
m3.caption := languagelist.values['fit height'];
end;
initialization
languagelist := tstringlist.create;
finalization
languagelist.free;
end.
簡體轉換繁體
vb.net strconv 函式介紹 public shared function strconv byval str as string,byval conversion as microsoft.visualbasic.vbstrconv,optional byval localeid as ...
C 簡體繁體轉換
簡體轉繁體 轉換內容 繁體 public static string convertbig5 string convertext 繁體轉簡體 轉換內容 簡體 public static string convertgb2312 string convertext 將繁體亂碼轉繁體 已經是big5編碼...
Python 繁體轉簡體
注意 這是在乙個檔案 import 了另乙個檔案 如果出現了異常,可以點進出錯的地方修改 import 繁體 簡體 simplified sentence 憂鬱的台灣烏龜 sentence converter zh hans convert sentence print sentence 簡體 繁體...