views:

36

answers:

2

Hi, I have a userControl I'm doing some Painting to, and when the control is moved to the edge of the screen, or moved so that the Vista Taskbar overlaps it, the screen edge/taskbar edge is being drawn to the control, leaving ugly lines over the paintable area of the control.

What is the best way to detect this and call Invalidate on the control? The "Moved" and "LocationChanged" events apparently deal with the movement of the control within its parent container, not with a change in screen location. I believe the same thing will occur when the control is overlapped by another window in Windows XP, but I haven't tested that yet. Same question applies under that circumstance.

I am currently drawing directly to the control's Graphics object, which I believe is the root of the problem. Would it be better to draw to the Control's BackGroundImage as an attempt to sidestep this issue?

Note: This is a significant rephrasing of an earlier question which was phrased very badly. I felt that starting a new question was the thing to do, rather than try to repair the nonsense I had written.

EDIT: It turns out that the taskbar is not causing the problem, just the bottom screen edge. I had thought that the taskbar was causing problems as well, but it looks like I was wrong

+2  A: 

Yes you can draw control's background to give illusion problem free drawing.

Are you trying to draw on the clipped area (Clip Rectangle) of the graphics object or using whole surface of it? I think whenever another window or object hides an other object windows sends it repaint message and with that it passes the area that needs to be redrawn (clip rectangle).

TheVillageIdiot
A: 

While making screenshots of the error occurring, it became obvious that the problem was that I was drawing an area described by the ClipRectangle of the Paint event, and not by the ClipRectangle of the control itself.

The ClipRectangle of the Paint event describes the area that is being revealed by a single Movement event, it does not describe the area of the bounds of the Control. I simply happened to move the control fast enough that it became obvious that the entire control was being drawn into the revealed space. I altered the code to draw to an area corresponding to the size of the control and everything worked fine.

Another PEBKAC question. Oh well, at least the error was found.

Frosty840
Reread trailblazer's answer I realised it's actually correct. I had misread "clip rectangle" as "client rectangle".
Frosty840