Advertisement

PeekMessage screws up my variables!

Started by January 21, 2001 03:36 PM
1 comment, last by Catfish 24 years ago
Heya... I've hit an error in some C++ coding that I can't figure out...was wondering if anyone here could offer any help: I have a global vector, consisting of pointers to a 'particle' object. vector<particle*> pList; I can quite happily assign a new particle object to it using push_back, & can set & read variables of the particle. & then I call PeekMessage, to check for incoming messages... PeekMessage(&msg,NULL,0,0,PM_REMOVE) At this point, all the variables in my particle object are filled with garbage. The pointer in pList stays the same - its still pointing to the same address... I'm kinda new to C++, so this has confused the hell out of me. I appreciate this probably isn't much to go on, but does anyone know what's going wrong? Thanks in advance.... Catfish Edited by - Catfish on January 21, 2001 7:22:18 PM
Post code , Ill fix it 4 you . Happened to me once.
I was influenced by the Ghetto you ruined.
Advertisement
OK....finally got it sorted thanks to a comment someone made in reply to one of my posts. I was declaring a local temporary particle & assigning its address into my vector - I didn''t think about it going out of scope once I exited that function.
My main problem was that looking in the watcher window, my vector variable wasn''t updated until PeekMessage was called, so that kinda sent me off on the wrong track. Setting the watcher to look directly at my temporary particle pointed out the problem.

Cheers for the help anyway
Catfish

This topic is closed to new replies.

Advertisement