class DDEServer
{
DDEString ServiceName; // The only service name
DDEString SystemTopic; // The system topic
BOOL bAcceptSelfConnections; // True if server accepts self
// connections
BOOL isOpen; // True if connection is open
static DDEServer * theDDEServer; // Pointer to the only
// DDE Server object
static CPtrList ServerConversationList; // List of server
// conversations
//........
public:
DDEServer(); // Create object
virtual ~DDEServer();
// Opens DDE service. You always have to call OpenServer first
// to start the server.
BOOL OpenServer(const DDEString & ServiceName);
// If you don't call CloseServer, it will get called by
// destructor.
BOOL CloseServer();
// Return TRUE if the server is open
BOOL IsOpen() const { return isOpen; }
// Conversation virtual functions called by system to start/stop
// conversations. You can redefine them to override default
// behaviour.
// You MUST redefine this member to accept conversations.
// If you return TRUE, the conversation is accepted.
virtual BOOL AcceptConversation(const DDEString & Topic)
{ return FALSE;}
// This member notifies you that a conversation has started and
// passes you the handle. You usually don't need to redefine this
// member function and dont care about the handle.
virtual void
BeginConversation(const DDEString & Topic, HCONV hConversation)
{}
// This gets called when the conversation is ended
// You usually don't need to redefine this member function.
virtual void
EndConversation(const DDEString & Topic,HCONV hConversation)
{}
//..................
// Virtual functions called by system to complete transactions:
// You can usually ignore the HCONV papameter.
// This is called when a client requests some data from the
// server. Set the data inside the passed DDEData object
// (the object must not be freed)
virtual BOOL
HandleRequest(const DDEString & topic, const DDEString & item,
DDEDataOut & Data, HCONV hConv)
{ return FALSE; } // Return TRUE if you handled message
// This is called when a client pokes some data to this server.
// The data is inside the DDEDataIn object. Return TRUE if you
// accept it.
virtual BOOL
HandlePoke(const DDEString & topic, const DDEString & item,
const DDEDataIn & Data, HCONV hConv)
{ return FALSE; }// Return TRUE if you handled message
// Called when server receives an execute transaction from a
// client. The complete execute command is in the command
// parameter.
virtual BOOL
HandleExecute(const DDEString & Topic, LPSTR commands,
HCONV hConv)
{ return FALSE; }
// Virtual functions that handle warm/hot links.
// They get called to implement advise links.
// Return TRUE to handle advise loop: this just enables it,
// does not return data
virtual BOOL
AcceptAdvise(const DDEString & topic, const DDEString & item,
UINT format, HCONV hConv)
{ return FALSE;}
// This returns the data requested in the advise loop.
virtual BOOL
PrepareAdviseData(const DDEString & topic,
const DDEString & item, DDEDataOut & Data,
UINT CountRemaining, HCONV hConv)
{ return FALSE;}
// Call when an advise request is terminated:
// don't need to do anything
virtual void
AdviseStop(const DDEString & topic, const DDEString & item,
UINT format, HCONV hConv)
{}
// Called when registering/unregistering service names.
// Register=FALSE for Unregister
virtual void Register(const DDEString & BaseServName,
const DDEString & InstServName, BOOL Register)
{}
// Called when a DDE memory error occurs, release your data
// and close conversations if possible. Can get passed the
// handle of the conversation causing the error or NULL
virtual void OnError(HCONV hConvError)
{}
// Tell DDE that a topic/item pair has changed.
// You must call this function when an item changes.
// The system will then call the appropriate virtual functions.
BOOL PostAdvise(const DDEString & topic, const DDEString & item);
// Tell DDE that all topic/item pairs have been changed
// You must call this function when all your data has changed.
// The system will then call the appropriate virtual functions.
BOOL PostAdvise();
//..........
private: // Private members
// DDE Callback function that dispatches transactions to
// clients and servers
friend HDDEDATA CALLBACK
DDECallback(UINT,UINT,HCONV,HSZ,HSZ,HDDEDATA,DWORD,DWORD);
// DDE Callback function where all server DDE transactions
// get dispatched
HDDEDATA
DDEServerCallback(UINT, UINT, HCONV, HSZ, HSZ, HDDEDATA, DWORD,
DWORD);
//................
};