Original Post
Hello all, I am rather new to DirectX and have been working my way through a book I bought to learn some concepts. I am trying to enhance an example and have run into trouble. I am creating a server and client application using DirectPlay. I created a network class to encapsulate some of the functionality for reuse but I am having trouble with the ServerMessageHandler function. I have the prototype in my resource file like this: class cNetwork { private: IDirectPlay8Server *m_pDPServer; static HRESULT WINAPI NetworkMsgHandler(PVOID context, DWORD msgid, PVOID data); public: cNetwork(); ~cNetwork(); }; The problem I have is that every time the handle function is called the context is null. It does not matter if the message is coming from the server or a client application. Without the context I cannot get a handle to the server variable and so I cannot do anything. Here is the basic setup of the code: HRESULT WINAPI cNetwork::NetworkMsgHandler(PVOID context, DWORD msgid, PVOID data) { // Get a pointer to the calling network object. cNetwork *network = (cNetwork*)context; if(network == NULL) { return E_FAIL; } DPNMSG_CREATE_PLAYER *CreatePlayer; DPNMSG_DESTROY_PLAYER *DestroyPlayer; DPNMSG_RECEIVE *ReceiveData; switch(msgid) { case DPN_MSGID_CREATE_PLAYER: break; case DPN_MSGID_DESTROY_PLAYER: DestroyPlayer = (DPNMSG_DESTROY_PLAYER*)data; break; case DPN_MSGID_RECEIVE: ReceiveData = (DPNMSG_RECEIVE*)data; break; } return S_OK; } Can anyone help me on where to look or what is going on? I really cannot go any further with my exercise at this point. Thanks, Jarlax