Posting messages

i am currently having problems with receiving messages before the function
that sent the message exits. the problem is that the class that sends the
message also receives it and changes the address space before the sending
function returns. thus when the stack trys to return from the sending
function after doing the other stuff, the address space has changed and i
get an access violation. I have done some reading and found that i need to
post messages rather then sending them… but how can i do this?

currently my main event loop looks like this…(it is from paragui … the
PumpIntoEventQueue function
decides which object(s) receive the event and then process them.)

there is a SendMessage function which adds the event using SDL_PushEvent.
any help would be great as i am stuck with a half working application. :frowning:

while(!my_quitEventLoop) {

// pull motion events (may flood the eventqueue)
while(SDL_PeepEvents(&event, 1, SDL_GETEVENT, SDL_MOUSEMOTIONMASK) > 0)

if(enableAppIdleCalls) {
if (SDL_PollEvent(&event) == 0) {
} else {
} else {