⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dll_shared.pas

📁 Form from DLL (Delphi source code)
💻 PAS
字号:
unit DLL_Shared;

interface

uses
   Windows, Forms, Dialogs;

var
   DLLApp: TApplication;
   DLLScr: TScreen;
   DLLAppHandle: THandle;

procedure ShowTestDllMessage;
procedure RestoreAppAndScr;
procedure DisplayModalForm2(App: TApplication);
procedure CreateModeLessForm2(App: TApplication);
procedure DestroyModeLessForm;
procedure CreateMDIChildForm2(App: TApplication; Scr: TScreen);
procedure DestroyMDIChildForm;

exports
    RestoreAppAndScr,
    ShowTestDllMessage,
    DisplayModalForm2,
    CreateModeLessForm2,
    DestroyModeLessForm,
    CreateMDIChildForm2,
    DestroyMDIChildForm;

implementation

uses
   FormDLL, FormDLL2;

procedure ShowTestDllMessage;
begin
  ShowMessage('Pr骲a鼁enet a DLL-b鮨...');
end;

procedure RestoreAppAndScr;
begin
  Screen := DLLScr;
  Application := DLLApp;
end;

procedure DestroyModeLessForm;
begin
  if Assigned(DLLModeLessForm) then
  begin
    DLLModeLessForm.Free;
  end
  else
  begin
    //ShowMessage('A Form m醨 t鰎鰈ve!');
  end;
  DLLModeLessForm := nil;
  RestoreAppAndScr;
end;

procedure DisplayModalForm2(App: TApplication);
var
  DLLModalForm: TDLLForm;
begin
  Application := App;
  DLLModalForm := TDLLForm.Create(Application);
  try
    DLLModalForm.Caption := 'Modal Form';
    DLLModalForm.ShowModal;
  finally
    DLLModalForm.Free;
    RestoreAppAndScr;
  end;
end;

procedure CreateModeLessForm2(App: TApplication);
begin
  DestroyModeLessForm;
  if not Assigned(DLLModeLessForm) then
  begin
    Application := App;
    DLLModeLessForm := TDLLForm.Create(Application);
    DLLModeLessForm.Caption := 'Modeless Form';
    DLLModeLessForm.Show;
  end
  else
  begin
    DLLModeLessForm.Show;
  end;
end;

procedure CreateMDIChildForm2(App: TApplication; Scr: TScreen);
begin
  if not Assigned(DLLForm2) then
  begin
    Application := App;
    if Assigned(Scr) then
      Screen := Scr;
    DLLForm2 := TDLLForm2.Create(Application.MainForm);
    DLLForm2.Caption := 'MDI Child Form';
    DLLForm2.Show;
  end
  else
  begin
    DLLForm2.Show;
  end;
end;

procedure DestroyMDIChildForm;
begin
  if Assigned(DLLForm2) then
  begin
    DLLForm2.Free;
  end
  else
  begin
    //ShowMessage('A Form m醨 t鰎鰈ve!');
  end;
  DLLForm2 := nil;
  RestoreAppAndScr;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -