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
}
} 4 2844
"raylopez99 " <ra********@yah oo.comwrote in message
news:a6******** *************** ***********@d77 g2000hsb.google groups.com...
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!"); }
Well, you were outside the try/catch when you threw an exception, so it will
hit the OS and do very bad things. Why not show your MessageBox and return
immediately instead of throwing?
>
// 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
}
}
On Jul 6, 3:55*pm, "Ben Voigt [C++ MVP]" <r...@nospam.no spamwrote:
Well, you were outside the try/catch when you threw an exception, so it will
hit the OS and do very bad things. *Why not show your MessageBox and return
immediately instead of throwing?
Thanks Ben Voigt! Indeed, simply placing the 'throw' * inside the
'try' block solved the problem.
And if you comment out the exception handling, it solves the problem
with no distraction to the user (since a minimized window is not
really an error)
RL
* this code:
if (TrueOrFalseZer oRect)
{
// MessageBox.Show ("zero_area1!") ;
throw new ArgumentExcepti on("zero area!");
}
You shouldnt really throw when there are other options, error handling is
expensive. Why not just have this:
if ((cx != 0) || (cy !=0)) {
TrueOrFalseZero Rect = false;
} else {
TrueOrFalseZero Rect = true;
return ;}
Its the better option, surely?
--
Ciaran O''Donnell http://wannabedeveloper.spaces.live.com
"raylopez99 " wrote:
On Jul 6, 3:55 pm, "Ben Voigt [C++ MVP]" <r...@nospam.no spamwrote:
Well, you were outside the try/catch when you threw an exception, so it will
hit the OS and do very bad things. Why not show your MessageBox and return
immediately instead of throwing?
Thanks Ben Voigt! Indeed, simply placing the 'throw' * inside the
'try' block solved the problem.
And if you comment out the exception handling, it solves the problem
with no distraction to the user (since a minimized window is not
really an error)
RL
* this code:
if (TrueOrFalseZer oRect)
{
// MessageBox.Show ("zero_area1!") ;
throw new ArgumentExcepti on("zero area!");
}
On Jul 7, 6:11*am, Ciaran O''Donnell
<CiaranODonn... @discussions.mi crosoft.comwrot e:
You shouldnt really throw when there are other options, error handling is
expensive. Why not just have this:
Yes, that's much better; for this example, I was using somebody else's
code and for demonstration purposes I was trying to modify it to work
with try/catch.
RL This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Marcin Kielar |
last post by:
hello
i'm searching for algorithm able to detect and resolve conflicts
during recursive event propagation.
I'd like to implement small message passing framework without using
message queue - messages
would be delivered by simple method calls. This leads to recursive
message ordering instead of
natural one - and thus sometimes may cause problems. I know there are
algorithms that detect this
|
by: Robot Tree |
last post by:
how do i break out of an entire method (void return type)?
i have a loop that, under certain conditions, must contain some sort of
method termination (assignment).
does a 'break;' statement break out of the entire method, or just the loop?
thanks for any consideration
|
by: Anand Pillai |
last post by:
This is for folks who are familiar with asynchronous event handling in
Python using the asyncore module.
If you have ever used the asyncore module, you will realize that it's
event loop does not have a programmable exit condition. It keeps
looping till the channels in its socket map (a dictionary) are closed
and don't have any pending reads/writes.
If you are using Python threads in your application, by using either
the threading or...
|
by: lastusernameleft |
last post by:
to what would i attach a key event handler to detect a user pressing ctrl
break to escape a hanging process? a function of an admin tool i've made
allows the browsing of a remote machine's c drive, but hangs when the machine
is offline. i know i could ping the machine first but that would be additonal
overhead to a very simple process.
|
by: Alo Sarv |
last post by:
Hi
From what I have understood from various posts in this newsgroup, writing event
loops pretty much comes down to this:
while (true) {
handleEvents();
sleep(1); // or _sleep() or nanosleep(), depending on platform
}
| |
by: bclegg |
last post by:
Hi,
I am trying to use a 3rd Party telephony (Intel's CT-ADE 8.3) library in
a vb.net service.
The way it hangs up is to raise an Event.
If you build a windows Application you can write:
Sub DoSomeWork
While not Hungup
Do lots of good things
application.doevents
end While
|
by: khng |
last post by:
When there is a HTML Form with lots of input elements, how can I know
which element is triggering the form submit action with the help of
javascript.
|
by: Zytan |
last post by:
Can I break the debugger into a worker thread? Right now, my app is
freezing, and when I press pause, it stops on:
Application.Run(new MyForm());
I don't know what that means. I know the application starts there.
But why would the debugger stop on it? Why doesn't it stop where the
code is being run? I think there's a worker thread that is messed up.
Zytan
|
by: a.mil |
last post by:
I am programming for code-speed, not for ansi or other nice-guy stuff
and I encountered the following problem:
When I have a for loop like this:
b=b0;
for (a=0,i=0;i<100;i++,b--) {
if (b%i) continue;
a=1;
}
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |