TDataComm

This VCL allows you to easily pass data between two applications 
running on the same computer without resorting to DDE.  Use it to 
share data, find out if another instance of your application is
already running, or even to remotely control one application
from another.

PROPERTIES

Channel:          This is the channel you will be broadcasting
                  your data over.  It is really a Windows message.
                  The default is WM_USER + 99, but I sugggest you 
                  change it so as not to conflict with other 
                  programs that may be using this control.  The 
                  value must be greater than WM_USER. 

Data:             This is a longint, and represents the data to be
                  sent.  This doesn't mean that you can only send
                  4 bytes of information, just typecast a pointer 
                  to your data as a long.  For example:

                  Data := LongInt(@MyBitmap);

                  When sending a pointer to an object, make sure 
                  that the object won't be destroyed before the
                  reciever has a chance to read the data.  The
                  best way to do this is to only send pointers 
                  to global variables.

InData:           This is the longint received by the control.
                  Using the above example, to decode the data
                  do the following:

                  Image1.picture.assign(TBitmap(pointer(InData)));

                  Note the use of Assign.  Always make a local copy 
                  of the data as soon as possible to reduce the 
                  chance of the data being destroyed before you are 
                  finished.

METHODS

SendData:         This is what actually triggers the data being sent.

EVENTS

OnReceiveData:    This event is fired when data is received over the 
                  specified channel.  At this point, InData will
                  contain the LongInt received.


Installing TDataComm

To install this VCL, copy both DATACOMM.DCU and DATACOMM.DCR to the
directory where you have your other shareware controls.  Then, 
from Delphi's main menu, select Options|Install Components.  In the
dialog, click on the Add... button, then Browse... and change to the 
drive/directory where you stored the above two files.  Select 
DATACOMM.DCU and click OK, then OK again.

Using TDataComm

To use this control, simply place it on your form, and set the Channel
property to some unique value over WM_USER.

Suppose you want to send a structure containing names and addresses 
from one application to another (both applications must contain a
TDataComm control set to the same channel).

First create the structure:

Type
   TAddBook = Record
   Name : String;
   Address1 : String;
   Address2 : String;
   City : String;
   State : String;
   ZIP : String;
   Phone : String;
   Age : Integer;
   Other : LongInt;
end;

Var
   MyAddress : TAddBook;

Next, send the Data:

procedure TForm1.Button1Click(Sender: TObject);
begin
   MyAddress.Name := 'Bob Jones';
   MyAddress.Address1 := '1234 Main Street';
   MyAddress.Address2 := 'Apt 4';
   {...fill in the rest of the structure}
   DataComm1.Data:=longint(@MyAddress);
   DataComm1.SendData;
end;

In the receiving application, you should have the same structure as 
above defined.  Then, add the following code to the OnReceiveData
event:

procedure TForm1.DataComm1OnReceiveData(Sender: TObject);
var
   AnAddress : TAddBook;
begin
   AnAddress := TAddBook(pointer(InData));
   Label1.caption := AnAddress.Name;
   {..., etc.}
end;

That's all there is to it!


Support:

Send comments and questions to:

Zane Rathwick
Indigo Software

CIS: 74633,1314
AOL: ZaneR
Internet:   ZaneR@aol.com
U.S. Mail:  Zane Rathwick
            Indigo Software
            4240 Park Newport Suite 308
            Newport Beach, CA 92660

Registering TDataComm

To register TDataComm and receive source code, send $10 (+$2 S&H) to:

Indigo Software
4240 Park Newport # 308
Newport Beach, CA 92660

You can save the $2 shipping fee by specifying a Compuserve or AOL 
account to have your control sent to instead of by mail.

You may also order through Compuserve (GO SWREG), by ordering
Product #10769.