Solved

Delphi Programming question

Posted on 1997-07-09
1
147 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
Comment Utility
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

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…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

763 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now