Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

DDE in Delphi 3.x

Posted on 1998-01-12
18
Medium Priority
?
527 Views
Last Modified: 2010-05-18
Has anyone got the DDE components to work correctly in Delphi 3.x, specifically:-

1) Connecting to an application not in the same directory.
2) Getting the Server Item name to stay in the ClientItem.DDEItem

Are there any other components available that work and if so where?

Thanks for any assistance.

Chris
0
Comment
Question by:ChrisBerry
[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
  • 9
  • 9
18 Comments
 
LVL 5

Expert Comment

by:ronit051397
ID: 1356196
To what application you want to connect with DDE? another Delphi application or a non Delphi application?
0
 

Author Comment

by:ChrisBerry
ID: 1356197
I have two Delphi applications both of which must be client and server as I wish to pass messages between both. Also I do not want the client to have to request/poll for messages but to be told - OnChange - when a message has arrived for it.
0
 
LVL 5

Accepted Solution

by:
ronit051397 earned 50 total points
ID: 1356198
Use the following Example which works, and try to figure out how DDE works:

On this example when you press a button on a client application,
then the contents of the edit box in this client application are shown in an edit box in the server application.

1. Create a project and call it Project1 (the client application).
2. Create a button and an edit box.
3. write the following code:
procedure TForm1.Button1Click(Sender: TObject);
var
  DdeClientConv1: TDdeClientConv;
  DdeClientItem1: TDdeClientItem;
  Buf: PChar;
begin                           DdeClientConv1:=TDdeClientConv.Create(Form1);                           DdeClientItem1:=TDdeClientItem.Create(Form1);
  DdeClientItem1.DdeItem := 'DdeServerItem1';
  DDEClientItem1.DDEConv := DDEClientConv1;
  GetMem(Buf,100);
  with DdeClientConv1 do
  begin
    ConnectMode := ddeManual;
    SetLink('Project2','DdeServerConv1');
    OpenLink;
    StrPCopy(Buf, Edit1.Text);
    ExecuteMacro(Buf,True);
    CloseLink;
  end;
  FreeMem(Buf,100);
  DDEClientItem1.Free;
  DdeClientConv1.Free;
end;

4. Create a project on the same directory as project1 and call it Project2 (the server application).
5. Create a TDdeServerConv with the name DdeServerConv1.
6. Create a TDdeServerItem with the name DdeServerItem1.
7. Set DdeServerItem1.ServerConv to DdeServerConv1.
8. Create an edit box.
9. write the following code on the OnExecuteMacro Event:
procedure Tform1.DdeServerConv1ExecuteMacro(Sender: TObject;
       Msg: TStrings);
begin
  Edit1.Text:=Msg[0];
end;

10. First run project2 then run project1.
11. Press the button on project1. The contents of the edit box in the client will be shown on the edit box in the server.
12. If this doesn't work, then let me Know.
13. I use exeutemacro because it is more stable then pokedata and doesn't create access violations.
14. There is an example in the demos directory in Delphi1.

If you want both applications to be clients and servers then do the same in the other application.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:ChrisBerry
ID: 1356199
Sorry for the delay in replying.

Thanks for your reply, however I am looking to use the DDE using the full path, as it states the component will do, but I still am unable to connect although the application does open, an instance for every SetLink. If I have both apps in the same directory all is OK.
0
 
LVL 5

Expert Comment

by:ronit051397
ID: 1356200
Did you try SetLink('c:\FullPath\Project2','DdeServerConv1');?
0
 

Author Comment

by:ChrisBerry
ID: 1356201
Yes I did and as I said it launched the application but would not connect. I tried the same on an application that worked in the same directory using the project name but when I changed to the full path it would not work.??!!??

Using the project name it always used the same instance, using the full path it always launched a new instance.

0
 
LVL 5

Expert Comment

by:ronit051397
ID: 1356202
OK, Let me check. I'll be back within a day or two.
0
 
LVL 5

Expert Comment

by:ronit051397
ID: 1356203
Ok, I checked, and this is working also when 2 projects are in different directories. Post your EMail address so I can send you the examples.
0
 

Author Comment

by:ChrisBerry
ID: 1356204
Thanks - cupar@poboxes.com
0
 
LVL 5

Expert Comment

by:ronit051397
ID: 1356205
Well, did you get the mail?
0
 

Author Comment

by:ChrisBerry
ID: 1356206
Yes, thanks will let you know the result.
0
 

Author Comment

by:ChrisBerry
ID: 1356207
Did you get the mail I sent in response to your demo application.?

What do you think?
0
 
LVL 5

Expert Comment

by:ronit051397
ID: 1356208
I didn't get the mail.
0
 

Author Comment

by:ChrisBerry
ID: 1356209
This is a copy of the mail sent 22/1/98:-

Hi,

Thanks for your help so far.

Don't know if I should reply via e-mail or Experts Exchange but here
goes.

> Attached 2 sample projects. Place them in 2 different directories
> and let me know.

1) If I have both the Client and Server running they work fine.

2) If I run the Client it will not instansiate the Server either from
separate diectories or if I put the EXEs in the same diectory.

3) I modified the code to include the full path in the Client
SetLink. This had the effect of running a different instance of
the Server for every key press but did not transfer any data.

These are the same problems as I have been having although I was not
using the Macro path for the transfer of data.

Where to from here? Do you get the same problems or is it something
to do with my system?

Regards

0
 
LVL 5

Expert Comment

by:ronit051397
ID: 1356210
In order to get it work properly, you need to open both client and server, and then do what ever you need. Is it necessary for you to open the server automatically when the client call it?
0
 

Author Comment

by:ChrisBerry
ID: 1356211
I did want to open the server from the client. The documentation states that it will do this and in fact it will but does not connect. It also opens a new instance of the server every time you try to connect, not what I want.
0
 
LVL 5

Expert Comment

by:ronit051397
ID: 1356212
Yes, there is a problem with that. I suggest you open the server not by DDE, but by any other method, say, calling winexec for example, and then, start talking to it by DDE.
0
 

Author Comment

by:ChrisBerry
ID: 1356213
I guess we might as well call a halt on this. Your last answer is where I was at the begining, ie I implemented it that way, but I have since changed to using WM_Copydata which seems to be more reliable than the DDE components.

Thanks for your help
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

670 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