Variable not updating in WM_PAINT after calling InvalidateRect() in WM_COMMAND
I have a global variable 'output' to a structure CALC_DATA...
this variable is used in two places, 1st within WM_PAINT
and secondly within WM_COMMAND where it gets updated...
// Show calculatd results
DisplayResults(hwnd, hdc, output, rsltFont);
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.
if(HIWORD(wParam) == BN_CLICKED)
/* Calculate results from input data */
output = ProcessData(hwnd);
/* Repaint */
InvalidateRect (hwnd, NULL, TRUE);
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?