unit U_GetDllForm; interface uses Windows,Messages,forms,OleCtnrs,DateUtils,SysUtils,ADODB; function GetDllForm(App:Tapplication; FormH:hwnd; FormID:integer; Language: integer; WinStyle:integer; GCode: Pchar; GName: Pchar; DataBase:Pchar;Title:PChar; Parameters1:PChar;Parameters2:PChar;Parameters3:PChar;Parameters4:PChar; Parameters5:PChar;Parameters6:PChar;Parameters7:PChar;Parameters8:PChar; Parameters9:PChar;Parameters10:PChar;DataBaseStr:PChar):hwnd;export;stdcall; function ConnData():Boolean; implementation uses U_DataLink,U_BaoGuanList ,U_BaoGuanListZXD ,U_BaoGuanXSList; var frmBaoGuanList,frmBaoGuanListGQX,frmBaoGuanListCXGQX,frmBaoGuanListZL:TfrmBaoGuanList; frmBaoGuanListHT,frmBaoGuanListFP,frmBaoGuanListZXD,frmBaoGuanListBGD:TfrmBaoGuanList; frmBaoGuanListSBYS,frmBaoGuanListHD,frmBaoGuanListSH,frmBaoGuanListDJ:TfrmBaoGuanList; ///////////////////////////////////////////////////////////////// // 功能说明:取Dll中得窗体 // // 参数说明:App>>调用应用程序; // // FormH>>调用窗口句柄 ; // // FormID>>窗口号; // // Language>>语言种类; // // WinStyle>>窗口类型; // ///////////////////////////////////////////////////////////////// function GetDllForm(App:Tapplication; FormH:hwnd; FormID:integer; Language: integer; WinStyle:integer; GCode: Pchar; GName: Pchar; DataBase:Pchar;Title:PChar; Parameters1:PChar;Parameters2:PChar;Parameters3:PChar;Parameters4:PChar; Parameters5:PChar;Parameters6:PChar;Parameters7:PChar;Parameters8:PChar; Parameters9:PChar;Parameters10:PChar; DataBaseStr:PChar):hwnd; var i: Integer; bFound:Boolean; mnewHandle: hwnd; mstyle: TFormStyle; // 0:子窗口; 1:普通窗口 mstate: TWindowState; mborderstyle: TFormBorderStyle; begin mNewHandle:=0; DName:=PChar(GName); DCode:=PChar(GCode); DdataBase:=DataBase; DTitCaption:=Title; DParameters1:=Parameters1; DParameters2:=Parameters2; DParameters3:=Parameters3; DParameters4:=Parameters4; DParameters5:=Parameters5; DParameters6:=Parameters6; DParameters7:=Parameters7; DParameters8:=Parameters8; DParameters9:=Parameters9; DParameters10:=Parameters10; MainApplication:=App; DCurHandle:=FormH; IsDelphiLanguage:= Language; Application:=TApplication(App); DCurHandle:=0; //赋值链接字符串 SetLength(server, 255); SetLength(dtbase, 255); SetLength(user, 255); SetLength(pswd, 255); server:='121.40.233.100,7781'; //192.168.1.113 //server:='.'; //192.168.1.113 dtbase:='XinFengData'; user:='sa'; //pswd:='rightsoft'; pswd:='rightsoft@123'; DConString := 'Provider=SQLOLEDB.1;Password='+pswd+';Persist Security Info=True;User ID=' +user+';Initial Catalog='+dtbase+';Data Source='+server; DConString:=DataBaseStr; //DName:='ADMIN'; //DParameters1:='高权限'; // 办公用品仓库 //DParameters2:=''; if not ConnData() then begin result:=0; exit; end; // 定义窗口类型 、状态 if WinStyle=0 then begin mstyle := fsMDIChild ; mstate := wsMaximized ; mborderstyle := bsSizeable; end else begin mstyle := fsNormal ; mstate := wsNormal ; mborderstyle := bsSizeable; end; //Title:='报关管理'; ///////////////////// //调用子模块窗口 case FormId of -1: //报关资料录入 begin bFound := FALSE; for i := (App.MainForm.MDIChildCount - 1) downto 0 do begin if App.MainForm.MDIChildren[i].Caption = '报关资料录入' then begin BringWindowToTop(frmBaoGuanList.Handle); bFound := TRUE; Break; end; end; if not bFound then //if frmBaoGuanList=nil then begin frmBaoGuanList:= TfrmBaoGuanList.Create(application.MainForm); with frmBaoGuanList do begin Title:='报关资料录入'; caption:=Trim(Title); FormStyle := mstyle ; windowState := mstate ; BorderStyle := mborderstyle; //show; end; end else frmBaoGuanList.BringToFront; //句柄 mNewHandle:=frmBaoGuanList.Handle; end ; -2: //报关资料录入(高权限) begin bFound := FALSE; for i := (App.MainForm.MDIChildCount - 1) downto 0 do begin if App.MainForm.MDIChildren[i].Caption = '报关资料录入(高权限)' then begin BringWindowToTop(frmBaoGuanListGQX.Handle); bFound := TRUE; Break; end; end; if not bFound then //if frmBaoGuanList=nil then begin frmBaoGuanListGQX:= TfrmBaoGuanList.Create(application.MainForm); with frmBaoGuanListGQX do begin Title:='报关资料录入(高权限)'; caption:=Trim(Title); FormStyle := mstyle ; windowState := mstate ; BorderStyle := mborderstyle; //show; end; end else frmBaoGuanListGQX.BringToFront; //句柄 mNewHandle:=frmBaoGuanListGQX.Handle; end ; -3: //报关资料核对 begin bFound := FALSE; for i := (App.MainForm.MDIChildCount - 1) downto 0 do begin if App.MainForm.MDIChildren[i].Caption = '报关资料核对' then begin BringWindowToTop(frmBaoGuanListHD.Handle); bFound := TRUE; Break; end; end; if not bFound then //if frmBaoGuanListSBYS=nil then begin frmBaoGuanListHD:= TfrmBaoGuanList.Create(application.MainForm); with frmBaoGuanListHD do begin Title:='报关资料核对'; caption:=Trim(Title); FormStyle := mstyle ; windowState := mstate ; BorderStyle := mborderstyle; //show; end; end else frmBaoGuanListHD.BringToFront; //句柄 mNewHandle:=frmBaoGuanListHD.Handle; end ; -4: //报关资料审核 begin bFound := FALSE; for i := (App.MainForm.MDIChildCount - 1) downto 0 do begin if App.MainForm.MDIChildren[i].Caption = '报关资料审核' then begin BringWindowToTop(frmBaoGuanListSH.Handle); bFound := TRUE; Break; end; end; if not bFound then //if frmBaoGuanListSBYS=nil then begin frmBaoGuanListSH:= TfrmBaoGuanList.Create(application.MainForm); with frmBaoGuanListSH do begin Title:='报关资料审核'; caption:=Trim(Title); FormStyle := mstyle ; windowState := mstate ; BorderStyle := mborderstyle; //show; end; end else frmBaoGuanListSH.BringToFront; //句柄 mNewHandle:=frmBaoGuanListSH.Handle; end ; -5: //报关资料查询(高权限) begin bFound := FALSE; for i := (App.MainForm.MDIChildCount - 1) downto 0 do begin if App.MainForm.MDIChildren[i].Caption = '报关资料查询(高权限)' then begin BringWindowToTop(frmBaoGuanListCXGQX.Handle); bFound := TRUE; Break; end; end; if not bFound then //if frmBaoGuanListBGZL=nil then begin frmBaoGuanListCXGQX:= TfrmBaoGuanList.Create(application.MainForm); with frmBaoGuanListCXGQX do begin Title:='报关资料查询(高权限)'; caption:=Trim(Title); FormStyle := mstyle ; windowState := mstate ; BorderStyle := mborderstyle; //show; end; end else frmBaoGuanListCXGQX.BringToFront; //句柄 mNewHandle:=frmBaoGuanListCXGQX.Handle; end ; -6: //报关销售资料 begin if frmBaoGuanXSList=nil then begin frmBaoGuanXSList:= TfrmBaoGuanXSList.Create(application.MainForm); with frmBaoGuanXSList do begin caption:=Trim(Title); FormStyle := mstyle ; windowState := mstate ; BorderStyle := mborderstyle; //show; end; end else frmBaoGuanXSList.BringToFront; //句柄 mNewHandle:=frmBaoGuanXSList.Handle; end ; 1: //报关管理(单机) begin bFound := FALSE; for i := (App.MainForm.MDIChildCount - 1) downto 0 do begin if App.MainForm.MDIChildren[i].Caption = '报关管理' then begin BringWindowToTop(frmBaoGuanListDJ.Handle); bFound := TRUE; Break; end; end; if not bFound then //if frmBaoGuanList=nil then begin frmBaoGuanListDJ:= TfrmBaoGuanList.Create(application.MainForm); with frmBaoGuanListDJ do begin Title:='报关管理'; caption:=Trim(Title); FormStyle := mstyle ; windowState := mstate ; BorderStyle := mborderstyle; //show; end; end else frmBaoGuanListDJ.BringToFront; //句柄 mNewHandle:=frmBaoGuanListDJ.Handle; end ; { 118: //报关资料打印查询 begin bFound := FALSE; for i := (App.MainForm.MDIChildCount - 1) downto 0 do begin if App.MainForm.MDIChildren[i].Caption = '报关资料打印查询' then begin BringWindowToTop(frmBaoGuanListZL.Handle); bFound := TRUE; Break; end; end; if not bFound then //if frmBaoGuanListBGZLCX=nil then begin frmBaoGuanListZL:= TfrmBaoGuanList.Create(application.MainForm); with frmBaoGuanListZL do begin caption:=Trim(Title); FormStyle := mstyle ; windowState := mstate ; BorderStyle := mborderstyle; //show; end; end else frmBaoGuanListZL.BringToFront; //句柄 mNewHandle:=frmBaoGuanListZL.Handle; end ; 119: //报关合同打印查询 begin bFound := FALSE; for i := (App.MainForm.MDIChildCount - 1) downto 0 do begin if App.MainForm.MDIChildren[i].Caption = '报关合同打印查询' then begin BringWindowToTop(frmBaoGuanListHT.Handle); bFound := TRUE; Break; end; end; if not bFound then // if frmBaoGuanListHT=nil then begin frmBaoGuanListHT:= TfrmBaoGuanList.Create(application.MainForm); with frmBaoGuanListHT do begin caption:=Trim(Title); FormStyle := mstyle ; windowState := mstate ; BorderStyle := mborderstyle; //show; end; end else frmBaoGuanListHT.BringToFront; //句柄 mNewHandle:=frmBaoGuanListHT.Handle; end ; 120: //报关发票打印查询 begin bFound := FALSE; for i := (App.MainForm.MDIChildCount - 1) downto 0 do begin if App.MainForm.MDIChildren[i].Caption = '报关发票打印查询' then begin BringWindowToTop(frmBaoGuanListFP.Handle); bFound := TRUE; Break; end; end; if not bFound then //if frmBaoGuanListFP=nil then begin frmBaoGuanListFP:= TfrmBaoGuanList.Create(application.MainForm); with frmBaoGuanListFP do begin caption:=Trim(Title); FormStyle := mstyle ; windowState := mstate ; BorderStyle := mborderstyle; //show; end; end else frmBaoGuanListFP.BringToFront; //句柄 mNewHandle:=frmBaoGuanListFP.Handle; end ; 121: //报关装箱单打印查询 begin bFound := FALSE; for i := (App.MainForm.MDIChildCount - 1) downto 0 do begin if App.MainForm.MDIChildren[i].Caption = '报关装箱单打印查询' then begin BringWindowToTop(frmBaoGuanListFP.Handle); bFound := TRUE; Break; end; end; if not bFound then // if frmBaoGuanListZXD=nil then begin frmBaoGuanListZXD:= TfrmBaoGuanList.Create(application.MainForm); with frmBaoGuanListZXD do begin caption:=Trim(Title); FormStyle := mstyle ; windowState := mstate ; BorderStyle := mborderstyle; //show; end; end else frmBaoGuanListZXD.BringToFront; //句柄 mNewHandle:=frmBaoGuanListZXD.Handle; end ; 122: //报关单打印查询 begin bFound := FALSE; for i := (App.MainForm.MDIChildCount - 1) downto 0 do begin if App.MainForm.MDIChildren[i].Caption = '报关单打印查询' then begin BringWindowToTop(frmBaoGuanListBGD.Handle); bFound := TRUE; Break; end; end; if not bFound then //if frmBaoGuanListBGD=nil then begin frmBaoGuanListBGD:= TfrmBaoGuanList.Create(application.MainForm); with frmBaoGuanListBGD do begin caption:=Trim(Title); FormStyle := mstyle ; windowState := mstate ; BorderStyle := mborderstyle; //show; end; end else frmBaoGuanListBGD.BringToFront; //句柄 mNewHandle:=frmBaoGuanListBGD.Handle; end ; 123: //申报要素打印查询 begin bFound := FALSE; for i := (App.MainForm.MDIChildCount - 1) downto 0 do begin if App.MainForm.MDIChildren[i].Caption = '申报要素打印查询' then begin BringWindowToTop(frmBaoGuanListSBYS.Handle); bFound := TRUE; Break; end; end; if not bFound then //if frmBaoGuanListSBYS=nil then begin frmBaoGuanListSBYS:= TfrmBaoGuanList.Create(application.MainForm); with frmBaoGuanListSBYS do begin caption:=Trim(Title); FormStyle := mstyle ; windowState := mstate ; BorderStyle := mborderstyle; //show; end; end else frmBaoGuanListSBYS.BringToFront; //句柄 mNewHandle:=frmBaoGuanListSBYS.Handle; end ; } end ; // end case Result:= mnewHandle; NewDllApp:=Application ; end; //=========================================================== //建立数据库连接池 //=========================================================== function ConnData():Boolean; begin if not Assigned(DataLink_DDMD) then DataLink_DDMD:=TDataLink_DDMD.Create(Application); Try with DataLink_DDMD.ADOLink do begin //if not Connected then begin Connected:=false; ConnectionString:=DConString; LoginPrompt:=false; Connected:=true; end; end; Result:=true; Except Result:=false; application.MessageBox('数据库连接失败!','错误',mb_Ok+ MB_ICONERROR); end; end; INITIALIZATION OldDllApp:= Application; FINALIZATION DataLink_DDMD.Free; Application := OldDllApp; end.