Home > Back-end >  Delphi7 fusion form of DLL cannot get focus, a great god
Delphi7 fusion form of DLL cannot get focus, a great god

Time:10-02

Form of DLL cannot get focus delphi7 fusion, a great god see my code is
Inside the DLL is written such
The function ShowDll (Parent: THandle;) : the HWND; Stdcall; Export;
The begin
Application. Handle:=the Parent;

If Form1=nil then
Form1:=TForm1. Create (Application);
Form1. ParentWindow:=the Parent;
Form1. Show;
Result:=Form1. Handle;
The end;
Host form is inside this call
DllFormHandle: THandle;
DllFormHandle:=ShowDll (Panel1. Handle);
Now can form integration into the host form, but the DLL is swollen form cannot get focus, the inside of the Edit couldn't input how to solve it?
I find information on the Internet http://www.360doc.com/content/12/0802/10/7873422_227797421.shtml
AppEvent is added to the host program control, and add the following code in its OnMessage event:
If IsDialogMessage (ExternMonitorHandle, Msg) then
Handled:=True;
But I can't find the AppEvent delphi7 inside control, a great god what's the solution? In addition to the control and not a little bit more simple solution?

CodePudding user response:

With Additional TAB of the 3 arrow is TApplicationEvents controls

CodePudding user response:

I joined the TApplicationEvents control DLL form still cannot receive focus, DLL form inside of the Edit control can't input this is how to return a responsibility?

CodePudding user response:

Is defined as a child form?

CodePudding user response:

Application of DLL to use exe application
 
Var
DLLApp: TApplication;
DLLScr: TScreen;

The function CreateForm (App: TApplication; Scr: TScreen) : HWND;
The begin
Application:=App;
Screen:=Scr;
Form1:=TForm1. Create (Application);
.
The end;

Procedure DLLRun (Reason: Integer);
The begin
If a tiny=DLL_PROCESS_DETACH then
The begin
Application:=DLLApp;
Screen:=DLLScr;
The end;
The end;

Exports
CreateForm;

The begin
DLLApp:=Application;
DLLScr:=Screen;
DLLProc:=@ DLLRun;

CodePudding user response:

We have done, send a demo to me?
[email protected]

CodePudding user response:

If the original poster can solve the notice a sound? I also have this several problems:
1, EXE form title bar is gray;
2, use the mouse to switch on the taskbar, although EXE form is pressed down, but not in advance;
3, some key mouse leave will not restore plane, such as speedbutton
4, DLL form hint cannot display;
A discussion!

CodePudding user response:

DLL code

The library DLLPRJ;

{Important note about DLL memory management: ShareMem must be the
The first unit in your library 's USES clause AND your project' s (select
The Project - the View Source) USES clause if your DLL exports any procedures or
Functions provides that pass strings as parameters or function results. This
Applies to all strings passed to and from your DLL - even those that
Are nested in records and classes. ShareMem is the interface unit to
The BORLNDMM. DLL Shared memory manager, which must be deployed along
With your DLL. To get the using BORLNDMM. DLL, pass the string information
Using PChar or ShortString parameters.}

USES the
SysUtils,
Classes,
Dockfrm in 'Dockfrm. Pas' {frmdock};

{$R *. Res}
Exports
ShowFrm CloseFrm;

The begin
End.
The unit Dockfrm;

Interface

USES the
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls ExtCtrls;

Procedure ShowFrm (sHand: THandle); Stdcall;
Procedure CloseFrm; Stdcall;
Type
Tfrmdock=class (TForm)
For: TButton;
Label1: TLabel;
Edit1: TEdit;
Procedure Button1Click (Sender: TObject);
Procedure FormClose (Sender: TObject; Var Action: TCloseAction);

Private
{Private declarations}
Public
{Public declarations}
The end;

Var
Frmdock: Tfrmdock;

Implementation

{$R *. DFM}
Procedure ShowFrm (sHand: THandle); Stdcall;
The begin
Application. Handle:=sHand;
If not Assigned (frmdock) then
The begin
Frmdock:=Tfrmdock. Create (Application);
Frmdock. ParentWindow:=sHand;
Frmdock. Show;
The end;
The end;

Procedure CloseFrm; Stdcall;
The begin
If Assigned (frmdock) then
FreeAndNil (frmdock);
The end;

Procedure Tfrmdock. Button1Click (Sender: TObject);
The begin
Showmessage (" fdsaf ");
The end;

Procedure Tfrmdock. FormClose (Sender: TObject; Var Action: TCloseAction);
The begin
Action:=CaFree;
Frmdock:=Nil;
The end;

End.


Call the form code
The unit callfrm;

Interface

USES the
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, ExtCtrls, Menus;

Procedure ShowFrm (sHandle: THandle); Stdcall; External 'DLLPRJ. DLL';
Procedure CloseFrm; Stdcall; External 'DLLPRJ. DLL';
//function func () : Integer; Stdcall; External '12345. DLL';

Type
Tfrmcall=class (TForm)
MainMenu1: TMainMenu;
Fdgs1: TMenuItem;
N1231: TMenuItem;
N2341: TMenuItem;
Panel1: TPanel;
Procedure FormClose (Sender: TObject; nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related