义爨 : 狷尻蝽-铕桢眚桊钼囗眍 镳铄牝桊钼囗桢 磬 Borland C++

1. 吾 疋邃屙 镳钽疣祆圊 磬 Borland C++

2. 羊痼牝箴 泐腩忭钽 羿殡 镳铄牝

3. 羊痼牝箴 羿殡钼 祛潴脲 纛痨

4. 吾豚耱 忤滂祛耱 漕耱箫 钺牝囔 祛潴

5. 雨噻囹咫 磬 钺牝

 

1. 吾 疋邃屙 镳钽疣祆圊 磬 Borland C++

朽耨祛蝠桁 忸镳铖 钺 铕汔龛玎鲨 镳桦铈屙 C++ 漕耱箫 钺牝囔, 桴 疋铋耱忄 戾蝾溧.

橡桦铈屙桢 磬 C++ 耦耱铊 桤 钺怆屙栝 (镥疱戾眄, 觐眈蜞眚, 蜩镱, 觌囫耦, 趔黻鲨) 铒桉囗栝 趔黻鲨. 佯邃 趔黻鲨 怦邈溧 桁邋蝰 汶噔磬 - WinMain 潆 镳桦铈屙栝 Windows. 褥屙眍  趔黻鲨 恹镱腠弪 镳 玎矬耜 镳桦铈屙, 恹镱腠弪 蝾朦觐 礤觐蝾瘥 镱溷铗钼栩咫 铒屦圉梃, 礤钺躅滂禧 潆 磬鬣豚 疣犷螓. 溧脲 镳 挝 镱漉钿 疣犷蜞 镳桦铈屙 铒疱溴弪 镳铊聃钿扈 耦猁蜩扈 疱嚓鲨彘 磬 龛 钺牝钼.

枢 镳噔桦, 镳钽疣祆 耱痤蝰 镱 祛潴朦眍祗 镳桧鲨矬 耦耱 桤 祉铈羼蜮 祛潴脲. 族蜿铄 耦犭屙桢 镳桧鲨镱 祛潴朦眍耱 耦麇蜞龛 镳桧鲨镱 耦牮 桧纛痨圉梃 镱玮铍弪 忭篁痂 膻犷泐 祛潴 镳钼钿栩 礤钺躅滂禧 祛滂翳赅鲨, 礤 玎蝠嚆桠 镳 铎 铖蜞朦睇 祛潴脲 泐腩忭簋 趔黻鲨.

埋 钺牝 觐祜铐屙蝾 疣珈妁帼蝰 钺牝圊 - 纛痨圊. 碾 赅驿铋 纛痨 C++Builder 耦玟噱 铗溴朦睇 祛潴朦. 褥屙眍 祛潴 铖簌羼蜮弪 镳钽疣祆桊钼囗桢 玎溧麒. 钺疣犷蝼桕圊 耦猁蜩 钺牝钼 疣珈妁帼蝰 怦 嚯泐痂蜢. 铖眍忭铎 铐 疋钿蝰 钺疣犷蜿 桧纛痨圉梃, 耦溴疰帙彘 疋铋耱忄 钿龛 钺牝钼, 玎溧龛 镱 疱珞朦蜞蜞 钺疣犷蜿 疋铋耱 漯筱桴 钺牝钼. 橡 铎 镱耱眄 镳铊聃钿栩 钺疣屙桢 戾蝾溧 疣珉梓睇 钺牝钼.

杨汶囫眍 镳桧鲨镟 耦牮 桧纛痨圉梃 祛潴朦 耦耱铊 桤 玎泐腩忸黜钽 羿殡, 觐蝾瘥 耦溴疰栩 钺怆屙 觌囫耦, 趔黻鲨, 镥疱戾眄 .., 羿殡 疱嚯桤圉梃, 觐蝾痤 耦溴疰栩 铒桉囗桢 趔黻鲨. 羊囗溧痱眍 疣聒桊屙桢 玎泐腩忸黜 羿殡钼 - .h. 羊囗溧痱眍 疣聒桊屙桢 羿殡钼 疱嚯桤圉梃 - .耩.

项耠 蝾泐, 赅 镳桦铈屙桢 磬镨襦眍, 磬 邋 铖眍忮 耦玟噱蝰 恹镱腠屐 羿殡 (祛潴朦). 蒡铗 镳铞羼 铖簌羼蜮弪 礤耜铍 囡钼.

秧圜嚯 疣犷蜞弪 镳屣痤鲥耨铕, 觐蝾瘥 镳孱狃噻箦 桉躅漤 蝈犟. 橡屣痤鲥耨铕 铖簌羼蜮弪 镳孱狃噻钼囗 耦铗忮蝰蜮梃 耦 耧弼栲朦睇扈 滂疱牝桠囔 镳屣痤鲥耨铕, 觐蝾瘥 疣珈妁帼蝰 桉躅漤铎 蝈犟蝈. 橡屣痤鲥耨铕 祛驽 耦铗忮蝰蜮梃 桁 滂疱牝桠囔 怅膻鬣螯 蝈犟螓 钿龛 羿殡钼 蝈犟螓 漯筱桴, 疣玮屦螓忄螯 爨牮铖 - 耦牮帙屙睇 钺铉磬麇龛 疣珉梓睇 恹疣驽龛 恹镱腠螯 祉铈羼蜮 漯筱桴 镳孱狃噻钼囗栝.

项耠 镳屣痤鲥耨铕 疣犷蜞弪 觐祜桦蝾. 陪 玎溧鬣 - 镥疱忮耱 蝈犟螓 祛潴脲 钺牝睇 觐. 疱珞朦蜞蝈 潆 赅驿钽 桉躅漤钽 羿殡 .耩 耦玟噱蝰 钺牝睇 羿殡, 桁妣 疣聒桊屙桢 .obj.

项耠 觐祜桦蝾疣 疣犷蜞弪 觐祜铐钼, 觐蝾瘥 钺滂弪 钺牝睇 羿殡 邃桧 玎沭箸铟睇 恹镱腠屐 祛潴朦, 桁妣 疣聒桊屙桢 .艴. 蒡铗 祛潴朦 祛骓 玎矬耜囹 磬 恹镱腠屙桢.

 

2. 羊痼牝箴 泐腩忭钽 羿殡 镳铄牝

镳铞羼皴 镳铄牝桊钼囗 镳桦铈屙 C++Builder 噔蝾爨蜩麇耜 耦玟噱 觐潲 泐腩忭钽 羿殡 镳铄牝, 觐潲 铗溴朦睇 祛潴脲 觐潲 桴 玎泐腩忸黜 羿殡钼. 妙腩忭铋 羿殡 镳铄牝 耦溴疰栩 趔黻鲨 WinMain. 镳铟桢 祛潴腓 忖钿栩 疋铋 觐, 耦玟噔 钺疣犷蝼桕 疣珉梓睇 耦猁蜩. 玎泐腩忸黜 羿殡 桴 祛潴脲 镱戾 怦 钺怆屙. 皖 泐腩忭铋 祛潴朦, 赅 镳噔桦, 礤 疱溧牝桊箦禧. 翌朦觐 桉觌栩咫 耠篦 磬漕 黩-蝾 桤戾螯 蝈犟蝈 泐腩忭钽 祛潴, 胥屙屦桊钼囗眍 C++Builder. 义 礤 戾礤, 磬漕 怦-蜞觇 镳邃耱噔螯 忤 泐腩忭钽 羿殡 镳铄牝 镱龛爨螯, 黩 铉磬鬣 邈 铒屦囹铕.

橡铖祛蝠弪 觐 泐腩忭钽 羿殡 镳铄牝 祛骓 麇疱 矬黻 戾睨 Project | View Source. 诣镨黜 泐腩忭铋 羿殡 镳铄牝 桁邋 耠邃簋 忤:

(1)

袜麒磬弪 羿殡 泐腩忭钽 祛潴 滂疱牝桠囔 镳屣痤鲥耨铕, 磬栳铍邋 忄骓 滂疱牝桠 #include. 蒡 滂疱牝桠 镱潢膻鬣 溧眄 羿殡 蝈犟螓 箨噻囗睇 龛 羿殡钼. 鬣耱眍耱, 镱漕犴 滂疱牝桠囔 怅膻鬣 蝈犟 玎泐腩忸黜 羿殡. 蔫疱牝桠 #include <vcl.h> 镱潢膻鬣弪 玎泐腩忸黜 羿殡 vcl.h, 耦溴疰帙栝 钺怆屙, 桉镱朦珞屐 徼犭桀蝈赍 忤珞嚯 觐祜铐屙蝾 C++Builder.

项耠 滂疱牝桠 镳屣痤鲥耨铕 羿殡 疣珈妁屙 镳邃腩驽龛 USERES USEPORM. 蒡 爨牮铖, 桉镱朦珞屐 潆 镱潢膻麇龛 镳铄牝 羿殡钼 纛痨, 疱耋瘃钼 漯. 橡屣痤鲥耨铕 疣玮屦礤  爨牮铖 耦铗忮蝰蜮簋 觐. C++Builder 噔蝾爨蜩麇耜 纛痨桊箦 耦铗忮蝰蜮簋 镳邃腩驽龛 爨牮铖铎 USEFORM 潆 赅驿铋 纛痨, 忭铖桁铋 镳铄牝. 襄疴 镟疣戾蝠 爨牮铖 耦溴疰栩 桁 羿殡 祛潴, 耦铗忮蝰蜮簋泐 纛痨 (磬镳桁屦, 玌nit1.cpp), 怛铕铋 镟疣戾蝠 - 桁 纛痨.

泥脲 疣耧铍铈屙 汶噔磬 趔黻鲨 镳钽疣祆 - WinMain.

蝈脲 铋 趔黻鲨 翳泱痦 耜钺赅 疣珈妁屙 耠邃簋 铒屦囹铕:

Application->Initialize 桧桷栲腓玷痼弪 钺牝 觐祜铐屙蝾 溧眄钽 镳桦铈屙.

Application->CreateForm 耦玟帼 钺牝 耦铗忮蝰蜮簋 纛痨. 灶痨 耦玟帼蝰 蝾 镱耠邃钼囹咫铖蜩, 觐蝾痤 耠邃簋  铒屦囹铕. 襄疴 桤 耦玟噔噱禧 纛痨 怆弪 汶噔眍.

Application->Run 磬麒磬弪 耦狁蜮屙眍 恹镱腠屙桢 镳钽疣祆. 项耠 钽 铒屦囹铕 镳钽疣祆 驿弪 耦铗忮蝰蜮簋 耦猁蜩, 觐蝾瘥 箫疣怆 邋 躅漕.

义腩 趔黻鲨 WinMain 玎觌屙 犭铌 try catch. 蒡 耱痼牝箴, 疋玎眄 钺疣犷蜿铋 蜞 磬琨忄屐 桉觌屙栝 - 噔囵栝睇 耔蝮圉栝, 忸珥桕帼 镳 疣犷蝈 镳钽疣祆. 篷腓 蜞赅 噔囵栝磬 耔蝮圉 忸珥桕礤, 蝾 狍潴 恹镱腠屙 铒屦囹铕, 疣耧铍铈屙睇 犭铌 catch. 项 箪铍鬣龛 铎 犭铌 疣耧铍铈屙 耱囗溧痱睇 钺疣犷蝼桕 桉觌屙栝 镱祛 趔黻鲨 Application->ShowException.

项耠邃龛 铒屦囹铕 蝈豚 趔黻鲨 WinMain - 铒屦囹铕 return 0;, 玎忮瘌帼 镳桦铈屙桢 觐漕 玎忮瘌屙 0.

埋 铒桉囗睇 恹 铒屦囹铕 泐腩忭钽 羿殡 镳桦铈屙 玎眍蝰 礤泐 噔蝾爨蜩麇耜 镳铞羼皴 镳铄牝桊钼囗 镳桦铈屙. 袜镳桁屦, 镳 漕徉怆屙梃 镳铄牝 眍忸 纛痨 羿殡 噔蝾爨蜩麇耜 怦蜞怆 耦铗忮蝰蜮簋 镳邃腩驽龛 USEFORM 铒屦囹铕 Application->CreateForm, 耦玟帼 纛痨. 亦 黩 钺眍 龛麇泐 泐腩忭铎 羿殡 桤戾螯 礤 磬漕 溧驽 礤 礤钺躅滂祛耱 邈 耢铗疱螯.

褥 泐腩忭钽 羿殡 镳铄牝 镱 箪铍鬣龛 溧弪 耱囗溧痱眍: Project1, Project2 .. 蒡 驽 桁 狍溴 恹镱腠屐钽 祛潴 镳钽疣祆. 亦 黩 驽豚蝈朦眍 桤戾龛螯 桁 镱 箪铍鬣龛. 碾 钽 漕耱囹铟眍 耦躔囗栩 泐腩忭铋 羿殡 镳铄牝 镱 耦铗忮蝰蜮簋 桁屙屐.

埋邈溧 眢骓 耦躔囗螯 镳铄牝 镱 赅觇-蝾 铖禧耠屙睇 桁屙屐. 软圜 铟屙 耜铕 祛骓 玎矬蜞螯 徨耜铐鬻睇 镳钽疣祆圊 Project1.

 

3. 羊痼牝箴 羿殡钼 祛潴脲 纛痨

朽耨祛蝠桁 蝈镥瘘 蝈犟螓 祛潴脲 纛痨. 枢驿 蜞觐 祛潴朦 耦耱铊 桤 溻篚 羿殡钼: 玎泐腩忸黜钽, 耦溴疰帙邈 铒桉囗桢 觌囫襦 纛痨, 羿殡 疱嚯桤圉梃. 丸驽 镳桠邃屙 蝈犟螓 桴 羿殡钼 祛潴 纛痨, 磬 觐蝾痤 疣珈妁屙 钿桧 觐祜铐屙 蜩镟 TLabel 钿桧 觐祜铐屙 蜩镟 TButton. 项漯钺睇 觐祆屙蜞痂 铎 蝈犟蝈 镱耥, 牦溧 黩 铗 觐 祛驽蝈 漕徉怆螯.

(2)

青泐腩忸黜 羿殡:

(3)

脏殡 疱嚯桤圉梃:

朽耨祛蝠桁 镱漯钺礤  羿殡. 青泐腩忸黜 羿殡 磬麒磬弪 噔蝾爨蜩麇耜 怅膻麇眄 礤泐 滂疱牝桠 镳屣痤鲥耨铕. 鬣耱眍耱, C++Builder 襦 镱戾弪 蝮 滂疱牝桠 include, 镱潢膻鬣桢 觐镨 羿殡钼, 觐蝾瘥 铒桉囗 蝈 觐祜铐屙螓, 镥疱戾眄, 觐眈蜞眚, 趔黻鲨, 觐蝾瘥 桉镱朦珞 溧眄铎 祛潴脲. 武磬觐 潆 礤觐蝾瘥 趔黻鲨 蜞觐 噔蝾爨蜩麇耜铄 镱潢膻麇龛 礤 镳铊玮钿栩. 桴 耠篦 疣琊噌铗麒 漕腈屙 漕徉忤螯 耦铗忮蝰蜮簋 滂疱牝桠 include 怵篦眢.

泥脲 耠邃箦 铒桉囗桢 觌囫襦 纛痨. 褥 觌囫襦 纛痨 - TForm1. 孰囫 耦溴疰栩 蝠 疣玟咫: published - 铗牮 疣玟咫, 耦溴疰帙栝 钺怆屙 疣珈妁屙睇 磬 纛痨 觐祜铐屙蝾 钺疣犷蝼桕钼 耦猁蜩 龛, private - 玎牮 疣玟咫 觌囫襦, public - 铗牮 疣玟咫 觌囫襦. 溧眄铎 耠篦噱 疣玟咫 published 祛驽蝈 忤溴螯 钺怆屙 箨噻囹咫彘 磬 溻 觐祜铐屙蜞: 觐祜铐屙 Button1 蜩镟 TButton 觐祜铐屙 Label1 蜩镟 TLabel 蜞 驽 钺怆屙桢 趔黻鲨 Button1Click - 忖邃屙眍泐 镱朦珙忄蝈脲 钺疣犷蝼桕 耦猁蜩 膑赅 磬 觏铒赍 Button1. 埋, 黩 桁邋蝰 疣玟咫 published, C++Builder 怅膻鬣弪 礤泐 噔蝾爨蜩麇耜 镳铞羼皴 镳铄牝桊钼囗 纛痨. 疣玟咫 private public 祛驽蝈 漕徉怆螯 疋铊 钺怆屙 蜩镱, 镥疱戾眄, 趔黻鲨. 翌, 黩 钺怆屙 疣玟咫 public, 狍溴 漕耱箫眍 潆 漯筱桴 觌囫耦 祛潴脲. 翌, 黩 钺怆屙 疣玟咫 private, 漕耱箫眍 蝾朦觐 镳邃咫圊 溧眄钽 祛潴. 枢 祛驽蝈 忤溴螯, 邃桧耱忮眄铄, 黩 C++Builder 襦祛耱蝈朦眍 怅膻麒 疣玟咫 public,  钺怆屙桢 (镳铗铗栾) 觐眈蝠箨蝾疣 纛痨 TForm1.

项耠 钺怆屙 觌囫襦 耠邃箦 镳邃腩驽龛 PACKAGE, 觐蝾痤 怅膻鬣弪 羿殡 噔蝾爨蜩麇耜. 项耠 钽 祛驽蝈 疣珈羼蜩螯 钺怆屙 蜩镱, 镥疱戾眄, 趔黻鲨, 觐蝾瘥 镳 耦犭屙梃 礤觐蝾瘥 漕镱腠栩咫 篑腩忤 狍溴 漕耱箫 桤 漯筱桴 祛潴脲, 眍 觐蝾瘥 礤 怅膻鬣 觌囫 纛痨.

义镥瘘 疣耨祛蝠桁 蝈犟 羿殡 疱嚯桤圉梃 祛潴. 项耠 噔蝾爨蜩麇耜 怅膻麇眄 铗 羿殡 滂疱牝桠 镳屣痤鲥耨铕 耠邃箦 蝾驽 噔蝾爨蜩麇耜 怅膻麇眄铄 钺怆屙桢 箨噻囹咫 磬 钺牝 纛痨 Form1, 玎蝈 - 恹珙 觐眈蝠箨蝾疣 纛痨. 义腩 耦铗忮蝰蜮簋 趔黻鲨 矬耱铄, 眍 祛驽蝈 怅膻麒螯 礤泐 赅觇-蝾 铒屦囹铕. 项耠 钽 疣珈妁帼蝰 铒桉囗 怦艴 趔黻鲨, 钺怆屙睇 玎泐腩忸黜铎 羿殡. 卿羼 蜞赕 祛骓 疣珈妁囹 钺怆屙 膻猁 蜩镱, 觐眈蜞眚, 镥疱戾眄, 礤 钺怆屙睇 玎泐腩忸黜铎 羿殡, 疣珈妁囹 铒桉囗 膻猁 趔黻鲨, 礤 箫铎眢螓 玎泐腩忸黜铎 羿殡. 褥屙 羿殡囔 祛潴脲 C++Builder 溧弪 镱 箪铍鬣龛: 潆 镥疴钽 祛潴 桁 疣忭 Unit1, 潆 怛铕钽 Unit2 - ..

 

4. 吾豚耱 忤滂祛耱 漕耱箫 钺牝囔, 镥疱戾眄 趔黻鲨

4.1 橡桁屦 祛潴, 耦溴疰帙邈 钺牝 镳铞邃箴

朽耨祛蝠桁, 赅 祛骓 忖钿栩 祛潴朦 镥疱戾眄, 趔黻鲨 铖- 铖簌羼蜮螯 龛 漕耱箫. 丸驽 镳桠邃屙 蝈犟 觐溧 祛潴, 觐蝾痤 磬 纛痨 疣珈妁屙 溻 觐祜铐屙蜞: 觏铒赅 Button1 蜩镟 TButton 戾蜿 Label1 蜩镟 TLabel. 署铎 蝾泐, 祛潴脲 忖邃屙 钺疣犷蝼桕 耦猁蜩, 疋玎眄钽 耦 膑觐 镱朦珙忄蝈 磬 觏铒赍, 疣珥 戾耱圊 祛潴 忖邃屙 镥疱戾眄 趔黻鲨, 黩钺 祛骓 猁腩 忤溴螯, 赅 镱塍麒螯 龛 漕耱箫.

(4)

青泐腩忸黜 羿殡:

(5)

脏殡 疱嚯桤圉梃:

 

项扈祛 趔黻鲨 Button1Click 觐 祛潴 忭羼屙 趔黻鲨: Fl-F4, 耔焘铍 镥疱戾眄: Ch1-Ch4. 朽耨祛蝠桁 镱漯钺眍  趔黻鲨. 袜 忄骓 镱螯, 赅 桤 趔黻鲨 钺疣螯 疣珉梓睇 钺牝囔 镥疱戾眄. 皖 牮囹觐 铒桉囗桢 蝾泐, 黩 溴豚  趔黻鲨, 磬漕 溧螯.

枢驿 桤 趔黻鲨 F1-F4 徨疱 珥圜屙桢 疋铋耱忄 Caption 戾蜿 TLabel, 镳栳噔弪 礤 耔焘铍, 镥疱溧眄 礤 赅 镟疣戾蝠 Ch, 镳栳噔弪 溧脲 耔焘铍, 躔囗轳 镥疱戾眄铋 Ch1, 忸玮疣弪 磬滹桉 桁 漕徉怆屙扈 钺疣蝽 戾蜿.

吾疣犷蝼桕 TForm1::Button1Click 玎溧弪 镥疱戾眄 Ch1-Ch4 珥圜屙 耔焘铍钼 "-", "", "" "", 玎蝈 铟棂噱 疋铋耱忸 Caption 戾蜿 Label1, 玎眍 礤泐 矬耱簋 耱痤牦, 玎蝈 镱铟屦邃眍 钺疣弪 趔黻鲨 Fl-F4, 镥疱溧忄 龛 赅麇耱忮 镟疣戾蝠钼 疣珉梓睇 耔焘铍. 玎觌屙桢 磬滹桉 戾蜿 铌疣忄弪 牮囫睇 鲡弪 疋铋耱忸 Font->Color. 琼圜屙桢 钽 疋铋耱忄 桤戾弪 镱耠邃龛 铒屦囹铕 镳铞邃箴 TForm1::Button1Click.

 

4.2 念耱箫 疋铋耱忄 戾蝾溧 钺牝钼

朽耨祛蝠桁 蝈镥瘘, 赅 镱塍麒螯 桤 镳钽疣祆 漕耱箫 疋铋耱忄 戾蝾溧 钺牝钼. 念耱箫 钺牝囔-觐祜铐屙蜞 祛骓 镱塍麒螯 麇疱 钺怆屙睇 玎泐腩忸黜铎 羿殡 祛潴 箨噻囹咫 磬  钺牝. 袜镳桁屦, 钺怆屙梃 觌囫襦 纛痨 TForm1 玎泐腩忸黜铎 羿殡 桁邋蝰 耱痤赅

TLabel *Label1;

蒡 耱痤赅 钺怆弪 Label1 赅 箨噻囹咫 磬 戾蜿 - 钺牝 蜩镟 TLabel. 念耱箫 屐屙蜞 觌囫襦 钺羼镥麒忄弪 镱祛 铒屦圉梃 耱疱腙. 羿殡 疱嚯桤圉梃 祛潴 蝈犟蜞 趔黻鲨 F1 F2 恹疣驽龛 忤溧 Label1->Caption 铉磬鬣: 疋铋耱忸 Caption 钺牝 Label1. 软钽溧 疋铋耱忸 钺牝 怆弪 疋铪 铟屦邃 钺牝铎. 翌沅 钺疣龛 铎 疋铋耱怏 箨噻噱蝰 怦 鲥镱麝 镳邃耱怏桴 钺牝钼. 袜镳桁屦, 戾蜿 桁妣 疋铋耱忸 Font - 梏, 觐蝾痤 疋铪 铟屦邃 怆弪 钺牝铎. 钽 钺牝 桁邋蝰 祉铈羼蜮 疋铋耱, 鬣耱眍耱, 疋铋耱忸 Color - 鲡弪 梏蜞. 昨钺 耦耠囹 磬 鲡弪 梏蜞 戾蜿 Label1, 磬漕 磬镨襦螯 Label1->Font->Color. 蒡 铉磬鬣弪: 疋铋耱忸 Color 钺牝 Font, 镳桧噤脲驵泐 钺牝 Label1. 理嚯钽梓磬 眍蜞鲨 桉镱朦珞弪 潆 漕耱箫 戾蝾溧 钺牝.

袜镳桁屦, 潆 戾蜿 铒疱溴脲 戾蝾 Hide, 觐蝾瘥 溴豚弪 戾蜿 礤忤滂祛. 篷腓 赅觐-蝾 祛戾眚 疱腓 皲咫囹 戾蜿 Label1 礤忤滂祛, 祛驽蝈 磬镨襦螯 铒屦囹铕

Label1->Hide();

 

4.3 朽珉梓桢 镥疱戾眄 趔黻鲨, 怅膻麇眄 礤 怅膻麇眄 铒桉囗桢 觌囫襦

朽耨祛蝠桁, 麇 疣珉梓帼蝰 镥疱戾眄 趔黻鲨, 怅膻麇眄 礤 怅膻麇眄 铒桉囗桢 觌囫襦. 襄疱戾眄 趔黻鲨, 怅膻麇眄 铒桉囗桢 觌囫襦, 钺眍 磬琨忄 耦铗忮蝰蜮屙眍 溧眄-屐屙蜞扈 趔黻鲨扈-屐屙蜞扈. 橡桁屙栩咫 挝 C++Builder 桴 磬琨忄 疋铋耱忄扈 戾蝾溧扈. 镳桠邃屙眍 镳桁屦 镥疱戾眄 裩 趔黻鲨 F1 F2 怅膻麇睇 铒桉囗桢 觌囫襦, 镥疱戾眄 Ch2, Ch3 趔黻鲨 F3 F4 钺怆屙 忭 觌囫襦. 麇 狍溴 镳怆螯 疣珉梓桢 桴 桉镱朦珙忄龛?

篷腓 镳桦铈屙梃 耦玟噱蝰 蝾朦觐 钿桧 钺牝 溧眄钽 觌囫襦 ( 镳桁屦 - 蝾朦觐 钿桧 钺牝 纛痨 觌囫襦 TForm1), 蝾 疣珉梓桢 铖眍忭铎 麒耱 忭屮礤. 碾 趔黻鲨, 钺怆屙睇 觌囫皴, 桴 铒桉囗梃 桁屙 趔黻鲨 漕腈磬 漕徉怆螯 耨赅 磬 觌囫 镱祛 铒屦圉梃 汶钺嚯钽 疣琊屮屙 钺豚耱 溴轳蜮 (::). 磬 镳桁屦 桁屙 趔黻鲨 F1, F2 Button1Click 铒桉囗梃 桴 趔黻鲨 玎戾 磬 TForm1::Fl, TForm1::F2 TForm1::Button1Click. 义 襦禧 箨噻噱蝰, 黩 疱鼽 桎弪 趔黻鲨 觌囫襦 TForm1. 碾 趔黻鲨 F3 F4, 钺怆屙睇 忭 觌囫襦, 蜞觐泐 漕镱腠屙 桁屙 礤 蝠遽箦蝰.

湾钺躅滂祛耱 漕徉怆屙 桁屙 趔黻鲨, 铒桉囗睇 觌囫皴, 耨铌 磬 觌囫 钺耥弪 镳铖蝾. 填驽蝈 忭 觌囫襦 铒桉囹 漯筱簋 疋铪 趔黻鲨 蝈 驽 桁屙屐 (磬镳桁屦, F1), 黩 趔黻鲨 觌囫襦. 蝾沅 桤 趔黻鲨, 礤 铒桉囗睇 觌囫皴, 耢铈弪 耨囹 磬 钺  趔黻鲨 F1, 蝾朦觐 磬 钿眢 桤 龛 礤镱耩邃耱忮眄 - 镱 桁屙 F1, 磬 漯筱簋 麇疱 钺牝 觌囫襦 - Form1::Fl. 岭嚆钿囵 铎, 镳 铒桉囗梃 疋铊 趔黻鲨 忭 觌囫襦 祛驽蝈 溧驽 礤 珥囹 桁屙 怦艴 趔黻鲨, 铒桉囗睇 觌囫皴. 丸赅觐 矬蜞龛鳆 镳 铎 礤 忸珥桕礤.

亦觇 钺疣珙, 镳桁屙屙桢 铒屦圉梃 汶钺嚯钽 疣琊屮屙 钺豚耱 溴轳蜮 镱玮铍弪 钺忤螯 疣珥 觌囫襦 忭 觌囫耦 镥疱戾眄 趔黻鲨 钿桧嚓钼 桁屙囔. 铎 耠篦噱 铒屦圉 疣琊屮屙 钺豚耱 溴轳蜮 箨噻噱, 赅觐 桁屙眍 镥疱戾眄铋 桦 趔黻鲨 桎弪 疱鼽. 礤觐蝾瘥 耠篦 镳 疣犷蝈 C++Builder 疣琊屮屙桢 钺豚耱 溴轳蜮 镳桴钿栩 溴豚螯 怵篦眢. 蒡 镳铊聃钿栩 蝈 耠篦, 觐沅 觐祜桦蝾 恹溧弪 耦钺龛, 黩 礤 祛驽 恹狃囹 钿眢 桤 礤耜铍桴 嚯屦磬蜩, 磬镳桁屦, 礤 珥噱, 赅觐祗 觌囫耋 铗眍耔蝰 箨噻囗睇 戾蝾.

吾疣龛 镥疱戾眄 趔黻鲨, 铒桉囗睇 忭篁痂 忭 觌囫襦, 桤 趔黻鲨, 铒桉囗睇 忭 觌囫襦, 疣珉梓噱蝰. 镥疱戾眄 趔黻鲨, 铒桉囗睇 忭 觌囫襦, 钺疣龛 镳铊聃钿栩 镳铖蝾 镱 桴 桁屙囔, 镥疱戾眄 趔黻鲨, 铒桉囗睇 觌囫皴, 麇疱 桁 钺牝 觌囫襦. 项铎 镳桁屦 趔黻鲨 F3 F4 钺疣龛 镥疱戾眄铋 h 桁邋 忤 Form1->Ch1. 项 蝾 驽 镳梓桧 钺疣龛 疋铋耱怏 Caption 钺牝 Label1 桴 趔黻鲨 桁邋 忤 Form1->Label1->Caption. 翌朦觐 麇疱 耨牦 磬 钺牝 Form1 忭屮龛 镱 铗眍龛 觌囫耋 趔黻鲨 祛泱 镱塍麒螯 漕耱箫 觐 怦屐, 钺怆屙眍祗 觌囫皴.

埋  耨觇 磬 钺牝 礤 蝠遽簋蝰 趔黻鲨, 钺怆屙睇 觌囫皴. 项铎 趔黻鲨 TForm1::Fl, TForm1::F2 TForm1::Button1Click 耨觇 磬 镥疱戾眄簋 h 磬 钺牝 Label1 礤 耦溴疰囹 漕镱腠栩咫 耨铌 磬 钺牝 纛痨.

篷腓 镳桦铈屙梃 耦玟噱蝰 礤耜铍 钺牝钼 钿眍泐 觌囫襦, 磬镳桁屦, 礤耜铍 纛痨 觌囫襦 TForm1, 蝾 镳怆 犷脲 镳桧鲨镨嚯 疣珉梓 戾驿 镥疱戾眄, 铒桉囗睇扈 忭篁痂 忭 觌囫襦. 襄疱戾眄 忭 觌囫襦 ( 磬 镳桁屦 Ch2 Ch3) 蜞 铖蜞 钿眍 珏祜疱. 镥疱戾眄, 铒桉囗睇 觌囫皴 ( 磬 镳桁屦 h), 蜩疣骅痼 耱铍 疣, 耜铍 钺牝钼 溧眄钽 觌囫襦 耦玟囗. .. 赅驿铎 钺牝 觌囫襦 TForm1 狍溴 疋 镥疱戾眄 h 怦 铐 漯筱 漯筱铎 龛赅 礤 狍潴 疋玎睇. 亦觇 钺疣珙, 镥疱戾眄簋, 铒桉囗眢 忭篁痂 觌囫襦, 祛骓 玎眍耔螯 赅牦-蝾 桧纛痨圉棹, 桧滂忤潴嚯簋 潆 赅驿钽 钺牝 溧眄钽 觌囫襦. 镥疱戾眄, 铒桉囗磬 祛潴脲 忭 铒桉囗 觌囫襦, 祛驽 躔囗栩 蝾朦觐 钿眍 珥圜屙桢.

悟戾蜩 妁 钿眢 铖钺屙眍耱. 襄疱 桁屙囔 趔黻鲨-屐屙蝾 觌囫襦 耱噔栩 铒鲨 觐祜桦蝾疣 _fastcall. 湾 怃噔顸 溴蜞腓 耜噫屐, 黩  铒鲨 怆弪 磬 镳铞羼 觐祜桦鲨 钺羼镥麒忄弪 镥疱溧黧 镟疣戾蝠钼 趔黻鲨 猁耱瘥 疱汨耱瘥, 黩 篑觐弪 恹珙 趔黻鲨. 碾 趔黻鲨-屐屙蝾 觌囫耦  铒鲨 耠邃箦 箨噻囹 怦邈溧. 碾 漯筱桴 趔黻鲨 邋 祛骓 箨噻囹, 祛骓 礤 箨噻囹. 嘛痤麇,  铒鲨 鲥脲耦钺疣珥 箨噻囹 潆 趔黻鲨, 礤 怆桴 屐屙蜞扈 觌囫襦.

玎觌屙桢 镳铖箪扈痼屐 桤腩驽眄 镳噔桦.

疱嚯桤圉棹 趔黻鲨-屐屙蝾 漕腈磬 漕徉怆螯 耨赅 磬 觌囫 镱祛 铒屦圉梃 汶钺嚯钽 疣琊屮屙 钺豚耱 溴轳蜮 (::).

泽黻鲨-屐屙螓 钺怆 铒桉帼蝰 镳桁屙屙桢 铒鲨 觐祜桦蝾疣 _fastcall.

趔黻鲨-屐屙蜞 钺疣龛 漯筱桁 趔黻鲨-屐屙蜞 溧眄-屐屙蜞 蝾泐 驽 觌囫襦 祛驽 铖簌羼蜮螯 徨 箨噻囗 磬 钺牝.

趔黻鲨, 礤 怆桴 屐屙蜞扈 觌囫襦 溧眄钽 钺牝, 漕耱箫 戾蝾溧 疋铋耱忄 铖簌羼蜮弪 麇疱 箨噻囹咫 磬 钺牝 镱祛 铒屦圉梃 耱疱腙 (->) 桦 镱祛 疣琨戾眍忄龛 箨噻囹咫 磬 钺牝 铒屦圉梃 蝾麝 (.).

 

4.4 吾豚耱 忤滂祛耱 镥疱戾眄 趔黻鲨

朽耨祛蝠桁 忤滂祛耱 趔黻鲨 镳桦铈屙, 桁妣 礤耜铍 祛潴脲. 篷腓 祛潴脲 Unit1 邈 玎泐腩忸黜铎 羿殡 忭 铒桉囗 觌囫襦 钺忤腓 礤觐蝾痼 趔黻鲨 F, 蝾 漯筱铎 祛潴脲 Unit2 祛驽蝈 桉镱朦珙忄螯 邋 镳 恹镱腠屙梃 钿眍泐 桤 溻篚 篑腩忤:

怅膻鬣弪 滂疱牝桠铋 #include 祛潴朦 Unit2 玎泐腩忸黜 羿殡 Unit1.h

镱怛铕弪 祛潴脲 Unit2 ( 玎泐腩忸黜铎 羿殡 桦 羿殡 疱嚯桤圉梃) 钺怆屙桢 趔黻鲨 F

钺铊 耠篦 耢铈弪 恹玮囹 趔黻鲨 F 桤 膻犷泐 戾耱 祛潴 Unit2.

篷腓 驽 趔黻鲨 F 钺怆屙 祛潴脲 Unit1 礤 玎泐腩忸黜铎 羿殡, 羿殡 疱嚯桤圉梃, 蝾 邃桧耱忮眄 耧铖钺 桉镱朦珙忄螯 邋 祛潴脲 Unit2 - 镱怛铕栩 礤 钺怆屙桢 趔黻鲨.

篷腓 躅蜩蝈 镳邃铗怵囹栩 忸珈铈眍耱 钺疣龛 趔黻鲨 桤 漯筱钽 祛潴, 邋 磬漕 钺忤螯 耦 耧弼梏桕圉桢 static. 袜镳桁屦:

static void F(void);

项溻邃屐 礤觐蝾瘥 栩钽 疣耨祛蝠屙 镳钺脲 忤滂祛耱 镥疱戾眄 趔黻鲨.

襄疱戾眄, 钺怆屙睇 玎泐腩忸黜铎 羿殡 祛潴 桦 羿殡 邈 疱嚯桤圉梃 忭 铒桉囗 觌囫襦 趔黻鲨, 怆 汶钺嚯. 雾 漕耱箫睇 忮玟 忭篁痂 溧眄钽 祛潴. 碾 漕耱箫 龛 桤 忭屮龛 祛潴脲 桴 祛潴 漕腈眍 猁螯 镱怛铕屙 桴 钺怆屙桢 漕徉怆屙桢 耧弼梏桕圉梃 extern. 疣耨祛蝠屙眍 镳桁屦  铗眍耔蝰 镥疱戾眄 h2 h.

泽黻鲨, 钺怆屙睇 玎泐腩忸黜铎 羿殡 祛潴 忭 铒桉囗 觌囫襦, 怆 汶钺嚯. 雾 漕耱箫睇 忮玟 忭篁痂 溧眄钽 祛潴. 碾 漕耱箫 龛 桤 忭屮龛 祛潴脲 桴 祛潴 桦 磬漕 镱怛铕栩 桴 钺怆屙桢, 桦 怅膻麒螯 滂疱牝桠铋 #include 玎泐腩忸黜 羿殡 蝾泐 祛潴, 觐蝾痤 趔黻鲨 铒桉囗. 疣耨祛蝠屙眍 镳桁屦  铗眍耔蝰 趔黻鲨 F3.

泽黻鲨, 钺怆屙睇 羿殡 疱嚯桤圉梃 祛潴, 怆 汶钺嚯. 雾 漕耱箫睇 忮玟 忭篁痂 溧眄钽 祛潴. 碾 漕耱箫 龛 桤 忭屮龛 祛潴脲 桴 祛潴 磬漕 镱怛铕栩 桴 钺怆屙桢. 疣耨祛蝠屙眍 镳桁屦  铗眍耔蝰 趔黻鲨 F4.

蓦屐屙螓 (镥疱戾眄 趔黻鲨), 钺怆屙睇 觌囫皴 疣玟咫 private, 忤滂禧 漕耱箫睇 蝾朦觐 忭篁痂 溧眄钽 祛潴. 橡 铎 桤 趔黻鲨, 钺怆屙睇 忭篁痂 觌囫襦, 龛 祛骓 钺疣螯 礤镱耩邃耱忮眄 镱 桁屙, 桤 漯筱桴 趔黻鲨 - 蝾朦觐 耦 耨觐 磬 钺牝 溧眄钽 觌囫襦. 疣耨祛蝠屙眍 镳桁屦  铗眍耔蝰 镳铞邃箴 F1. 篷腓 祛潴脲 铒桉囗 礤耜铍 觌囫耦, 蝾 钺牝 桴 觌囫耦 忡噼祉 忤 屐屙螓, 铒桉囗睇 桴 疣玟咫圊 private.

蓦屐屙螓, 钺怆屙睇 觌囫皴 疣玟咫 public, 忤滂禧 漕耱箫睇 潆 钺牝钼 膻猁 觌囫耦 潆 漯筱桴 祛潴脲, 觐蝾瘥 滂疱牝桠铋 include 怅膻麇 玎泐腩忸黜 羿殡 溧眄钽 祛潴. 橡 铎 桤 钺牝钼 蝾泐 驽 觌囫襦, 龛 祛骓 钺疣螯 礤镱耩邃耱忮眄 镱 桁屙, 桤 漯筱桴 钺牝钼 镳铞邃箴 - 蝾朦觐 耦 耨觐 磬 钺牝 溧眄钽 觌囫襦. 疣耨祛蝠屙眍 镳桁屦  铗眍耔蝰 镥疱戾眄铋 h 镳铞邃箴 F2.

觌囫襦 祛泱 猁螯 妁 疣玟咫 protected -玎眄. 蓦屐屙螓, 钺怆屙睇 觌囫皴 疣玟咫 protected, 忤滂禧 漕耱箫睇 潆 膻猁 钺牝钼 忭篁痂 溧眄钽 祛潴, 蜞赕 潆 钺牝钼 觌囫耦-磬耠邃龛觐 溧眄钽 觌囫襦 漯筱桴 祛潴. 吾牝 桤 漯筱桴 祛潴脲, 觌囫覃 觐蝾瘥 礤 怆 磬耠邃龛赅扈 溧眄钽 觌囫襦, 玎眄 屐屙蝾 礤 忤.

蓦屐屙螓, 钺怆屙睇 忭篁痂 趔黻鲨 桦 犭铌 ( 疣耨祛蝠屙眍 镳桁屦  镥疱戾眄 Ch4 钺怆屙磬 忭篁痂 趔黻鲨 TForm1::Button1Click), 怆 腩赅朦睇扈, .. 铐 忤滂禧 漕耱箫睇 蝾朦觐 忭篁痂 溧眄铋 趔黻鲨 桦 溧眄钽 犭铌. 橡 铎 怵屐 骅珥 镥疱戾眄, 钺怆屙睇 忭篁痂 趔黻鲨 桦 犭铌, 铒疱溴弪 怵屐屙屐 嚓蜩忭铖蜩 溧眄钽 犭铌. 亦 镥疱戾眄 Ch4 磬 镳桁屦 耦玟噱蝰 祛戾眚 恹珙忄 趔黻鲨 TForm1::Button1Click 箜梓蝾驵弪 镳 玎忮瘌屙梃 疣犷螓 铋 趔黻鲨. 唁咫囹 腩赅朦眢 镥疱戾眄簋 耋耱怏彘 镱耱眄 祛骓 镱祛 耧弼梏桕圉梃 static.

襄疱戾眄 趔黻鲨, 钺怆屙睇 泐腩忭铎 羿殡 镳铄牝, 怆 汶钺嚯 潆 钽 羿殡. 篷腓 蝠遽箦蝰 漕耱箫 龛 桤 漯筱桴 祛潴脲, 蝾 潆 趔黻鲨 龛 漕腈睇 猁螯 镱怛铕屙 桴 钺怆屙, 潆 镥疱戾眄 - 镱怛铕屙 钺怆屙桢 (徨 桧桷栲腓玎鲨) 耦 耧弼梏桕圉桢 extern.

篷腓 忸 忭篁疱眄屐 犭铌 钺怆屙 镥疱戾眄 蝈 驽 桁屙屐, 黩 忸 忭屮礤 犭铌, 桦 蝈 驽 桁屙屐, 黩 汶钺嚯 镥疱戾眄, 蝾 耦铗忮蝰蜮簋 忭屮 桦 汶钺嚯 镥疱戾眄 犭铌 礤 忤漤. 铎 耠篦噱 镱潴麒螯 漕耱箫 钿眍桁屙眍 汶钺嚯铋 镥疱戾眄铋 祛骓 蝾朦觐 镱祛 箜囵眍 铒屦圉梃 疣琊屮屙 钺豚耱 溴轳蜮 "::".

 

 

5. 雨噻囹咫 磬 钺牝

务眍忸 钺牝眍-铕桢眚桊钼囗眍泐 镳钽疣祆桊钼囗 怆 钺牝 觌囫覃. 朽耨祛蝠桁 犷脲 耠铈睇 蝾黻桢 忸镳铖 疣犷螓 钺牝囔. 雨噻囹咫 磬 钺牝 -  镥疱戾眄, 觐蝾痤 躔囗栩 耨赅 磬 钺牝 礤觐蝾痤泐 觌囫襦, .. 磬 戾耱 镟蜩, 沅 疣珈妁屙 钺牝. 吾怆屙桢 (耦玟囗桢) 箨噻囹咫 磬 钺牝 礤觐蝾痤泐 觌囫襦 (蜩镟) 镳铊玮钿栩 铒屦囹铕铎:

<蜩> *<箨噻囹咫>;

袜镳桁屦, 耠邃簋 钺怆屙桢 耦玟噱 箨噻囹咫 磬 钺牝 觌囫襦 TLabel:

TLabel *Lab;

杨玟噱蝰 礤 襦 钺牝, 蝾朦觐 箨噻囹咫 磬 膻犷 钺牝 溧眄钽 蜩镟. 祛戾眚 邈 耦玟囗 箨噻囹咫 桧桷梃痼弪 眢脲. 腕朦 礤 祛驽 囫耦鲨桊钼囹 龛 赅觇 钺牝铎 镟蜩. 项铎 铒疱溴腓螯, 玎礤皴磬 箨噻囹咫 耨赅 磬 觐黻疱蝽 钺牝, 桦 礤, 祛骓, 磬镳桁屦, 铒屦囹铕铎:

if (Lab ==0) ... ;

卿羼 祉钽铗铟桢 钺铉磬麇睇 礤觇 溴轳蜮, 觐蝾瘥 磬漕 溴豚螯 镳 铗耋蝰蜮梃 耨觇.

C++ 镳邃铒疱溴脲磬 觐眈蜞眚 NULL, 觐蝾疣 忤忄脲眚磬 眢脲忸祗 箨噻囹咫. 项铎 镳桠邃屙睇 恹 铒屦囹铕 忤忄脲眚屙 耠邃簋祗:

if (Lab == NULL) ...;

溧朦礤轼屐 箨噻囹咫 祛骓 镳桉忸栩 耨牦 磬 膻犷 钺牝 耦铗忮蝰蜮簋泐 觌囫襦 镳铖螓 镳桉忄桠囗桢. 袜镳桁屦:

Lab = Label1;

翌沅 箨噻囹咫 Lab 耱囗钼栩 赅 猁 锺邂漕龛祛 钺牝 Label1. 吾 箨噻囹咫: Lab, Label1 耨帼蝰 磬 钿桧 蝾 驽 钺牝. 袜镳桁屦,

Label1->Captin Lab->Caption 耨帼蝰 磬 磬滹桉 钿眍 蝾 驽 戾蜿.

赅麇耱忮 蜩镟 钺牝, 磬 觐蝾瘥 耨噱蝰 箨噻囹咫, 祛骓 玎溧螯 void. 袜镳桁屦:

void *Lab;

亦觐 箨噻囹咫 磬 void 祛骓 疣耨爨蝠桠囹 赅 箨噻囹咫 磬 钺牝 膻犷泐 蜩镟. 溧朦礤轼屐 铎 箨噻囹咫 祛骓 玎溧螯 镳铖螓 镳桉忄桠囗桢 耨牦 磬 钺牝 膻犷泐 蜩镟. 皖 疣琨戾眍忄龛 蜞觐泐 箨噻囹咫 蝠遽箦 镳桁屙屙 忭钽 镳桠邃屙 蜩镱, 镱耜铍 觐祜桦蝾 礤 珥噱, 磬 钺牝 赅觐泐 蜩镟 溴轳蜮栩咫铖蜩 耨噱蝰 箨噻囹咫. 项铎 潆 礤泐 礤朦, 磬镳桁屦, 镱耠 镳桉忄桠囗 屐 耨觇 磬 戾蜿 Label1 磬镨襦螯 镳铖蝾 Lab->Caption. 碾 耨觇 磬 磬滹桉 Caption 麇疱 铗 箨噻囹咫 磬漕 镨襦螯 ((TLabel *)Lab)->Caption, 蝾 羼螯 忭 钺疣珙 镳桠钿栩 蜩 箨噻囹咫 Lab 蜩矬 "箨噻囹咫 磬 钺牝 觌囫襦 TLabel".

填骓 耦玟噔囹 耨牦 磬 钺牝 镱祛 箨噻囹咫 礤 磬 桉蜩眄 觌囫 钺牝, 磬 钿桧 桤 觌囫耦, 觐蝾瘥 磬耠邃箦 觌囫 溧眄钽 钺牝. 腻腩 蝾, 黩 膻犷 钺牝 祛驽 疣耨爨蝠桠囹 礤 蝾朦觐 赅 钺牝 疋铄泐 觌囫襦, 眍 赅 钺牝 膻犷泐 觌囫襦-镳邃赅. 蒡 钺 漕耱囹铟眍 羼蝈耱忮眄 潆 钺眍泐 镱龛爨龛 钺牝钼 疱嚯铎 扈疱.

袜镳桁屦, 箜桠屦襦朦睇 箨噻囹咫屐 磬 膻犷 觐祜铐屙 祛驽 猁螯 箨噻囹咫 磬 觌囫 TControl - 徉珙恹 觌囫 怦艴 觐祜铐屙蝾:

TConrrol *Contr;

亦觐祗 箨噻囹咫 祛骓 礤镱耩邃耱忮眄 镳桉忄桠囹 耨牦 磬 膻犷 觐祜铐屙. 袜镳桁屦,

Contr = Label1;

橡 蜞觐 镳桉忄桠囗梃 觐祜桦蝾 襦 镳铊玮钿栩 礤钺躅滂祛 镳桠邃屙桢 蜩镱. 皖 桁 箨噻囹咫屐 Contr 箧 礤朦 疣犷蜞螯 礤镱耩邃耱忮眄 赅 箨噻囹咫屐 磬 戾蜿. 碾 礤泐 桤忮耱睇 蝾朦觐 疋铋耱忄, 钺怆屙睇 觌囫皴 TControl. 蒡 蜞觇 钺 疋铋耱忄 怦艴 觐祜铐屙蝾, 赅, 磬镳桁屦, Name - 桁. 湾镱耩邃耱忮眄 耨赅 磬 耧弼梏梓羼觇 疋铋耱忄 觌囫耦-磬耠邃龛觐 礤忸珈铈磬. 袜镳桁屦, 镱稃蜿 磬镨襦螯 觐 Contr->Caption 恹珙忮 耦钺龛 觐祜桦蝾疣 钺 铠栳赍, 耢 觐蝾痤泐 玎觌噱蝰 蝾, 黩 疋铋耱忸 Caption 觌囫皴 TControl 礤漕耱箫眍. 项铎 潆 漕耱箫 戾蝾溧 疋铋耱忄, 铗耋蝰蜮簋 觌囫皴 TControl, 磬漕 铖簌羼蜮螯 忭铄 镳桠邃屙桢 蜩镟 箨噻囹咫, 磬镳桁屦:

((TLabel *)Contr)->Caption

蒡铗 觐 泐忸痂 觐祜桦蝾痼: 囫耢囹痂忄 Contr 赅 耨牦 磬 觌囫 TLabel. 蝾沅 龛赅觇 耦钺龛 钺 铠栳赅 礤 忸珥桕噱.

杨玟囗桢 眍忸泐 钺牝 蜞赕 疋玎眍 耦玟囗桢 箨噻囹咫 磬 礤泐. 碾 耦玟囗 钺牝 镳桁屙弪 铒屦圉 new. 礤 镱耠 觌邂钽 耠钼 new 箨噻噱蝰 觌囫 觐祜铐屙蜞. 篷腓 钺牝 怆弪 觐祜铐屙蝾, 蝾 镱耠 觌囫襦 觐祜铐屙蜞 耜钺赅 箨噻噱蝰 觐祜铐屙 - 躅桧 (Owner). 署铎 蝾泐, 镱耠 耦玟囗 觐祜铐屙蜞 钺玎蝈朦眍 磬漕 箨噻囹 邈 痤滂蝈 (Parent) - 觐祜铐屙, 磬 觐蝾痤 疣珈妁噱蝰 眍恹 觐祜铐屙. 项赅 礤 玎溧 痤滂蝈朦, 觐祜铐屙 礤朦 筲桎弪.

朽耨祛蝠桁 耠邃簋 觐:

TLabel *Lab1 = new TLabel (Form1);

Lab1->Parent = Form1;

Lab1->Caption = " 眍忄 戾蜿";

襄疴 桤 桴 铒屦囹铕钼 耦玟噱 箨噻囹咫 Lab1 磬 钺牝-戾蜿 蜩镟 TLabel 耦玟噱 镱祛 new 襦 钺牝-戾蜿 躅桧铎 Form1. 项耠邃簋 铒屦囹铕 桉镱朦珞 箨噻囹咫 Lab1 潆 玎溧龛 疋铋耱 戾蜿: 疣珈妁帼 邋 磬 纛痨 Form1 玎溧 磬 礤 磬滹桉 蝾 眍忄 戾蜿嗷:

项耜铍 龛赅觇 漯筱桢 疋铋耱忄 戾蜿 礤 玎溧睇, 铐 狍潴 篑蜞眍怆屙 觐眈蝠箨蝾痤 觌囫襦 TLabel 箪铍鬣龛屐. 蒡铗 觐眈蝠箨蝾 礤忭 钺疣珙 恹琨忄弪 铒屦圉桢 new.