|
Monitoring Applications
The application programming interface (API) elements of the DDEML can be used
to create an application that monitors DDE activity in the system. Like any
DDEML application, a DDE monitoring application contains a DDE callback function.
The DDEML notifies a monitoring application's DDE callback function whenever a
DDE event occurs, passing information about the event to the callback function.
The application typically displays the information in a window or writes it to
a file.
To receive notifications from the DDEML, an application must have registered
as a DDE monitor by specifying the APPCLASS_MONITOR flag in a call to the DdeInitialize function. In this same call, the application can specify one or more monitor
flags to indicate the types of events for which the DDEML is to notify the
application's callback function. The following monitor flags can be specified by an
application:
Flag
| Description
| MF_CALLBACKS
| Notifies the callback function whenever a transaction is sent to any DDE
callback function in the system.
| MF_CONV
| Notifies the callback function whenever a conversation is established or
terminated.
| MF_ERRORS
| Notifies the callback function whenever a DDEML error occurs.
| MF_HSZ_INFO
| Notifies the callback function whenever a DDEML application creates, frees, or
increments the usage count of a string handle or whenever a string handle is
freed as a result of a call to the DdeUninitialize function.
| MF_LINKS
| Notifies the callback function whenever an advise loop is started or ended.
| MF_POSTMSGS
| Notifies the callback function whenever the system or an application posts a
DDE message.
| MF_SENDMSGS
| Notifies the callback function whenever the system or an application sends a
DDE message.
|
The following example shows how to register a DDE monitoring application so
that its DDE callback function receives notifications of all DDE events.
DWORD idInst;
PFNCALLBACK lpDdeProc;
hInst = hInstance;
if (DdeInitialize(
(LPDWORD) &idInst, /* instance identifier */
DDECallback, /* points to callback function */
APPCLASS_MONITOR | /* this is a monitoring application */
MF_CALLBACKS | /* monitor callback functions */
MF_CONV | /* monitor conversation data */
MF_ERRORS | /* monitor DDEML errors */
MF_HSZ_INFO | /* monitor data handle activity */
MF_LINKS | /* monitor advise loops */
MF_POSTMSGS | /* monitor posted DDE messages */
MF_SENDMSGS, /* monitor sent DDE messages */
0)) /* reserved */
return FALSE;
The DDEML informs a monitoring application of a DDE event by sending an XTYP_MONITOR transaction to the application's DDE callback function. During this
transaction, the DDEML passes a monitor flag that specifies the type of DDE event that
has occurred and a handle of a DDE object that contains detailed information
about the event. The DDEML provides a set of structures that the application can
use to extract the information from the DDE object. There is a corresponding
structure for each type of DDE event.
Structure
| Description
| MONCBSTRUCT
| Contains information about a transaction.
| MONCONVSTRUCT
| Contains information about a conversation.
| MONERRSTRUCT
| Contains information about the latest DDE error.
| MONLINKSTRUCT
| Contains information about an advise loop.
| MONHSZSTRUCT
| Contains information about a string handle.
| MONMSGSTRUCT
| Contains information about a DDE message that was sent or posted.
|
The following example shows the DDE callback function of a DDE monitoring
application that formats information about each string handle event and then
displays the information in a window. The function uses the MONHSZSTRUCT structure to extract the information from the DDE object.
HDDEDATA CALLBACK DDECallback(uType, uFmt, hconv, hsz1, hsz2,
hdata, dwData1, dwData2)
UINT uType;
UINT uFmt;
HCONV hconv;
HSZ hsz1;
HSZ hsz2;
HDDEDATA hdata;
DWORD dwData1;
DWORD dwData2;
{
LPVOID lpData;
CHAR *szAction;
CHAR szBuf[256];
DWORD cb;
switch (uType) {
case XTYP_MONITOR:
/* Obtain a pointer to the global memory object. */
if (lpData = DdeAccessData(hdata, &cb)) {
/* Examine the monitor flag. */
switch (dwData2) {
case MF_HSZ_INFO:
#define PHSZS ((MONHSZSTRUCT FAR *)lpData)
/*
* The global memory object contains
* string handle data. Use the MONHSZSTRUCT
* structure to access the data.
*/
switch (PHSZS->fsAction) {
/*
* Examine the action flags to
* determine the action performed on
* the handle.
*/
case MH_CREATE:
szAction = "Created";
break;
case MH_KEEP:
szAction = "Incremented";
break;
case MH_DELETE:
szAction = "Deleted";
break;
case MH_CLEANUP:
szAction = "Cleaned up";
break;
default:
DdeUnaccessData(hdata);
return (HDDEDATA) 0;
}
/* Write formatted output to a buffer. */
wsprintf(szBuf,
"Handle %s, Task: %x, Hsz: %lx(%s)",
(LPSTR) szAction, PHSZS->hTask,
PHSZS->hsz, (LPSTR) PHSZS->str);
.
. /* Display text or write to a file. */
.
break;
#undef PHSZS
.
. /* Process other MF_* flags. */
.
default:
break;
}
}
/* Free the global memory object. */
DdeUnaccessData(hdata);
break;
default:
break;
}
return (HDDEDATA) 0;
}
| Last news from Greatis Software |
 |
|
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 |
|
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 |
|
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 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 offers controls with gradient background feature. Labels, panels and so on... Full C# source codes are available More » |
 |
|
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 projectsDmitry Vasiliev (just.dmitry)
Related LinksSoftware 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
|