1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;
TCHAR greeting[] = _T("Wisdom Earned:");
TCHAR space[] = _T(" ");
_TCHAR szBuffer[100];
int wisdomCnt=0;
UINT_PTR IDT_TIMER1=1;
static BOOL fFlipFlop = FALSE ;
RECT rc;
switch (message)
{
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
// Parse the menu selections:
switch (wmId)
{
case IDM_ABOUT:
DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
break;
case IDM_EXIT:
DestroyWindow(hWnd);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
break;
case WM_CREATE:
SetTimer (hWnd, IDT_TIMER1, 1000, NULL) ;
return 0 ;
case WM_TIMER :
wisdomCnt++;
fFlipFlop = !fFlipFlop ;
InvalidateRect (hWnd, NULL, FALSE) ;
return 0 ;
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
TextOut(hdc, 10, 10, greeting, _tcslen(greeting));
_stprintf_s(szBuffer, _T("%i"), wisdomCnt);
TextOut(hdc,120,10,szBuffer, _tcslen(space));
//MessageBox(hWnd, szBuffer, _T("wat"), MB_OK);
// TODO: Add any drawing code here...
GetClientRect (hWnd, &rc) ;
EndPaint(hWnd, &ps);
break;
case WM_DESTROY:
KillTimer (hWnd, IDT_TIMER1);
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
|