Link to home
Start Free TrialLog in
Avatar of dpms
dpms

asked on

DDE/PostMessage

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????
Avatar of dpms
dpms

ASKER

Edited text of question
ASKER CERTIFIED SOLUTION
Avatar of Tommy Hui
Tommy Hui

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dpms

ASKER

I did put in an " #include <dde.h> " statement from the start. But the packddelparam comes back as unrecognized? Am I missing something?
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.