Delphi DLL form Encapsulation

Source: Internet
Author: User
1. Create form => fromtest. Pas {fromtest. DFM}

VaR
Frmdll: tfrmdll;
Procedure synapp (APP: thandle); stdcall;
Procedure showform; stdcall;


Implementation
Uses math, F2;
{$ R * . DFM}

Procedure synapp (APP: thandle); stdcall;
Begin
Application. Handle: = APP;
End ;

Procedure showform; stdcall;
Begin
Try
Frmdll: = Tfrmdll. Create (application );
Finally
Freeandnil (frmdll );
End ;
End ;

2. Create DLL wizard => formdll. DPRLibrary formdll;

Uses
Sysutils,
Classes,
Forms,
Formtest in'Formtest. pa' {frmdll },

{$ R*. Res}
Exports
Synapp, showform;

Begin
End.

Compile formdll. DPR to generate formdll. dll

3. InProgramMedium

VaR
Form1: tform1;
Procedure synapp (APP: thandle); stdcall; external ' Formdll. dll ';
Procedure showform; stdcall; external ' Formdll. dll ';

Implementation

{$ R * . DFM}

Procedure tform1.button1click (Sender: tobject );
Begin
Synapp (application. Handle );
Showform;
End ;

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.