Solved

DDE/PostMessage

Posted on 1998-01-05
4
1,026 Views
Last Modified: 2012-08-13
First the sample code:

    char *szApplication="Excel";
    char *szTopic="Sheet1";
    static HWND hwndClientDDE;
    static HWND hwndServerDDE;  
    int atomApplication,atomTopic;
    int atomItem;
    long lgval;
    char *szItemName="R1C1";
    //ADDITIONAL VARIABLES DECLARED HERE...........

lgval=::SendMessage((HWND) -1,     // broadcasts message           WM_DDE_INITIATE,           //initiates conversation       (WPARAM) hwndClientDDE,      //handle of client DDE  
        MAKELONG(atomApplication,  // application-name atom        atomTopic));                //topic-name atom              
 
    //Code to delete atom here................
   
    atomItem = GlobalAddAtom(szItemName);  
   
    lgval=::PostMessage(hwndServerDDE,
            WM_DDE_REQUEST,
            (WPARAM) hwndClientDDE,
            PackDDElParam(WM_DDE_REQUEST, CF_TEXT,             atomItem));

This is pretty much out of MSDN, I am using VC 1.0 (can you believe it!). I want to hook to an Excel spreadsheet. The above SendMessage returns a 1, but then it broadcasts to all active windows so I'm not totally convinced. The PostMessage comes back as 0 and the PackDDElParam is not recognized at all in the compiling(so I tried it with MAKELONG, taking out the WM_DDE_REQUEST - and got the 0). Does anybody know why this doesn't work????
0
Comment
Question by:dpms
[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
  • 2
  • 2
4 Comments
 

Author Comment

by:dpms
ID: 1177530
Edited text of question
0
 
LVL 15

Accepted Solution

by:
Tommy Hui earned 50 total points
ID: 1177531
The standard form of trying to find the DDE server is to use SendMessage to all top-level windows and asking it if it supports DDE (WM_DDEINITIATE) and if it supports the application with that topic name.

Then any application that supports that DDE conversation will return the HWND of the window you are supposed to communicate with. Then your application will need to use PostMessage to that particular window in order to communicate with it. If the parameters to any of the messages are incorrect, then the client and the server are speaking different languages and won't be to communicate. So you need to use PackDDElParam which is in the header DDE.h. If you don't, then you'll run into problems.


0
 

Author Comment

by:dpms
ID: 1177532
I did put in an " #include <dde.h> " statement from the start. But the packddelparam comes back as unrecognized? Am I missing something?
0
 
LVL 15

Expert Comment

by:Tommy Hui
ID: 1177533
Make sure you have spelled out PackDDElParam correctly and with the right case. The other possibility is that Visual C++ 1.0 may not have the right header file. You may want to search the headers to find out where PackDDElParam may be located.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

687 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