|
||||||
| Pascal/Delphi Forum for discussing Borland Delphi and Pascal coding techniques, tips and tricks. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
Well I figured this out. Let me guide you through the process, it is very simple but it might be tricky so follow me lead and don't get lost!
![]() First we want to create a new application. The mother application. - Click New -> Application Now that you have your application created, you can create the form you would like to include in your DLL. Don't worry, it will not be compiled within the application. - Click New -> Form For your application to not consume more memory we need to destroy the form when we close it. So we just add to the onClose event of the form the following code: Code:
Action := caFree; - Click New -> DLL Wizard or whatever it shows for you. In the uses, you have have to add the unit you want to include in your resource (The fom you want to use) In this case the unit we created is named Unit2, so we write just below the uses Code:
Unit2 in 'Unit2.pas' {Form2};
This is how your code should look like in the uses: Code:
uses
SysUtils,
Classes,
Unit2 in 'Unit2.pas' {Form2};
Now let's create two procedures, one to show the form and another one to show the form modal. You can add as many procedure as you want, I will just add 2 to give you an idea. Let's create procedure one: Code:
procedure ShowDllForm;stdcall; begin Form2 :=TForm2.Create(nil); Form2.Show; end; Code:
function ShowDllFormModal:integer;stdcall; begin Form2 :=TForm2.Create(nil); Result := Form2.ShowModal; end; Code:
Exports ShowDllForm, ShowDllFormModal; Click Project -> Build Now let's go into our actual application. You need to add the following code just above Var Code:
procedure ShowForm;stdcall;external 'Project2.dll' name 'ShowDllForm'; function ShowFormModal:integer;stdcall;external 'Project2.dll' name 'ShowDllFormModal'; Now let's create 2 buttons to call this procedures. Button Show: Code:
ShowForm Code:
ShowFormModal Click Project -> Build And that's it! You have created a resource dll. This saves resources and it reduces your application memory usage and file size too. Happy Coding! |
| Sponsored Links |
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| VB 6.0: Tutorial, How to Make Glass2K!! | TcM | VB Tutorials | 12 | 09-28-2008 12:53 PM |
| VB 6.0: Tutorial, How to make a GIF in your application | TcM | VB Tutorials | 17 | 07-01-2008 04:26 PM |
| How to make and use a library | twitch | C Tutorials | 0 | 06-13-2007 05:32 AM |
| How to make Dumplings | ahsan16 | The Lounge | 2 | 01-11-2007 11:55 PM |
| WingedPanther | ........ | 2753.6 |
| Xav | ........ | 2704 |
| Brandon W | ........ | 1702.32 |
| John | ........ | 1207.73 |
| marwex89 | ........ | 1175.24 |
| morefood2001 | ........ | 966.05 |
| dcs | ........ | 655.75 |
| Steve.L | ........ | 475.59 |
| orjan | ........ | 418.58 |
| Aereshaa | ........ | 383.54 |