This is supposed to draw a 1000 x 750 image in 10 horizontal sections. The purpose is to provide
an indication that that something is in progress. (it takes a couple seconds to complete)
As shown, it hangs up. It draws the first 1/10 section, then shows the complete image when it's been
completed. Then it hangs.
If I remove the UpdateWindow(hWnd) statement, it doesn't hang up. But it doesn't draw 10 horizontal
sections either. It completes the image internally, then displays it all at once.
Is it not possible to send multiple InvalidatRect() as shown? Should there be only one per window message?
ifields[] is an array of RECT type structures storing the 10 horizontal sections.
Code:
LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{ case WM_KEYDOWN:
keyinterpret(wParam);
break;
case WM_LBUTTONDOWN :
xyinterpret(lParam);
break;
case WM_PAINT:
updateclient(hWnd);
break;
case WM_CLOSE:
//if(MessageBox(hWnd, "Exit Pogram?", "", MB_YESNO | MB_DEFBUTTON2) == IDNO)
//return 1;
//else
terminate();
DestroyWindow(hWnd);
return 0;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, msg, wParam, lParam);
}
updatefields();
update = 0;
return 0;
}
void updateclient(HWND hWnd)
{
HDC hDcPaint;
PAINTSTRUCT ps;
hDcPaint = BeginPaint(hWnd, &ps);
BitBlt(hDcPaint, ps.rcPaint.left, ps.rcPaint.top,
ps.rcPaint.right-ps.rcPaint.left, ps.rcPaint.bottom-ps.rcPaint.top,
hMemdc, ps.rcPaint.left, ps.rcPaint.top, SRCCOPY);
EndPaint(hWnd, &ps);
}
void drawimage(void)
{ int i, n, x, y, y1, y2;
if(imagestat)
{ n = mapsizey/10;
for(i = 0; i < 10; i++)
{ y1 = i*n;
y2 = y1+n;
for(y = y1; y < y2; y++)
for(x = 0; x < mapsizex; x++)
SetPixel(hMemdc, x+ifield.left, y+ifield.top, spectrum[map[x][y]]);
InvalidateRect(hWnd, &ifields[i], 0);
UpdateWindow(hWnd);
}
}
}