?
Solved

DLL with a form and result

Posted on 2006-06-19
9
Medium Priority
?
178 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses
Course of the Month11 days, 1 hour left to enroll

770 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