What events can I use to notify a control that part of it has left the visible area of โ€‹โ€‹the screen?

I have a userControl in which I am doing some painting, and when the control is moved to the edge of the screen or is moved so that the Vista taskbar overlaps it, the edge of the screen / taskbar edge refers to the control, leaving ugly lines over the painted area of โ€‹โ€‹the control ...

What is the best way to detect this and call Invalidate on the control? The "Moved" and "LocationChanged" events appear to be related to the movement of the control in its parent container, rather than a change in screen location. I believe the same will happen when the control is overlapped by another window in Windows XP, but I haven't tested it yet. The same question applies in this case.

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

Note. This is a significant rephrasing of an earlier question that was poorly phrased. I felt like starting a new question was doing something, not trying to fix the nonsense I wrote.

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

0


a source to share


2 answers


Yes, you can paint the background to give the illusion of free drawing.



Are you trying to draw a clipped region (clip-rectangle) of a artwork, or are you using its entire surface? I think whenever another window or object hides another object, the windows send its redraw message and thereby pass the area to be redrawn (clip rectangle).

+2


a source


When taking screenshots of the error, it became apparent that the problem was that I was drawing the area described by the ClipRectangle event for Paint, and not using the ClipRectangle of the control itself.

The ClipRectangle of the Paint event describes the area that opens with a single Movement event, and does not describe the border area of โ€‹โ€‹the control. I just managed to move the controls quickly enough to make it obvious that all controls are being pulled into the identified space. I changed the code to draw to an area that matches the size of the control and everything worked fine.



Another question is PEBKAC. Well, at least a bug was found.

0


a source







All Articles