C++ & DDE

Hi all,

I am working with a platform that provides info on the financial market. (MetaTrader 4).

The platform has an embedded DDE server. I am trying to figure out how to act as a DDE client directly trough a project I am about to code.

Namely retreiving market rates, making a short analysing, and exporting the whole things to a .txt for printing.

Here's the material I am currently looking at:
http://msdn.microsoft.com/en-us/library/ms648712(v=VS.85).aspx

My questions are:

1. I know DDE is getting old, is there a way to communicate with a DDE Sever without resorting to DDE (Sry if this question sounds stupid).

2. Is there a tutorial for begginners, I read the MSDN thing unfortunately its not commented enough for me to follow accurately.

3. Any advice on that matter ?

Regards,

Wissam
1. No. DDE is a protocol. If you're a client, you have to observe the protocol. Pay attention to memory management. You can leak tons of memory if you're not careful.

2. Have you read this? http://msdn.microsoft.com/en-us/library/ms648774%28VS.85%29.aspx

3. Be careful. DDE is an old (Windows 3.0) technology. MSDN has been trimmed over the years, so you may get more information from an old MSDN CD from the 90s.
To get practical, to retrieve market prices from MetaTrader 4, the following piece of code is to be used (on excel) : =MT4|BID!EURUSD
This will stream to excel every market price tick for EURUSD.

Also I have Metatrader4 installed and launched from "C:\MT4\MT4.exe"

Looking at the MSDN, to initiate conversation with MetaTrader4 (or any other software), they give the following example:

----------------------------------------------

static BOOL fInInitiate = FALSE;
char *szApplication;
char *szTopic;
atomApplication = *szApplication == 0 ?
NULL : GlobalAddAtom((LPSTR) szApplication);
atomTopic = *szTopic == 0 ?
NULL : GlobalAddAtom((LPSTR) szTopic);

fInInitiate = TRUE;
SendMessage((HWND) HWND_BROADCAST, // broadcasts message
WM_DDE_INITIATE, // initiates conversation
(WPARAM) hwndClientDDE, // handle to client DDE window
MAKELONG(atomApplication, // application-name atom
atomTopic)); // topic-name atom
fInInitiate = FALSE;
if (atomApplication != NULL)
GlobalDeleteAtom(atomApplication);
if (atomTopic != NULL)
GlobalDeleteAtom(atomTopic);

---------------------------------------------------------

The following piece of code is the most interest for me for now:

SendMessage((HWND) HWND_BROADCAST, // broadcasts message
WM_DDE_INITIATE, // initiates conversation
(WPARAM) hwndClientDDE, // handle to client DDE window
MAKELONG(atomApplication, // application-name atom
atomTopic)); // topic-name atom

I do understand the purpose of this function, I do not know what kind of info, and in which format I should replace "hwndClientDDE", "atomApplication", and "atomTopic".

Can you shed some light on that ?


Similarly to retrieve data they say:

PostMessage(hwndServerDDE,
WM_DDE_REQUEST,
(WPARAM) hwndClientDDE,
PackDDElParam(WM_DDE_REQUEST, CF_TEXT, atomItem)

What do the "hwndClientDDE" and the "atomItem" stand for ? (pratically)

Thanks again,

Wissam
Last edited on
Have you read the protocol? Do you know what an atom is? Do you realise your app needs a window for DDE communication?
Of course I did, the code I pasted here is from the MSDN.

However I thought I could skip the atom part...looks like I shouldn't.

Do you happen to have a sample code somewhere ? Comparing the MSDN code and another would help me greatly.
You need to tell the server what you're interested in. The way you pass a string in is to make an atom that has MT4|BID!EURUSD as its value and pass that in.
Hi, still reading on this stuff.

On the MSDN about DDEML I have "Existing applications using the message-based DDE protocol are fully compatible with those that use the DDEML; that is, an application using message-based DDE can establish conversations and perform transactions with applications using the DDEML"

I wonder if this mean that I can through my C++ software communicate in "DDEML" with a DDE server ?

If yes will learn that instead, it seems far more documented...
I think it does, but I know nothing about DDEML.
thx for your all your answer kbw.
Topic archived. No new replies allowed.