InfoLight-EEP(delphi)不同Package(bpl)表單(form)相互呼叫(達到模組化)
開發案例:
撰寫”共用地址查詢”(翻寫”三加二郵遞區號查詢” )
※把需要讓外部取得的值,利用屬性Published出來,再透過 delphi RTTI,讀取該表單的屬性內容。
請先uses TypInfo、UserUtils
1: procedure TfmCompetitionStore.btnAddrClick(Sender: TObject);
2: var
3: aForm:TForm;
4: aPropInfo:PPropInfo;//Uses TypInfo
5: iCityID:String;
6: begin
7: inherited;
8: aForm:=GetPackageForm('cSelAddress','fmSelAddress','');//Uses UserUtils;
9: try
10: //將Form設定為SDI單一畫面格式
11: aForm.FormStyle:=FsNormal;
12: aForm.Visible:=False;
13: aForm.WindowState:=wsNormal;
14: aForm.BorderStyle:=bsDialog;
15: if aForm.ShowModal =mrOk then
16: begin
17: //利用RTTI取得屬性
18: //取得屬性值
19: with fAddress do begin
20: fZipCode:= (GetStrProp(aForm,'ZipCode'));
21: fCity:= (GetStrProp(aForm,'City'));
22: fArea:= (GetStrProp(aForm,'Area'));
23: fRoad:= (GetStrProp(aForm,'Road'));
24: fNeighbor:= (GetStrProp(aForm,'Neighbor'));
25: fLane:= (GetStrProp(aForm,'Lane'));
26: fAlley:= (GetStrProp(aForm,'Alley'));
27: fNum:= (GetStrProp(aForm,'Num'));
28: fNumOf:= (GetStrProp(aForm,'NumOf'));
29: fFloor:= (GetStrProp(aForm,'Floor'));
30: fFloorOf:= (GetStrProp(aForm,'FloorOf'));
31: fRoom := (GetStrProp(aForm,'Room'));
32: fBasement:= (GetStrProp(aForm,'Basement'));
33: fFulAddress:= (GetStrProp(aForm,'FulAddress'));
34: end;
35: end;
36: finally
37: aForm.Free;
38: end;
39: end;