I have a global variable 'output' to a structure CALC_DATA...

Code:
CALC_DATA output={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
this variable is used in two places, 1st within WM_PAINT

Code:
	case WM_PAINT:
		{
			hdc=BeginPaint(hwnd, &pntS);

			// Show calculatd results
			DisplayResults(hwnd, hdc, output, rsltFont);

			EndPaint(hwnd, &pntS);
		}
and secondly within WM_COMMAND where it gets updated...

Code:
		case IDBC_RESULTSBUTTON:
			 {
				 if(HIWORD(wParam) == BN_CLICKED)
				 {
					 /* Calculate results from input data */
					 output = ProcessData(hwnd);
					
					 /* Repaint */
					 InvalidateRect (hwnd, NULL, TRUE);
					 UpdateWindow(hwnd);
				 }
			 }
The program initially sets all the edit boxes with values from a file, by pressing the RESULTS button function ProcessData first grabs data from the edit boxes, calculates results and store them in the variable output. Then the window is repainted to call DisplayResults() with the new values on output.

PROBLEM: By changing the values on edit boxes to different values (this time not reading from file), and pressing RESULTS button for the second time, after repaint, results and edit boxes are back to the original values... When i run this on debug mode i notice that new values are correctly read from edit boxes and output within WM_COMMAND is correctly initialized with new results but output in WM_PAINT is still what it was before... Q. How can the same variable have different values in WM_PAINT & WM_COMMAND if declared globally?