Why is my wHour showing up as 0 not 5 (it's 5 right now)?
Code:
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HDC hdc ;
PAINTSTRUCT ps ;
RECT rect ;
SYSTEMTIME time;
switch (message)
{
case WM_LBUTTONUP:
GetCursorPos(&p);
sprintf(x, "%d", p.x);
sprintf(y ,"%d", p.y);
repaint_variable = 1; // This is to tell the window to repaint with the coordinates
InvalidateRect(hwnd, NULL, false);
return 0;
case WM_PAINT:
GetSystemTime(&time);
minute = time.wMinute;
seconds= time.wSecond;
thehour = time.wHour;
sprintf(hourptr, "%d", thehour);
sprintf(minuteptr, "%d", minute);
hdc = BeginPaint (hwnd, &ps) ;
GetClientRect(hwnd, &rect);
DrawTextA(hdc, "First Program", -1, &rect, DT_CENTER );
TextOutA(hdc, 400, 400, hourptr, 3);
TextOutA(hdc, 450, 400, minuteptr, 3);
if ( repaint_variable == 1)
{
TextOutA(hdc, 0, 0 , "The x coordinate is: ", 22);
TextOutA(hdc, 150, 0, x, 3);
TextOutA(hdc, 0, 30, "The y coordinate is: ", 22);
TextOutA(hdc, 150,30, y, 3);
repaint_variable == 0;
}
if (repaint_variable == 0)
{ return 0; }
EndPaint (hwnd , &ps) ;
return 0 ;
case WM_DESTROY:
PostQuitMessage (0) ;
return 0 ;
}
return DefWindowProc (hwnd, message, wParam, lParam) ;
}
some variable declarations aren't shown in this snippet but they have no importance to this issue.
EDIT+============================================= ===========================
never mind. It was fixed when i used GetLocalTime() instead of GetSystemTime().
Btw, Msdn had a really stupid update, so now you can't even find the parameters for functions in the Winapi it's annoying.