lParam in SysWMmsg

Hi,

I got a problem with msgtype WM_DEVICECHANGE,
following code should work:

#ifdef WINDOWS
PDEV_BROADCAST_HDR dbh;

      case SDL_SYSWMEVENT:
        if (event.syswm.msg!=NULL) {
          if (event.syswm.msg->msg==WM_DEVICECHANGE) {              

            dbh=(PDEV_BROADCAST_HDR)  event.syswm.msg->lParam;
              if (event.syswm.msg->wParam==DBT_DEVICEREMOVECOMPLETE)

{
if (dbh->dbch_devicetype==DBT_DEVTYP_VOLUME) {
sys->systemOut(“CD OUT”);
}
}
if (event.syswm.msg->wParam==DBT_DEVICEARRIVAL) {
if (dbh->dbch_devicetype==DBT_DEVTYP_VOLUME) {
sys->systemOut(“CD IN”);
}
}
}
}
break;
#endif //windows

wParam works find, but the lParam doesn’t seem to be the right pointer
to
the DEV_BROADCAST_HEADER. dbh->devicetype seems to be another
pointer rather than a DEVTYP (0,1,2 and so on).
Maybe my fault or GCC 3.4 ?

Regards,
Thomas Omilian

Hi,

may i be right that the lParam is no more valid while its
a pointer to a structure ? In the message loop, windows
wParam und lParam were just copied to a new event-struct and
the winmsg is proceeded. When the event reaches SDL,
the memory where lParam points to, is no more valid ?!?
So every messagetype where lParam is a pointer would
not be useful. Is there another solution ???

Regards,
Thomas Omilian

may i be right that the lParam is no more valid while its
a pointer to a structure ?

Yep, you’re getting the message later, not while it’s being processed.

What you probably want to do is use the interface to get the window handle
and then replace the window proc for that window, calling SDL’s window proc
from your own. You can see SDL doing this in SDL_dibevents.c, search for
userWindowProc.

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment