Graphics drawn in improper order...

M

matko

(Due to absolutely no response in ms.pub.dotnet.general, I'm reposting
here...)

When I call the following function, the rectangle will overlap the
graphics that is drawn _afterwards_. Why is that? How can I make sure
my graphics is drawn in correct order?

(Note: If I comment the FillRectangle-line, the other graphics is drawn
correctly.)

private void PaintBox(Graphics g, Brush b, Pen p)
{
// The background rectangle...
g.FillRectangle(b, mBoxRectangle);

// The foreground graphics...
switch (mRegionInfo.Box)
{
case RegionInfo.BoxState.Empty:
break;
case RegionInfo.BoxState.Crossed:
g.DrawLine(p, ...);
g.DrawLine(p, ...);
break;
case RegionInfo.BoxState.Circled:
g.DrawEllipse(p, ...);
break;
}
}
 
M

Michael Bray

(Due to absolutely no response in ms.pub.dotnet.general, I'm reposting
here...)

When I call the following function, the rectangle will overlap the
graphics that is drawn _afterwards_. Why is that? How can I make sure
my graphics is drawn in correct order?

Well if you posted this message to the other newsgroup, I can understand
why you didn't get a response. There is nothing in your code that would
indicate WHY you are seeing the overlap, because you didn't include the
actual code. You just replace a bunch of stuff with "...". That makes it
very hard for us to help.

Please post a *SHORT*, *COMPLETE* program that demonstrates the effect you
are seeing so that we can compile it on OUR machines and see what you are
seeing.

-mdb
 
M

matko

Oh, the replaced-with-"..."-bunch-of-stuff is just size and coordinate
information (which I knew would work). I actually never thought there
was a problem with the code itself (it's a simple piece of code), which
is why I didn't post more than that.

Well, I have solved the issue. Of course, the solution was very simple
(once I discovered the _actual_ problem) and the cause of the problem
was completely my crime... D'oh!
The error lied in the paint-event handler, not the PaintBox method.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top