Solved

Delphi Programming question

Posted on 1997-07-09
1
153 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
[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
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone 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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

734 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