I've run into a strange problem. I'm trying to process win32 messages and make my app act accordingly. I'm passing the messages in a loop with TranslateMessage() and DispatchMessage, and I intercept them with a LRESULT CALLBACK function. Everything works fine except when the messages are processed the arrays seem to be not in scope, they don't contain anything. When I check for them in the main loop where the messages are dispatched they are present and good, but at message processing they're not. This problem doesn't apply to simple variables, they preserve their values.
here's how I store my variables:
1 2 3 4 5 6 7 8 9
class foo //it is inherited by the class
//which contains the message processing function
{
public:
int a; //this preserves its value
std::vector<some_type> b; //this doesn't
foo(){}
};
here's the dispatching:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
for(;;) //the class wich contains this inherits the window processing class
{
MSG msg;
BOOL return_value = GetMessage(&msg, 0, 0, 0);
if(return_value == 0)
{}
elseif(return_value == -1)
{}
else
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
and the message processing:
1 2 3 4 5 6 7 8 9 10 11 12
//this is not static!
LRESULT CALLBACK window::msg_proc(UINT msg, WPARAM wparam, LPARAM lparam)
{
switch(msg)
{
case WM_COMMAND:
{
//do something, here the array's size is zero,
//so we actually can't do anything
}
}
}
is there a way to make my variables stay in scope, or access their content?