Solved

Delphi Programming question

Posted on 1997-07-09
1
149 Views
Last Modified: 2010-04-06
Hi,
I need source code for a dll and a program that would read that dll.
The Dll has to have a form on it. On that form there must be
a Tmemo component. in the memo, there must be an undefined amount of lines(it varies every time as this will be used for reading out multiple memos). When the "GetCoolScroll" procedure is called from a button on an application (not the dll) the dll takes the lines out of its own form and puts them into a TMemo component on the form of the main application. The source must be comented and complete. E-Mail me the zip to: maxcom@interserv.com.
Thanks and hope you can help.
MAXcom
0
Comment
Question by:maxcom
1 Comment
 
LVL 5

Accepted Solution

by:
ronit051397 earned 220 total points
ID: 1338528
I sent you the following examples by Email.
These example were tested under win3.11 (Delphi1) and winNT4 (Delphi3).

1. Application Code:
----------------------------------------------------------------
program Calldll;

uses
  Forms,
  Main in 'MAIN.PAS' {Form1};

begin
  Application.CreateForm(TForm1, Form1);
  Application.Run;
end.
----------------------------------------------------------------
unit Main;

interface

uses WinTypes, WinProcs, Classes, Graphics, Forms, Controls, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Memo1: TMemo;
    procedure Button1Click(Sender: TObject);
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure GetCoolScroll(FMemo: THandle);
  far; external 'Memodll.dll';

procedure TForm1.Button1Click(Sender: TObject);
begin
  GetCoolScroll(Memo1.Handle);
end;

end.
----------------------------------------------------------------
2. Dll code
library Memodll;

uses Uform2 in 'UFORM2.PAS' {Form2};

{$R *.RES}

exports
  GetCoolScroll;
begin
end.
----------------------------------------------------------------
unit Uform2;

interface

uses
  WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  Forms, StdCtrls;

type
  TForm2 = class(TForm)
    Memo2: TMemo;
    bbUpdate: TButton;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure bbUpdateClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

procedure GetCoolScroll(FMemo: THandle); export;
implementation
var MemoHandle: THandle;
    DllForm: TForm2;
{$R *.DFM}

procedure GetCoolScroll(FMemo: THandle);
begin
  MemoHandle:=FMemo;
  DllForm := TForm2.Create(Application);
  DllForm.Show;
end;

procedure TForm2.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  Release;
end;

procedure TForm2.bbUpdateClick(Sender: TObject);
var
  FBuffer:PChar;
  FSize: Integer;
begin
  FSize:= DllForm.Memo2.GetTextLen+1;
  Getmem(FBuffer,FSize);
  DllForm.Memo2.GetTextBuf(FBuffer,FSize);
  sendmessage(MemoHandle,WM_SETTEXT,0,LongInt(FBuffer));
  Freemem(FBuffer,FSize);
end;

end.
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
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…

805 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