unit U_GetDllForm; interface uses Windows, Messages, forms, OleCtnrs, DateUtils, SysUtils, ADODB, Dxcore, activex; 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_ClothSCList, U_ClothSCListAnPaiJiTaiAP, U_ClothSCDCGAnPai, U_ClothGMList, U_MJManageNewFDJJAP, U_JYOrderCDOne, U_DcgGzList, U_ClothTHList; ///////////////////////////////////////////////////////////////// // 功能说明:取Dll中得窗体 // // 参数说明:App>>调用应用程序; // // FormH>>调用窗口句柄 ; // // FormID>>窗口号; // // Language>>语言种类; // // WinStyle>>窗口类型; // ///////////////////////////////////////////////////////////////// var frmClothSCListLR, frmClothSCListSC1, frmClothSCListSC2, frmClothSCListCX: TfrmClothSCList; frmJYOrderCDOnePBGL, frmJYOrderCDOnePBCX: TfrmJYOrderCDOnePB; frmClothSCListAnPaiJiTaiAPGL1, frmClothSCListAnPaiJiTaiAPGL2, frmClothSCListAnPaiJiTaiAPCX: TfrmClothSCListAnPaiJiTaiAP; frmClothSCDCGAnPai1, frmClothSCDCGAnPai2: TfrmClothSCDCGAnPai; 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'; //server:='.'; pswd := 'rightsoft@123'; user := 'sa'; dtbase := 'hanglindata'; DConString := 'Provider=SQLOLEDB.1;Password=' + pswd + ';Persist Security Info=True;User ID=' + user + ';Initial Catalog=' + dtbase + ';Data Source=' + server; DConString := DataBaseStr; // DName := '谭必闷'; // DParameters1 := 'BS'; //DParameters3:='1'; 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; ///////////////////// //调用子模块窗口 case FormID of 101: //坯布生产计划单录入 begin bFound := FALSE; for i := (App.MainForm.MDIChildCount - 1) downto 0 do begin if App.MainForm.MDIChildren[i].Caption = '坯布生产计划单录入' then begin BringWindowToTop(frmClothSCListLR.Handle); bFound := TRUE; Break; end; end; if not bFound then begin frmClothSCListLR := TfrmClothSCList.Create(application.MainForm); with frmClothSCListLR do begin Title := '坯布生产计划单录入'; canshu1 := '录入'; caption := Trim(Title); FormStyle := mstyle; windowState := mstate; BorderStyle := mborderstyle; //show; end; end else frmClothSCListLR.BringToFront; //句柄 mnewHandle := frmClothSCListLR.Handle; end; 102: //坯布生产计划单查询 begin bFound := FALSE; for i := (App.MainForm.MDIChildCount - 1) downto 0 do begin if App.MainForm.MDIChildren[i].Caption = '坯布生产计划单查询' then begin BringWindowToTop(frmClothSCListCX.Handle); bFound := TRUE; Break; end; end; if not bFound then begin frmClothSCListCX := TfrmClothSCList.Create(application.MainForm); with frmClothSCListCX do begin Title := '坯布生产计划单查询'; canshu1 := '查询'; caption := Trim(Title); FormStyle := mstyle; windowState := mstate; BorderStyle := mborderstyle; //show; end; end else frmClothSCListCX.BringToFront; //句柄 mnewHandle := frmClothSCListCX.Handle; end; 201: //机台安排 begin bFound := FALSE; for i := (App.MainForm.MDIChildCount - 1) downto 0 do begin if App.MainForm.MDIChildren[i].Caption = '机台安排' then begin BringWindowToTop(frmClothSCListAnPaiJiTaiAPGL1.Handle); bFound := TRUE; Break; end; end; if not bFound then begin frmClothSCListAnPaiJiTaiAPGL1 := TfrmClothSCListAnPaiJiTaiAP.Create(application.MainForm); with frmClothSCListAnPaiJiTaiAPGL1 do begin Title := '机台安排'; caption := Trim(Title); FormStyle := mstyle; windowState := mstate; BorderStyle := mborderstyle; //show; end; end else frmClothSCListAnPaiJiTaiAPGL1.BringToFront; //句柄 mnewHandle := frmClothSCListAnPaiJiTaiAPGL1.Handle; end; 202: //机台安排查询 begin bFound := FALSE; for i := (App.MainForm.MDIChildCount - 1) downto 0 do begin if App.MainForm.MDIChildren[i].Caption = '机台安排查询' then begin BringWindowToTop(frmClothSCListAnPaiJiTaiAPCX.Handle); bFound := TRUE; Break; end; end; if not bFound then begin frmClothSCListAnPaiJiTaiAPCX := TfrmClothSCListAnPaiJiTaiAP.Create(application.MainForm); with frmClothSCListAnPaiJiTaiAPCX do begin Title := '机台安排查询'; caption := Trim(Title); FormStyle := mstyle; windowState := mstate; BorderStyle := mborderstyle; //show; end; end else frmClothSCListAnPaiJiTaiAPCX.BringToFront; //句柄 mnewHandle := frmClothSCListAnPaiJiTaiAPCX.Handle; end; 301: //布票打印 begin bFound := FALSE; for i := (App.MainForm.MDIChildCount - 1) downto 0 do begin if App.MainForm.MDIChildren[i].Caption = '布票打印' then begin BringWindowToTop(frmClothSCDCGAnPai1.Handle); bFound := TRUE; Break; end; end; if not bFound then begin frmClothSCDCGAnPai1 := TfrmClothSCDCGAnPai.Create(application.MainForm); with frmClothSCDCGAnPai1 do begin Title := '布票打印'; caption := Trim(Title); FormStyle := mstyle; windowState := mstate; BorderStyle := mborderstyle; // DParameters1:=YD; //show; end; end else frmClothSCDCGAnPai1.BringToFront; //句柄 mnewHandle := frmClothSCDCGAnPai1.Handle; end; 401: //手工挂码 begin if frmClothGMList = nil then begin frmClothGMList := TfrmClothGMList.Create(application.MainForm); with frmClothGMList do begin caption := Trim(Title); FormStyle := mstyle; windowState := mstate; BorderStyle := mborderstyle; //show; end; end else frmClothGMList.BringToFront; //句柄 mnewHandle := frmClothGMList.Handle; end; 411: //退货入库 begin if frmCloththList = nil then begin frmCloththList := TfrmClothTHList.Create(application.MainForm); with frmCloththList do begin caption := Trim(Title); FormStyle := mstyle; windowState := mstate; BorderStyle := mborderstyle; //show; end; end else frmCloththList.BringToFront; //句柄 mnewHandle := frmCloththList.Handle; end; 402: // 坯布检验 begin if frmMJManageNewFDJJAP = nil then begin frmMJManageNewFDJJAP := TfrmMJManageNewFDJJAP.Create(application.MainForm); with frmMJManageNewFDJJAP do begin caption := Trim(Title); FormStyle := mstyle; windowState := mstate; BorderStyle := mborderstyle; //show; end; end else frmMJManageNewFDJJAP.BringToFront; //句柄 mnewHandle := frmMJManageNewFDJJAP.Handle; end; 501: //检验信息管理 begin bFound := FALSE; for i := (App.MainForm.MDIChildCount - 1) downto 0 do begin if App.MainForm.MDIChildren[i].Caption = '检验信息管理' then begin BringWindowToTop(frmJYOrderCDOnePBGL.Handle); bFound := TRUE; Break; end; end; if not bFound then //if frmBaoGuanListBGZL=nil then begin frmJYOrderCDOnePBGL := TfrmJYOrderCDOnePB.Create(application.MainForm); with frmJYOrderCDOnePBGL do begin Title := '检验信息管理'; caption := Trim(Title); FormStyle := mstyle; windowState := mstate; BorderStyle := mborderstyle; //show; end; end else frmJYOrderCDOnePBGL.BringToFront; //句柄 mnewHandle := frmJYOrderCDOnePBGL.Handle; end; 502: //检验信息查询 begin bFound := FALSE; for i := (App.MainForm.MDIChildCount - 1) downto 0 do begin if App.MainForm.MDIChildren[i].Caption = '检验信息查询' then begin BringWindowToTop(frmJYOrderCDOnePBCX.Handle); bFound := TRUE; Break; end; end; if not bFound then //if frmBaoGuanListBGZL=nil then begin frmJYOrderCDOnePBCX := TfrmJYOrderCDOnePB.Create(application.MainForm); with frmJYOrderCDOnePBCX do begin Title := '检验信息查询'; caption := Trim(Title); FormStyle := mstyle; windowState := mstate; BorderStyle := mborderstyle; //show; end; end else frmJYOrderCDOnePBCX.BringToFront; //句柄 mnewHandle := frmJYOrderCDOnePBCX.Handle; end; 601: //次布报告 begin if frmDcgGzList = nil then begin frmDcgGzList := TfrmDcgGzList.Create(application.MainForm); with frmDcgGzList do begin caption := Trim(Title); FormStyle := mstyle; windowState := mstate; BorderStyle := mborderstyle; //show; end; end else frmDcgGzList.BringToFront; //句柄 mnewHandle := frmDcgGzList.Handle; end; end; Result := mnewHandle; // NewDllApp := Application; end; //=========================================================== //建立数据库连接池 //=========================================================== function ConnData(): Boolean; begin if not Assigned(DataLink_WeavingSchedule) then DataLink_WeavingSchedule := TDataLink_WeavingSchedule.Create(Application); try with DataLink_WeavingSchedule.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 CoInitialize(nil); dxUnitsLoader.Initialize; finalization DataLink_WeavingSchedule.Free; application := NewDllApp; dxUnitsLoader.Finalize; end.