Hi all,
I wondered how to program a changing value in the title of a window (for example the FPS, or a download finished percentage). I tried this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
#include <iostream>
#include <sstream>
#include <Windows.h>
using namespace std;
int main( int argc, char* argv[] ) {
int a = 0;
stringstream counter;
while ( GetAsyncKeyState( VK_ESCAPE ) != 0 ) {
counter.str( "" );
counter << ++a;
SetConsoleTitle( counter.str().c_str() );
}
return 0;
}
|
but it immediately closes. Anyone knows what I'm doing wrong? And perhaps suggestions how to do this?
Thanks!
Last edited on
Change
while ( GetAsyncKeyState( VK_ESCAPE ) != 0 )
to
while ( GetAsyncKeyState( VK_ESCAPE ) == 0 )
That will keep it open, but I ran it on my computer and it got a massive memory leak, which I'm not sure why..
EDIT: I took SetConsoleTitle( counter.str().c_str() );
out of the loop and it runs better.
Last edited on