Home   Index   About
Ultimate Pack


Custom Search
Notifying the Client that Data Has Changed

When the client establishes a link by using the WM_DDE_ADVISE message, with the fDeferUpd member not set (that is, equal to zero) in the DDEDATA structure, the client has requested the server send the data item each time the item's value changes. In such cases, the server renders the new value of the data item in the previously specified format and sends the client a WM_DDE_DATA message, as shown in the following example.

/*

* Allocate the size of a DDE data header, plus data (a string),

* plus a <CR><LF><NULL>

*/

if (!(hData = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE,

sizeof(DDEDATA) + lstrlen(szItemValue) + 3)))

return;

if (!(lpData = (DDEDATA FAR*) GlobalLock(hData))) {

GlobalFree(hData);

return;

}

lpData->fAckReq = bAckRequest; /* as specified in original */

/* WM_DDE_ADVISE message */

lpData->cfFormat = CF_TEXT;

lstrcpy(lpData->Value, szItemValue); /* copies value to be sent */

lstrcat(lpData->Value, "\r\n"); /* CR/LF for CF_TEXT format */

GlobalUnlock(hData);

if ((atomItem = GlobalAddAtom(szItemName)) != 0) {

if (!PostMessage(hwndClientDDE,

WM_DDE_DATA,

(WPARAM) hwndServerDDE,

PackDDElParam(WM_DDE_DATA, (UINT) hData, atomItem))) {

GlobalFree(hData);

GlobalDeleteAtom(atomItem);

FreeDDElParam(WM_DDE_DATA, lParam);

}

}

if (atomItem == 0) {

.

. /* error handling */

.

}

In this example, the client processes the item value as appropriate. If the fAckReq flag for the item is set, the client sends the server a positive WM_DDE_ACK message.

When the client establishes the link, with the fDeferUpd member set (that is, equal to 1), the client has requested that only a notification, not the data itself, be sent each time the data changes. In such cases, when the item value changes, the server does not render the value but simply sends the client a WM_DDE_DATA message with a null data handle, as illustrated in the following example.

if (bDeferUpd) { /* checking whether the flag was originally */

/* set in the WM_DDE_ADVISE message */

if ((atomItem = GlobalAddAtom(szItemName)) != 0) {

if (!PostMessage(hwndClientDDE,

WM_DDE_DATA,

(WPARAM) hwndServerDDE,

PackDDElParam(WM_DDE_DATA, 0,

atomItem))) { /* NULL data */

GlobalDeleteAtom(atomItem);

FreeDDElParam(WM_DDE_DATA, lParam);

}

}

}

if (atomItem == 0) {

.

. /* error handling */

.

}

As necessary, the client can request the latest value of the data item by issuing a normal WM_DDE_REQUEST message, or it can simply ignore the notice from the server that the data has changed. In either case, if fAckReq is equal to 1, the client is expected to send a positive WM_DDE_ACK message to the server.


Last news from Greatis Software

Nostalgia .Net     Nostalgia .Net     .Net is powerful, but not all-powerful, so sometimes we need to use Win32 API for our .Net applications. It's simple enough with Platform Invoke if you have Win32 skill, but we do not always have time to dig the ancient documentation, declare the special types that are compatible with Win32, find the values of the Win32's constants and so on. Nostalgia .Net offers several simple-to-use classes, and components that will allow you to forget about the headache of Win32 and just use the power of Win32 in your application the same way as you use the native. Net classes.  More »

Recommended software for developers

Ultimate Pack for Delphi and C++ Builder     Ultimate Pack     Component pack for Delphi and C++ Builder that contains runtime form designer, runtime object inspector, print suite and much more for the very special price.  More »

Form Designer .Net     Form Designer .Net     Unique runtime form design solution that allows to edit any form in .Net WinForms application at runtime with full source codes for only 300 euro!  More »

Print Suite .Net     Print Suite .Net     Print Suite .Net is a set of components for easy printing texts, images and grids from your WinForms applications. Full C# source codes are available  More »

Gradient Controls .Net     Gradient Controls .Net     Gradient Controls .Net offers controls with gradient background feature. Labels, panels and so on... Full C# source codes are available  More »

iGrid     Greatis iGrid     iGrid plots drawing grid right over your desktop, so you can use it everywhere, with any drawing application without any special plugins for different graphic editors.  More »


All the contacts and projects

Dmitry Vasiliev (just.dmitry)

Related Links

Software for Visual Studio .NET developers
Software for Delphi and C++ Builder developers
Software for Visual Basic 6 developers
Delphi Tips&Tricks
MegaDetailed.NET

More Online Helps

Win32 Programmer's Reference
Win32 Multimedia Programmer's Reference
OLE Programmer's Reference
Microsoft Windows Pen API Programmer's Reference
Microsoft Windows Sockets 2 Reference
Microsoft Windows Telephony API (TAPI) Programmer's Reference
Unix Manual Pages

Free Tech Secrets ;) Copyright © 2008-2012 Free Tech Secrets ;) greatis just4fun network just4fun