Hi,
I'm trying to display text into my window. My idea is to create a count down that displays in the window, using a for loop. I'm using the sleep() function to control the time.
Basically I just want the text to be displayed in window as the count down decrements.
It's suppose to go like this:
count=3
count=2
count=1
Here's my code:
Code:
#include <windows.h>
#include <mmsystem.h>
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
RECT rect;
int count = 5;
int i;
switch (message){
case WM_PAINT:
hdc = BeginPaint(hwnd, &ps);
for(i=0; i<5; i++)
{
count --;
Sleep(1000);//causes the main thread to sleep for 1 seconds - allowing another thread to run
TextOut(hdc, 20, 20,TEXT("count = %d\n",count),12);
}
EndPaint(hwnd, &ps);
return 0;
}
return DefWindowProc(hwnd, message, wParam, lParam);
}