動態更新EEP主畫面的底圖(backGroundImage),利用eep提供的cInitial畫面初始化bpl
效果:
原理:
利用EEP的cInitial的bpl畫面初始化,在EEP主畫面建立時,會先去找有沒有這個BPL,進行畫面的初始化。
過程中會將cInitial的ClientUIInfo指向FClientUIInfo(主畫面內部變數成員),接著只要利用FClientUIInfo,
就可以對畫面進行更新,但是底圖是用繪上去的所以要重新對ClientWndProc傳入WM_PAINT的訊息。
實作:
1: procedure TMainForm.cmbSelectCompanyChange(Sender: TObject);
2: var
3: sCompany, fCmpPic: string;
4: Msg: TMessage;
5: begin
6: inherited;
7: sCompany := GetItemType(cmbSelectCompany.Items[cmbSelectCompany.ItemIndex]);
8: if sCompany = '' then exit;
9: GetSysInfo(sCompany,UserUtils.SysInfo);
10: with SysInfo do
11: SELF.Caption:=Format('%s ERP系統',['['+CompanyID+']'+CompanyName]);
12:
13:
14: if ClientUIInfoIntf <> nil then
15: begin
16: //在底圖名稱,直接使用companyId
17: CheckLocalFile(
18: Format('Pics\%s.jpg',[sCompany]), //aFileName: string檔案名稱
19: True,//bDownLoadFromServer: boolean;是否從Server端下載
20: True,//bFindInSearchPath: boolean;是否要用SearchPath來尋找檔案
21: True,//bCheckVersion: boolean;是否要檢查版本
22: False);//
23: fCmpPic:= Format('%s\%s.jpg',[GetPicPath, sCompany]);
24: if FileExists(fCmpPic)then
25: begin
26: FClientUIInfo := (ClientUIInfoIntf as IImplementation).GetInstance as TClientUIInfo;
27: FClientUIInfo.BackGroundImage.LoadFromFile(fCmpPic);
28: //定義訊息 WM_Paint
29: Msg.Msg:= WM_Paint;
30: //對主畫面進行重繪
31: ClientWndProc(Msg); //這是由EEP自定的程序
32: end;
33: end;
34: end;
補充作法:
※在主畫面上放個image的元件,在切換圖片的事件上
1: fCmpPic:= Format('%s\%s.jpg',[GetPicPath, sCompany]);
2: if FileExists(fCmpPic)then
3: begin
4: img1.Visible:=False; //先隱藏
5: img1.Picture.LoadFromFile(fCmpPic);
6: img1.Visible:=True; //再打開 為了重繪畫面
7: end else img1.Picture.Graphic:= nil;