unit U_ModulePromptList; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, ComCtrls, ToolWin, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData, ADODB, cxGridCustomPopupMenu, cxGridPopupMenu, cxGridLevel, cxClasses, cxControls, cxGridCustomView, cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxGrid, DBClient, cxCalendar, cxButtonEdit, cxSplitter, RM_Common, RM_Class, RM_e_Xls, RM_Dataset, RM_System, RM_GridReport, cxTextEdit, cxPC; type TfrmModulePromptList = class(TForm) ToolBar1: TToolBar; TBRafresh: TToolButton; TBClose: TToolButton; Panel1: TPanel; cxGridPopupMenu1: TcxGridPopupMenu; ADOQueryCmd: TADOQuery; ADOQueryMain: TADOQuery; ADOQueryTemp: TADOQuery; DataSource1: TDataSource; Order_Main: TClientDataSet; RM1: TRMGridReport; RMDBMain: TRMDBDataSet; RMXLSExport1: TRMXLSExport; CDS_PRT: TClientDataSet; cxGridPopupMenu2: TcxGridPopupMenu; cxGrid1: TcxGrid; Tv1: TcxGridDBTableView; v1Column5: TcxGridDBColumn; cxGrid1Level1: TcxGridLevel; Label1: TLabel; Label2: TLabel; Label3: TLabel; Label4: TLabel; Label5: TLabel; Label6: TLabel; Label7: TLabel; Label8: TLabel; Label9: TLabel; Label10: TLabel; Label11: TLabel; Label12: TLabel; ModuleNote: TEdit; Label13: TLabel; procedure FormDestroy(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure TBCloseClick(Sender: TObject); procedure TBRafreshClick(Sender: TObject); procedure FormShow(Sender: TObject); procedure cxPageControl1Change(Sender: TObject); procedure FormCreate(Sender: TObject); procedure Tv1CellDblClick(Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean); procedure ModuleNoteChange(Sender: TObject); private FormID,FormType:Integer; canshu1,canshu2:string; formFile,FormPara,Formname,FFormPara:string; FormPara1,FormPara2,FormPara3,FormPara4,FormPara5:string; FormPara6,FormPara7,FormPara8,FormPara9,FormPara10:string; procedure InitGrid(); procedure InitForm(); procedure InitDllEvt(FromFile:String;FormID:Integer;Para:String;FormType:Integer; Title: String; Def1: String; Def2: String; Def3: String; Def4: String; Def5: String; Def6: String; Def7: String; Def8: String; Def9: String; Def10: string); { Private declarations } public { Public declarations } userID,username,ADOConnString:string; end; var frmModulePromptList: TfrmModulePromptList; implementation uses U_DataLink,U_RTFun; type TMyF = function( App: TApplication; //主应用程序 (对Delphi而言) FormH: HWND; //创建窗口的父窗口句柄 (对PB而言) FormID: Integer; //要调用dll中功能窗体的Id号; 如果只有一个功能窗口,FormID默认为0 Language: Integer; //0=Delphi; 1=PB WinStyle: Integer; //0=子窗口; 1:普通窗口 (PB中都为普通窗口) UID: PChar; //用户Id UName: PChar; //用户名 Para: PChar; Title: PChar; Defstr1: PChar; Defstr2: PChar; Defstr3: PChar; Defstr4: PChar; Defstr5: PChar; Defstr6: PChar; Defstr7: PChar; Defstr8: PChar; Defstr9: PChar; Defstr10: PChar; Datalink: PChar ): HWND; stdcall; var TP: FARPROC; Tf: TMyF; {$R *.dfm} procedure TfrmModulePromptList.FormDestroy(Sender: TObject); begin frmModulePromptList:=nil; end; procedure TfrmModulePromptList.FormClose(Sender: TObject; var Action: TCloseAction); begin Action:=caFree; end; procedure TfrmModulePromptList.TBCloseClick(Sender: TObject); begin Close; WriteCxGrid('工作列表',Tv1,'我的管家'); end; procedure TfrmModulePromptList.InitGrid(); begin try ADOQueryMain.DisableControls; with ADOQueryMain do begin Close; sql.Clear; SQL.Add(' exec P_Chk_Tishi :DName,:DCode'); Parameters.ParamByName('DName').Value:=Trim(DName); Parameters.ParamByName('DCode').Value:=Trim(DCode); ExecSQL; Open; end; SCreateCDS(ADOQueryMain,Order_Main); SInitCDSData(ADOQueryMain,Order_Main); finally ADOQueryMain.EnableControls; end; end; procedure TfrmModulePromptList.InitForm(); begin FFormPara:=Trim(DConString); ReadCxGrid('工作列表',Tv1,'我的管家'); InitGrid(); end; procedure TfrmModulePromptList.TBRafreshClick(Sender: TObject); begin InitGrid(); if ADOQueryMain.Active=False then Exit; SDofilter(ADOQueryMain,SGetFilters(Panel1,1,2)); SCreateCDS(ADOQueryMain,Order_Main); SInitCDSData(ADOQueryMain,Order_Main); end; procedure TfrmModulePromptList.FormShow(Sender: TObject); begin InitForm(); end; procedure TfrmModulePromptList.cxPageControl1Change(Sender: TObject); begin InitGrid(); end; procedure TfrmModulePromptList.FormCreate(Sender: TObject); begin canshu1:=Trim(DParameters1); canshu2:=Trim(DParameters2); end; procedure TfrmModulePromptList.InitDllEvt(FromFile:String;FormID:Integer;Para:String;FormType:Integer; Title: String; Def1: String; Def2: String; Def3: String; Def4: String; Def5: String; Def6: String; Def7: String; Def8: String; Def9: String; Def10: string); var Th: HMODULE; begin Th := LoadLibrary(PChar(FromFile)); if Th > 0 then begin TP := GetProcAddress(Th, 'GetDllForm'); if TP <> nil then begin Tf := TMyF(Tp); Tf(Application, 0, FormID, 0, FormType, PChar(DCode), PChar(DName), PChar(Para), PChar(Title), PChar(Def1), PChar(Def2),PChar(Def3),PChar(Def4),PChar(Def5), PChar(Def6),PChar(Def7),PChar(Def8),PChar(Def9),PChar(Def10), pchar(FFormPara)); end; end else begin Application.MessageBox(PChar('打不开文件' + FromFile + '!'), '错误', MB_ICONERROR); end; end; procedure TfrmModulePromptList.Tv1CellDblClick( Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean); begin { with ADOQueryTemp do begin Close; sql.Clear; sql.Add('select * from SY_ModuleSub where ModuleId='''+Trim(Order_Main.fieldbyname('ModuleId').AsString)+''''); sql.Add(' and ModuleSubId='''+Trim(Order_Main.fieldbyname('ModuleSubId').AsString)+''''); Open; end; //FormID,FormType:Integer; // formFile,FormPara,Formname:string; // FormPara1,FormPara2,FormPara3,FormPara4,FormPara5:string; //FormPara6,FormPara7,FormPara8,FormPara9,FormPara10:string; formFile:=Trim(ADOQueryTemp.fieldbyname('FormFile').AsString); FormID:=ADOQueryTemp.fieldbyname('FormID').AsInteger; FormType:=ADOQueryTemp.fieldbyname('FormType').AsInteger; Formname:=Trim(ADOQueryTemp.fieldbyname('Formname').AsString); FormPara:=Trim(ADOQueryTemp.fieldbyname('FormPara').AsString); // ShowMessage(FormPara); FormPara1:=Trim(ADOQueryTemp.fieldbyname('FormPara1').AsString); FormPara2:=Trim(ADOQueryTemp.fieldbyname('FormPara2').AsString); FormPara3:=Trim(ADOQueryTemp.fieldbyname('FormPara3').AsString); FormPara4:=Trim(ADOQueryTemp.fieldbyname('FormPara4').AsString); FormPara5:=Trim(ADOQueryTemp.fieldbyname('FormPara5').AsString); FormPara6:=Trim(ADOQueryTemp.fieldbyname('FormPara6').AsString); FormPara7:=Trim(ADOQueryTemp.fieldbyname('FormPara7').AsString); FormPara8:=Trim(ADOQueryTemp.fieldbyname('FormPara8').AsString); FormPara9:=Trim(ADOQueryTemp.fieldbyname('FormPara9').AsString); FormPara10:=Trim(ADOQueryTemp.fieldbyname('FormPara10').AsString); InitDllEvt(formFile,FormID,FormPara,FormType,Formname,FormPara1,FormPara2, FormPara3,FormPara4,FormPara5,FormPara6,FormPara7,FormPara8, FormPara9,FormPara10); } end; procedure TfrmModulePromptList.ModuleNoteChange(Sender: TObject); begin if ADOQueryMain.Active=False then Exit; SDofilter(ADOQueryMain,SGetFilters(Panel1,1,2)); SCreateCDS(ADOQueryMain,Order_Main); SInitCDSData(ADOQueryMain,Order_Main); end; end.