[SDL] Problem with WM_USER
Albert Fernández Marsal
afmarsal at cirsa.com
Tue Jun 5 08:56:26 PDT 2007
Hi all,
I have to integrate a third party dll into my sdl application on a Win32
platform. The dll polls for a resource and, to notify that something
happended, it sends a WM_USER to a previously provided window handler. This
handler cannot be the SDL window handler (I tried to, but it doesn't work).
So, I created a window via CreateWindow API call. I have to run a PeekMessage
loop over that window so it can process the messages, but it seems to conflict
with the SDL_PollEvent loop that I run elsewhere.
The scenario is as follows (the calls are not sintactically correct, but they
can be understood) :
Main thread (my app):
while( true )
{
SDL_PollEvent( ev )
if( ev.type >= SDL_USEREVENT )
SDL_PushEvent( ev );
}
Secondary thread (my app):
hdl = CreateWindow('',0,0,0,0,0,0,0,0,0); // fake window
Register3rdPartyDll( hdl );
while( true )
{
// loop for processing the fake window event queue
if( PeekMessage( hdl, WM_USER ) // only processing WM_USER event
{
translatemsg;
dispatchmsg;
}
}
3rd party dll:
register custom Window Proc for the fake window.
Run a thread for polling the resource and post WM_USER to the fake window if
smthg happened
The custom window proc calls my code through a callback when WM_USER is
processed.
The problem is that I get a Memory Exception inside the 3rd party dll in my
main thread when I call the SDL_PollEvent.
Since the SDL_Event struct defines the event type as a UInt8 and WM_USER is
0x0400 (out of range of a uint8 type), i cannot figure out how to bypass the
WM_USER from inside the SDL_PollEvent loop.
Thank you very much for your help.
ALBERT
More information about the SDL
mailing list