Pour ma part, je cherche deja a integrer une MDI dans une dll :/
J'ai mùon code source de l'exe qui creer une form de type fsMDIForm et une dans une dll qui est de la forme : fsMDIChild
Mon pb c'est que a la creation, j'ai une erreur de type "Fenetre non mdi non trouvé" ....
Ton code par rapport au miens est differents surtotu par l'utilisation de TScreen .... je connait pas ce paramettre.
Si t uveux on peux chercher ensemble ...
@++
-------------------------------
Réponse au message :
-------------------------------
> Personne n'a rencontré ce genre de problème avec les fenetres MDi et les DLL ???
>
> help please :)
>
> ..::=

DarkSky

=::..
>
>
> -------------------------------
> Réponse au message :
> -------------------------------
>
> > Salut a tous,
> >
> > j'ai créer un projet MDI avec Delphi 6 donc les fenetre MDi Filles sont dans une DLL.
> >
> > j'ai une erreur EConversionError a la place de l'affichage de l'info bulle Hint dans les composants de ma MDI Fille.
> >
> > Le problème est visiblement lié avec l'utilisation de TScreen ?
> >
> > Si quelqu'un a une idée, merci d'avance ......
> >
> > thx a tous pour ce forum.
> >
> > Voici le source des différents modules :
> >
> > -------------------------------------
> > Voici le code du programme MDI Parent
> > -------------------------------------
> > unit MAIN;
> >
> > interface
> >
> > uses Windows, SysUtils, Classes, Graphics, Forms, Controls, Menus,
> > StdCtrls, Dialogs, Buttons, Messages, ExtCtrls, ComCtrls, StdActns,
> > ActnList, ToolWin, ImgList;
> >
> > type
> > TMainForm = class(TForm)
> > MainMenu1: TMainMenu;
> > File1: TMenuItem;
> > FileNewItem: TMenuItem;
> > FileOpenItem: TMenuItem;
> > FileCloseItem: TMenuItem;
> > Window1: TMenuItem;
> > Help1: TMenuItem;
> > N1: TMenuItem;
> > FileExitItem: TMenuItem;
> > WindowCascadeItem: TMenuItem;
> > WindowTileItem: TMenuItem;
> > WindowArrangeItem: TMenuItem;
> > HelpAboutItem: TMenuItem;
> > OpenDialog: TOpenDialog;
> > FileSaveItem: TMenuItem;
> > FileSaveAsItem: TMenuItem;
> > Edit1: TMenuItem;
> > CutItem: TMenuItem;
> > CopyItem: TMenuItem;
> > PasteItem: TMenuItem;
> > WindowMinimizeItem: TMenuItem;
> > StatusBar: TStatusBar;
> > ActionList1: TActionList;
> > EditCut1: TEditCut;
> > EditCopy1: TEditCopy;
> > EditPaste1: TEditPaste;
> > FileNew1: TAction;
> > FileSave1: TAction;
> > FileExit1: TAction;
> > FileOpen1: TAction;
> > FileSaveAs1: TAction;
> > WindowCascade1: TWindowCascade;
> > WindowTileHorizontal1: TWindowTileHorizontal;
> > WindowArrangeAll1: TWindowArrange;
> > WindowMinimizeAll1: TWindowMinimizeAll;
> > HelpAbout1: TAction;
> > FileClose1: TWindowClose;
> > WindowTileVertical1: TWindowTileVertical;
> > WindowTileItem2: TMenuItem;
> > ToolBar2: TToolBar;
> > ToolButton1: TToolButton;
> > ToolButton2: TToolButton;
> > ToolButton3: TToolButton;
> > ToolButton4: TToolButton;
> > ToolButton5: TToolButton;
> > ToolButton6: TToolButton;
> > ToolButton9: TToolButton;
> > ToolButton7: TToolButton;
> > ToolButton8: TToolButton;
> > ToolButton10: TToolButton;
> > ToolButton11: TToolButton;
> > ImageList1: TImageList;
> > procedure FileNew1Execute(Sender: TObject);
> > procedure HelpAbout1Execute(Sender: TObject);
> > procedure FileExit1Execute(Sender: TObject);
> > procedure FormCreate(Sender: TObject);
> > procedure FormClose(Sender: TObject; var Action: TCloseAction);
> > private
> > { Déclarations privées }
> > public
> > { Déclarations publiques }
> > end;
> >
> > // Définition des prototypes pour les fonctions de la DLL
> > TDLLEntryPoint = procedure(dwReason: DWORD); stdcall;
> > TCreateMDIChildForm = procedure(App: TApplication; Scr: TScreen);
> > TDestroyMDIChildForm = procedure;
> >
> > var
> > MainForm: TMainForm;
> >
> > // Déclaration des fonctions exportés par la DLL
> > LibHandle : THandle;
> > DLLEntryPoint : TDLLEntryPoint;
> > CreateMDIChildForm : TCreateMDIChildForm;
> > DestroyMDIChildForm: TDestroyMDIChildForm;
> >
> >
> >
> >
> > implementation
> >
> > {$R *.dfm}
> >
> > uses about;
> >
> >
> > procedure TMainForm.FileNew1Execute(Sender: TObject);
> > begin
> > CreateMDIChildForm(Application, Screen);
> > end;
> >
> > procedure TMainForm.HelpAbout1Execute(Sender: TObject);
> > begin
> > AboutBox.ShowModal;
> > end;
> >
> > procedure TMainForm.FileExit1Execute(Sender: TObject);
> > begin
> > Close;
> > end;
> >
> > procedure TMainForm.FormCreate(Sender: TObject);
> > begin
> > if LibHandle <> 0 then
> > begin
> > ShowMessage('Library already loaded');
> > Exit;
> > end;
> > LibHandle := LoadLibrary('DLL.dll');
> > try
> > if LibHandle = 0 then
> > begin
> > raise Exception.Create('Unable to load DLL');
> > Exit;
> > end;
> > @DLLEntryPoint := GetProcAddress(LibHandle, 'DLLEntryPoint');
> > @CreateMDIChildForm := GetProcAddress(LibHandle, 'CreateMDIChildForm');
> > @DestroyMDIChildForm:= GetProcAddress(LibHandle, 'DestroyMDIChildForm');
> > except
> > FreeLibrary(LibHandle);
> > end;
> >
> > end;
> >
> > procedure TMainForm.FormClose(Sender: TObject; var Action: TCloseAction);
> > begin
> > @CreateMDIChildForm := nil;
> > @DestroyMDIChildForm:= nil;
> > if LibHandle = 0 then
> > begin
> > ShowMessage('Library already released');
> > Exit;
> > end;
> > //The two following procedures can be used to detach the dll
> > //FreeLibrary(LibHandle);
> > { or }
> > DLLEntryPoint(DLL_PROCESS_DETACH); //The procedure call can be used for VB and/or Delphi
> > LibHandle := 0;
> >
> > Action := caFree;
> > end;
> >
> > end.
> >
> > ------------------------
> > Voici le code de la DLL
> > ------------------------
> >
> > library Dll;
> >
> > uses
> > SysUtils,
> > Windows,
> > Forms,
> > Classes,
> > Unit1 in 'Unit1.pas' {Form1};
> >
> > var
> > DLLApp: TApplication;
> > DLLScr: TScreen;
> > DLLAppHandle: THandle;
> >
> >
> > {$R *.res}
> >
> > procedure RestoreAppAndScr;
> > begin
> > Screen := DLLScr;
> > Application := DLLApp;
> > end;
> >
> > procedure CreateMDIChildForm(App: TApplication; Scr: TScreen);
> > begin
> > // if not Assigned(Form1) then
> > // begin
> > Application := App;
> > //Assign Screen Object
> > if Assigned(Scr) then Screen := Scr;
> > //DLLForm2 := TDLLForm2.Create(Application);
> > Form1 := TForm1.Create(Application.MainForm);
> > Form1.Caption := 'MDI Child Form';
> > Form1.Show;
> > // end
> > // else
> > // begin
> > // Form1.Show;
> > // end;
> > end;
> >
> > procedure DestroyMDIChildForm;
> > begin
> > if Assigned(Form1) then
> > begin
> > Form1.Free;
> > end
> > else
> > begin
> > //ShowMessage('Form was already destroyed.');
> > end;
> > Form1 := nil;
> > RestoreAppAndScr;
> > end;
> >
> > //DLL Entry Point
> > //----------------
> > procedure DLLEntryPoint(dwReason: DWORD); stdcall; //register; //stdcall;
> > begin
> > case dwReason of
> > DLL_PROCESS_ATTACH: //1
> > begin
> > DLLAppHandle := Application.Handle;
> > DLLApp := Application;
> > DLLScr := Screen;
> > end;
> > DLL_PROCESS_DETACH: //3
> > begin
> > // Destroy des fenetres
> >
> > // Rend les handles au programme principal
> > RestoreAppAndScr;
> > Application.Handle := DLLAppHandle;
> > end;
> > DLL_THREAD_ATTACH : {ShowMessage('Thread Attach')}; //2
> > DLL_THREAD_DETACH : {ShowMessage('Thread Detach')}; //0
> > end;
> > end;
> >
> > exports
> > DLLEntryPoint, // Point d'entrée de la DLL
> > CreateMDIChildForm, // Création de la fenetre MDI
> > DestroyMDIChildForm; // Destruction de la fenetre MDI
> >
> > begin
> > //DLLEntryPoint is specifically a Win32 and C++ implementation
> > //DLLProc is a pointer variable from the SYSTEM Unit (automatically included)
> > //The SYSTEM Unit is responsible for executing code assinged to DLLEntryPoint
> > DLLProc := @DLLEntryPoint; //Assign the address of DLLEntryPoint to DLLProc
> > DLLEntryPoint(DLL_PROCESS_ATTACH); //Indicate that the DLL is attaching to the process
> > end.
> >
> > //In VB Call this to detach the DLL before the main process terminates
> > //DLLEntryPoint(DLL_PROCESS_ATTACH);
> >
> >
> > -------------------------------------------------
> > Voici le code de la fenetre MDI Fille Dans la DLL
> > -------------------------------------------------
> > unit Unit1;
> >
> > interface
> >
> > uses
> > Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
> > Dialogs, StdCtrls, Grids, AdvGrid;
> >
> > type
> > TForm1 = class(TForm)
> > Edit1: TEdit;
> > procedure FormDestroy(Sender: TObject);
> > procedure FormClose(Sender: TObject; var Action: TCloseAction);
> > private
> > { Déclarations privées }
> > public
> > { Déclarations publiques }
> > end;
> >
> > var
> > Form1: TForm1;
> >
> > implementation
> >
> > {$R *.dfm}
> >
> > procedure TForm1.FormDestroy(Sender: TObject);
> > begin
> > Form1 := nil;
> > end;
> >
> > procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
> > begin
> > //if Action := caFree; then you should nil the form variable
> > Action := caFree;
> > end;
> >
> > end.
> >
> >
> >
> > ..::=

DarkSky

=::..
>