M
mos
Unregistered / Unconfirmed
GUEST, unregistred user!
1:MDI主窗体用了VCLSkin皮肤控件2:MDI调用DLL中的子窗体也成功具体的代码如下LL的代码:library SysForm;uses SysUtils, Classes, Forms, ADODB, windows, WinSkinData, SysDllUnit in 'SysDllUnit.pas', F_Personnel in 'F_Personnel.pas' {Form_Personnel};{$R *.res}function ShowForm(App : TApplication; conn : String; CallProc : Pointer; CallID : Integer; parentform : TForm; ChildName : String):Longint;stdcall;begin Result :=-1; Application := App; @FreeProc := CallProc; ProcID := CallID; Tmp_SysConn :=conn; MDIForm :=parentform; if ChildName='Form_Personnel' then begin App.CreateForm(TForm_Personnel,Form_Personnel); Result :=Longint(Form_Personnel); Form_Personnel.Show; Form_Personnel.BringToFront; end;end;function CloseForm(ChildName:String): LongInt; StdCall;begin if ChildName='Form_Personnel' then begin if assigned(Form_Personnel) then begin Form_Personnel.Close; end; end; Result := 0;end;function ActiveForm(ChildName:String):LongInt;StdCall;begin if ChildName='Form_Personnel' then begin if assigned(Form_Personnel) then begin Form_Personnel.BringToFront; Form_Personnel.SetFocus; end; end; Result := 0;end;exports ShowForm, CloseForm, ActiveForm;procedure ExitDLL(Reason: Integer);begin if Reason = DLL_PROCESS_DETACH then begin Application := DllApp; end;end; begin DllApp:=Application; DLLProc:=@ExitDLL;end.================================================================================MDI窗体的代码如下:unit ufrmMain;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Menus, jpeg, ExtCtrls, ComCtrls, DB, ADODB, WinSkinData, StdCtrls;const WM_MyDLL = WM_APP+20;type TShowForm = function (App : TApplication; conn : String; CallProc : Pointer; CallID : Integer; parentform : TForm; ChildName : String):Longint;stdcall; TCloseForm = function(ChildName:String) : LongInt; StdCall; TActiveForm = function(Childname:String) : LongInt; StdCall; EDlllOadError = class(Exception); TfrmMain = class(TForm) MainMenu1: TMainMenu; N1: TMenuItem; N2: TMenuItem; N3: TMenuItem; N4: TMenuItem; frm11: TMenuItem; N5: TMenuItem; N6: TMenuItem; N7: TMenuItem; SBar: TStatusBar; ADOConnection1: TADOConnection; SkinData1: TSkinData; Edit1: TEdit; procedure N4Click(Sender: TObject); procedure frm11Click(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); private DllHandle : THandle; ShowForm : TShowForm; CloseForm : TCloseForm; ActiveForm:TActiveForm; procedure CallPostMessage(ID:Integer); procedure ReceFreeMSG(var ms: tMessage);message WM_MyDLL; { Private declarations } public { Public declarations } end;var frmMain: TfrmMain;implementation{$R *.dfm}procedure CallBackProc(ID:Integer); stdcall;begin frmMain.CallPostMessage(ID);end;procedure TfrmMain.N4Click(Sender: TObject);begin Close;end;procedure TfrmMain.frm11Click(Sender: TObject);var LibHandle : Thandle; ProcAddr : FarProc;begin if DllHandle = 0 then begin try LibHandle := LoadLibrary(PChar(extractfilepath(application.ExeName)+'SysForm.dll')); if LibHandle = 0 then raise EDLLLoadError.Create('不能载入'+extractfilepath(application.ExeName)+'Dll.dll 文件!'); except end; if LibHandle <> 0 then begin DllHandle := LibHandle; ProcAddr := GetProcAddress(LibHandle, 'ShowForm'); ShowForm := ProcAddr; ProcAddr := GetProcAddress(LibHandle, 'CloseForm'); CloseForm := ProcAddr; ProcAddr := GetProcAddress(LibHandle, 'ActiveForm'); ActiveForm := ProcAddr; try if Assigned(ShowForm) then begin ShowForm(Application,ADOConnection1.ConnectionString,@CallBackProc,1,FrmMain,'Form_Personnel'); end; except FreeLibrary(libHandle); end; end; end else begin if Assigned(ActiveForm) then begin ActiveForm('Form_Personnel'); end; end;end;procedure TfrmMain.CallPostMessage(ID: Integer);begin PostMessage(Self.Handle,WM_MyDLL,ID, 0);end;procedure TfrmMain.ReceFreeMSG(var ms: tMessage);var FormID:integer;begin if (ms.Msg = WM_MyDLL) then begin begin FormID:=integer(ms.WParam); try finally if FormID = 1 then begin if DllHandle<>0 then FreeLibrary(DllHandle); DllHandle:=0; end else end; end; end;end;procedure TfrmMain.FormClose(Sender: TObject; var Action: TCloseAction);begin if DllHandle <> 0 then begin CloseForm('Form_Personnel'); end;end;end.================================================================================注:Form_Personnel是子窗体的名称现在我需要问的是:我用VCLSkin控件为MDI主窗体加上皮肤(MDI主窗体的确也有皮肤的效果),可以为什么我调用了DLL中的子窗体,而子窗体没有MDI主窗体的皮肤效果?要如何解决!最好是有代码!