View the Form of a DLL in Delphi DX10

Asked

Viewed 778 times

1

I have the following situation: I have a project, which calls a DLL and this has a form. Until that moment 'OK', performs the call and displays the form, only one thing that bothers me visually is that in the system tray is two applications open, one from the project and the other from the DLL.

Opening the form in ShowModal, and squeezing Ctrl+tab for the project, it gives focus but can’t access anything.

My question is how to leave only in an application in the system’s flag.

Coding of the DLL

library ChamadaForm;

uses
  SysUtils,
  Forms,
  Classes;

{$R *.res}

procedure exibir; stdcall;
var
 frm : TForm;
begin
  frm := TForm.Create(nil);
  frm.ShowModal;
  freeAndNil(frm);
end;

exports
  exibir;
begin
end.

Call of the DLL in the Project.

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;


implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
 exibir : procedure; stdcall;
 handle: THandle;
begin
  handle := LoadLibrary('ChamadaForm.dll');
  if Handle <> 0 then
  begin
    @exibir := GetProcAddress (Handle, 'exibir');
    if @exibir <> nil then
      exibir;
    FreeLibrary (Handle);
  end;
end;

end.

1 answer

2


Whether you run a ShowModal you should remember that we are running a second application!

There are other forms of Hookar the application within the other!

But in the Delphi for this case can be quite simple. Access the project source (the DLL in the case) and add this line before the Application.Run.

Application.MainFormOnTaskBar := False;

Note that the command name itself is quite intuitive!

  • Hello @Junior, in this case I believe that it would not work because it does not have an appication.run a DLL is called in the main app.

  • Press Ctrl+Alt+F11 will be presented the Project Manager, then press on it Ctrl+V (shortcut to View Source).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.