For an outline rectangle, create a colored pen and SetROP2(hdc,
R2_XORPEN); Redrawing the rectangle will then erase it.
For a filled rectangle, the easiest way to make it visible is to
invert it, then invert again when done.
However, other applications can interfere with either method.
Why do you need to paint to the screen DC?
--
Sev
>Again, there's a problem. The solution you told me works nice in some
>situations, but fails in others: That is, when a window has refreshed between
>the interval until I redraw the rectangle, it may have refreshed a part of
>the rectangle (or even the whole). So, when I redraw the rectangle, it draws
>the same rectangle (or part of it that was refreshed) rather than delete it.
>Maybe suggest using another option rather than R2_XORPEN?...
>And another question: If I use the RedrawWindow for the screen, is there any
>possibility that it won't be redrawn (because it doesn't)?
>Any other suggestion please?
I don't know exactly what you're trying to do; but if you want to
capture a part of the desktop to an image, you could capture the
entire desktop at the beginning (mouse button down), display it in a
full-screen window (so that the image is static), then destroy the
window and crop the image when the mouse button is released.
The full-screen capture can take a significant amount of time, so you
may want to display an hourglass between at button down and your
selection cursor once your full-screen copy has painted.
Also, to repaint the entire screen, you can:
InvalidateRect(HWND_DESKTOP, NULL, 0);
--
Sev
void DisplayRefresh(void *n)
{
RECT x;
x.top = 0;
x.left = 0;
x.bottom = 480;
x.right = 640;
while(true)
{
InvalidateRect(hWind,&x,false);
Sleep(150);
}
}
Create the thread in function that Processes messages for the main window.
case WM_CREATE:
hWind = hWnd; // HDC hWind; I declared it as a global
variable
_beginthread(DisplayRefresh,0,NULL);
break;
Hope this helps.
Thanks!
Murugan Andezuthu Dharmaratnam
www.muruganad.net
"Nothing is impossible its just improbable"
"Kingherc" <King...@discussions.microsoft.com> wrote in message
news:A2EF7659-1585-4DCE...@microsoft.com...