Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help With Dll libraries 1

Status
Not open for further replies.

Spent

Programmer
Mar 20, 2003
100
BG
I have a Form1:TForm with a memo1:TMemo, and an external library called memo.dll. CAN you tell me is it possible to add strings into the memo directly from the Dll source code.Something like this but in the Dll: form1.memo1.lines.add('Hi from Dll'); And Will there be an error (Memo1 not found) while compyling the *.dll.Thank You. Spent mail:spentbg@yahoo.com
 
The problem I see is that the dll library won't know anything about your form and its controls, so any direct reference to a control (such as the memo) from within the DLL will lead to compiler errors.
If you keep it to simple variable types, you could pass properties of your form's controls as command line parameters of the functions within your dll.

if within the dll, you have a function called...

function lettercount(s : string) : integer;

...you could call that dll's function and pass it the contents of your memo like this...

n := lettercount(memo.text);

In this way, the contents of your controls could be passed into the DLL, (but the controls themselves cannot).

Hope this helps.
Peace,
Colt. If it's stupid but it works, it isn't stupid
 
In your example, you want your .dll to do something with a TMemo, so you would put a function in your .dll that could be called by the application with something like this:
Code:
interface

  procedure InitializeAMemo( AMemo:TMemo); external 'MYLIB.DLL';

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

implementation

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

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top