Notes: compiles fine, VC++, Windows XP, i'm a noob.
Hello, I'm trying to learn C++ vectors in a windows program, and I think that I've pin-pointed that my problem should live in the Windows programming forum. I have a vector<string> that sort of "logs events" that are push_back'ed onto it as they occur in their respective messages. So I messily hacked this stuff together, my WndProc:
Code:
LRESULT CALLBACK WindowProcedure
(HWND hWindow, UINT message, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
int j = 20;
RECT rcRect;
PAINTSTRUCT ps;
std::vector<std::string> rawr;
std::vector<std::string>::const_iterator i;
rawr.push_back("blah");
rawr.push_back("rawr");
rawr.push_back("test");
switch(message)
{
case WM_CREATE:
rawr.push_back("Created");
break;
case SOMEMOREEVENTSTOHANDLE:
pushbacksomemorestring();
break;
case WM_PAINT:
hdc = ::BeginPaint(hWindow, &ps);
RECT rcRect;
::GetClientRect(hWindow, &rcRect);
for(i = rawr.begin(); i != rawr.end(); ++i, j += 20)
{
::TextOut(hdc, rcRect.left, rcRect.bottom - j, (*i).c_str(), (*i).length());
}
::EndPaint(hWindow, &ps);
break;
case WM_DESTROY:
::PostQuitMessage( 0 );
break;
}
return ::DefWindowProc
(hWindow, message, wParam, lParam);
}
What happens: blah, test, and rawr, the ones outside the message handler switchy(), are printed to the screen just fine, but when I try to push back other messages like "Window created" "Tonto is a n00b" "etc..." then they are never drawn. I really don't know the problem here, can a new pair of eyes give me a hand with this?