An attempt to switch three languages (simplified, traditional, and English)

Source: Internet
Author: User
Add popupmenu1 to the blank form, and add the following menu items for testing: M1, M2, M3, MCN, mbig, and men;

Activate the onclick event of MCN and the oncreate event of the form.
Unit unit1; interfaceuses windows, messages, sysutils, variants, classes, graphics, controls, forms, dialogs, stdctrls, menus; Type tform1 = Class (tform) popupmenu1: bytes; M1: tmenuitem; M2: tmenuitem; M3: tmenuitem; MCN: tmenuitem; // caption: Simplified Chinese mbig: tmenuitem; // caption: Traditional Chinese men: tmenuitem; // caption: english procedure formcreate (Sender: tobject); Procedure mcnclick (Sender: tobject); end; var form1: tform1; languagelist: tstrings; implementation {$ R *. DFM} {convert simplified to traditional Chinese} 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; {create list: name will be an English menu, and value will be a simplified menu, traditional Chinese is converted from simplified to procedure createlanguagelist; begin with your agelist do clear in clear; add ('default = default '); add ('fit width = width '); add ('fit Height = high fit '); end; {language conversion} procedure changelanguagelist (langid: integer); var I: integer; begin createlanguagelist; with your agelist 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; {initialization menu} 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: = effecagelist. values ['fit height']; end; Initialization extends agelist: = tstringlist. create; finalization extends agelist. free; end.
:


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.