begin process at 2010 02 10 13:47:47
  Trouver un code source :
 
dans
 
Accueil > Forum > 

Archive Delphi

 > 

Archives

 > 

J'AI BESOIN D'AIDE !!!! :O

 > 

Problème Econversion Error lors de l'affichage d'une info bulle dans une fenetre MDIChild dans une DLL


Derniers messages déposésPoser une question dans le forum ou lancer une discussion

Problème Econversion Error lors de l'affichage d'une info bulle dans une fenetre MDIChild dans une DLL

mardi 4 février 2003 à 15:34:22 | Problème Econversion Error lors de l'affichage d'une info bulle dans une fenetre MDIChild dans une DLL

DarkSky

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 =::..
dimanche 9 février 2003 à 10:29:14 | Re : Problème Econversion Error lors de l'affichage d'une info bulle dans une fenetre MDIChild dans une DLL

DarkSky

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 =::..
lundi 16 juin 2003 à 20:27:11 | Re : Problème Econversion Error lors de l'affichage d'une info bulle dans une fenetre MDIChild dans une DLL

Clorish

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 =::..
>


Cette discussion est classée dans : end, dll, procedure, begin, tmenuitem


Répondre à ce message

Sujets en rapport avec ce message

thread & dll -> Exception [ par WSTBoss ] Bonjour à tous,j'ai une dll qui contient un thread, tout ce passe bien le thread marche comme il faut mais cependant lors du dechargement de la dll pa Classe TThread dans composant, liaison entre deux instances ? [ par Bacterius ] Bonjour ! Alors voilà un problème - j'essaye de faire un timer très précis : malheureusement celui-ci a besoin d'un thread pour fonctionner ! Je cherc Gestion de sa trayIcone [ par Michel34 ] Salut a toutes et tous , voila en premier je met le code et ensuite je vous donne mon soucis.UNIT UMain; INTERFACE USES  Windows,  Messages,  SysU Problème de transparence d'un contrôle [ par ThWilliam ] Bonjour à tous. J'écris un composant transparent dérivé de TCustomControl. Je ne peux pas le dériver de TGraphicControl, car j'ai besoin d'un contrôl TDateTime dans un StringGrid [ par notrica ] Salut,j'ai  placé un TDateTime dans un StringGrid  pour me permettre de selectionner la date à saisir. La date est séléctionnée sans problème, mais lo Problème de control dans un composant hérité de TScrollBox [ par Francky23012301 ] Salut à tous,Je suis entrain de réaliser un composant. J'ai fais des tests préalable et au moment de son élaboration voila que je suis confronté à un résolution sudoku backtrack [ par zwyx ] Bonjour à tous, Pour ceux qui aiment bien se creuser la tête sur de l'algorithmie... J'ai écrit un code permettant de résoude une grille de sudoku ré Opinion sur un composant TTreePanel [ par Francky23012301 ] Salut à tous,Ca commence à etre de notoriété internationale : Francky et le Design, ca fait deux .Alors quitte à faire un truc autant faire un truc sy pilotage ouverture/fermeture d'une barrière de sécurité pour boitier TC/USB16IO [ par Wiska ] Bonjour, Avant tout, voici la description de ce fameux boitier: "Le module TC/USB-16IO est un module d'interface pc, comportant 8 entrées logiques iso Spin edit [ par watrem ] bonjour , certainement suite a une mauvaise manip j'ai une erreur dans le "source" du spin edit , j'ai reinstaller delphi et l'erreur est toujours pre


Nos sponsors


Sondage...

Comparez les prix


HTC Magic

Entre 429€ et 429€

CalendriCode

Février 2010
LMMJVSD
1234567
891011121314
15161718192021
22232425262728

Consulter la suite du CalendriCode

 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 1,778 sec (4)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales