WinX and 0x80000xx
Palm Tip
Arg! I keep getting an error about 0x80000xx when making WinX system calls (especially on debug ROMs) where the emulator tells me that I haven't set my window drawing function, but I have called WinSetDrawWindow repeatedly.
As it happens, there's a small disagreement between EvtGetEvent and WinSetDrawWindow.
You see, when a window goes away, it creates a "exit window event". The next time your program calls EvtGetEvent, and that ends up calling WinSetDrawWindow(NULL);.
WinSetDrawWindow in debug ROMs behaves differently than it does in regular ROMs.
In regular ROMs (at least up until 4.1), this means 'set my drawing window to be the screen'.
In debug ROMs (at least up until 4.1), this means 'set my drawing window to be 0x80000000 (badDrawWindowValue)'.
The intention is clearly to allow developers to find when they're calling WinSetDrawWindow(NULL) and fix those places. However, when EvtGetEvent does it, it makes it quite difficult to sort out.
The quick fix is to add a 'WinSetDrawWindow(validWindowHandle)' immediately after EvtGetEvent, and the error goes away.
The longer, but more correct fix, would be to only do this when running under the emulator. At any other time, don't make this call.