See comment below. This is a simple problem but I'm a little rusty.
How to break out of a event loop (here _Paint)? I've tried if/else,
case, etc but not quite what I want--I keep getting the JIT system
event exception handler saying "zero area!", or, worse, the Paint loop
refuses to run at all; what I want to do is simply break out of the
_Paint loop, and (optionally) show a MessageBox.
This error happens everytime the "this.ClientRec tange" of the window
being painted becomes zero, that is, everytime this window is
minimized.
So one way around this (perhaps the solution to this problem) is to
set up code so that when a window is minimized, _Paint() is not
executed. Or is there a simplier way?
RL
private void Form2MyDialogBo x_Paint(object sender, PaintEventArgs e)
{
Rectangle rect = this.ClientRect angle;
int cx = rect.Width;
int cy = rect.Height;
bool TrueOrFalseZero Rect;
if ((cx != 0) || (cy !=0)) { TrueOrFalseZero Rect = false; } else
{ TrueOrFalseZero Rect = true; throw new ArgumentExcepti on("zero
area!"); }
// AT THIS POINT IN PAINT, IF THE RECT IS ZERO AREA, I WOULD LIKE TO
BREAK OUT OF PAINT...THE BELOW TRY/CATCH DOESN'T WORK
try
{
// stuff deleted here, not important, basically you get a divide by
zero error when cx=0
}
catch (ArgumentExcept ion ex)
{
MessageBox.Show (ex.ToString()) ;
}
finally
{
brush.Dispose() ; //clean up brush resources
}
}
How to break out of a event loop (here _Paint)? I've tried if/else,
case, etc but not quite what I want--I keep getting the JIT system
event exception handler saying "zero area!", or, worse, the Paint loop
refuses to run at all; what I want to do is simply break out of the
_Paint loop, and (optionally) show a MessageBox.
This error happens everytime the "this.ClientRec tange" of the window
being painted becomes zero, that is, everytime this window is
minimized.
So one way around this (perhaps the solution to this problem) is to
set up code so that when a window is minimized, _Paint() is not
executed. Or is there a simplier way?
RL
private void Form2MyDialogBo x_Paint(object sender, PaintEventArgs e)
{
Rectangle rect = this.ClientRect angle;
int cx = rect.Width;
int cy = rect.Height;
bool TrueOrFalseZero Rect;
if ((cx != 0) || (cy !=0)) { TrueOrFalseZero Rect = false; } else
{ TrueOrFalseZero Rect = true; throw new ArgumentExcepti on("zero
area!"); }
// AT THIS POINT IN PAINT, IF THE RECT IS ZERO AREA, I WOULD LIKE TO
BREAK OUT OF PAINT...THE BELOW TRY/CATCH DOESN'T WORK
try
{
// stuff deleted here, not important, basically you get a divide by
zero error when cx=0
}
catch (ArgumentExcept ion ex)
{
MessageBox.Show (ex.ToString()) ;
}
finally
{
brush.Dispose() ; //clean up brush resources
}
}
Comment