Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Delphi Programming question

Posted on 1997-07-09
1
Medium Priority
?
160 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 440 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

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

885 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