Solved

DLL with a form and result

Posted on 2006-06-19
9
172 Views
Last Modified: 2010-04-05
I need a skeleton DLL that shows a form with a Memo, checkbox and two buttons.
When the form is closed, I need the DLL to return the value of the checkbox
(0 for unchecked, 1 for checked). This is for a EULA dialog with a do not show again checkbox.

I'd like to load the DLL and then call a function like ShowEULA and then have the result of the
checkbox returned, If the user clicks button2, I'd like a result of 2 returned.
0
Comment
Question by:EddieShipman
  • 6
  • 3
9 Comments
 
LVL 10

Expert Comment

by:atul_parmar
ID: 16935154
Hi,

The dll will look like the following.

library EULA;

uses
  SysUtils,
  Classes,
  Unit1 in 'Unit1.pas' {Form1}; // This is your form what contains memo, checkbox, button etc.

{$R *.res}

function ShowEULA : boolean;
begin
  with TForm1.Create(nil) do
  begin
    try
      ShowModal;
      Result := CheckBox1.Checked;
    finally
      Free;
    end;
  end;
end;

exports
  ShowEULA;

begin
end.
0
 
LVL 10

Accepted Solution

by:
atul_parmar earned 500 total points
ID: 16935216
Sorry, you need the result to be 0, 1 and 2. So, I expect that Button1 will set the ModalResult to mrOk and Button2 will brCancel.

function ShowEULA : Integer;
begin
  with TForm1.Create(nil) do
  begin
    try
      if ShowModal = mrOk then
      begin
        if CheckBox1.Checked then Result := 1 else Result := 0;
      end
      else // for 2nd button
         Result := 2;
    finally
      Free;
    end;
  end;
end;
0
 
LVL 26

Author Comment

by:EddieShipman
ID: 16935235
I was going to accept that as answer but you only return one value.
I need a 0 if unchecked, 1 if checked, and 2 if button2 was clicked.
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 26

Author Comment

by:EddieShipman
ID: 16935237
oh, didn't see your second post...
0
 
LVL 26

Author Comment

by:EddieShipman
ID: 16935255
Now do I use it like this:

LoadLibrary(EULA)
case ShowEULA of
0: do this
1: do this
2: do this
end;
ReleaseLibrary(EULA);

0
 
LVL 26

Author Comment

by:EddieShipman
ID: 16935258
I mean FreeLIbrary(EULA);
0
 
LVL 26

Author Comment

by:EddieShipman
ID: 16935327
Ok, got it:

type
   TEULAFunc = function: integer; stdcall;

procedure TForm1.Button1Click(Sender: TObject);
var
  hMod: HMODULE;
  FShowEULAFunc: TEULAFunc;
begin
  hMod := LoadLibrary('C:\Projects\EULA.dll');
  try
    @FShowEULAFunc:=GetProcAddress(hMod, 'ShowEULA');
    case FShowEULAFunc of
    0: ShowMessage('0');
    1: ShowMessage('1');
    2: ShowMessage('2');
    end;
  finally
    FreeLibrary(hMod);
  end;
end;
0
 
LVL 10

Expert Comment

by:atul_parmar
ID: 16935350
Yep.

I am moving mate, see you next day.
0
 
LVL 26

Author Comment

by:EddieShipman
ID: 16935844
Thanks for the help.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question