DirectPlay Message handler as class member?
Hello,
I tried to develop my first game and put multiplayer functionality in it. I did everything object-oriented put the DirectPlay Message Handler in an object, so I did not make it static. When compiling, I get a mistake like this:
error C2664: ''IDirectPlay8Peer::Initialize'' : Converting of Parameter 2 of ''HRESULT (PVOID,DWORD,PVOID)'' in ''const PFNDPNMESSAGEHANDLER'' not possible
So the initialize - function does not seem to want a nonstatic function as a parameter. I tried using an approach I found somewhere and made a wrapper like this:
HRESULT DPMsgHandlerWrapper (PVOID pvUserContext, DWORD dwMessageId, PVOID pMsgBuffer)
{
return m_pGameClass->DirectPlayMessageHandler (pvUserContext, dwMessageId, pMsgBuffer);
}
..and I put that wrapper-handler in my initialize function, but the mistake does not change.
How do you all program your DirectPlay Applications? Is there a solution for this problem or is the DirectPlay MessageHandler just supposed to be static?
Thanks a lot for your help.
I haven''t tried putting it inside an object, BUT that wrapper approch can''t be wrong.
Since it''s a normal msg-handler function it has to work.
Check that you set DPMsgHandlerWrapper to your DPmsgProc and NOT m_pGameClass->DirectPlayMessageHandler!
You should be able to type any kind of c++ code inside your wrapper class
----------------------------------------------
Petter Nordlander
"There are only 10 kinds of people in the world. They who understand binary and those who do not"
Since it''s a normal msg-handler function it has to work.
Check that you set DPMsgHandlerWrapper to your DPmsgProc and NOT m_pGameClass->DirectPlayMessageHandler!
You should be able to type any kind of c++ code inside your wrapper class
----------------------------------------------
Petter Nordlander
"There are only 10 kinds of people in the world. They who understand binary and those who do not"
You can also use the pvUserContext to store a pointer to an instance of the class wich includes the Msg-Handler. Your static function casts this void* and calls its handler.
[ Games made by gamers'' minds | maxiInnovation - miniCan | mail: ChristianRoesch@gmx.de ]
[ Games made by gamers'' minds | maxiInnovation - miniCan | mail: ChristianRoesch@gmx.de ]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement