Strange form behavior....

C

craig

I was wondering if anyone might have any idea at all what might cause the
close button on a Windows Form to stop responding.

When my form is first brough up, the close button works as it should, but
after a while it stops repsonding when clicked on. The form can still be
closed through code, but not the button. What could I possibly have done to
cause this without explicitely disabling this button??

Any thoughts would be appreciated!
 
S

Saurabh

If you are handling WM_NC messages, make sure that you honour the default
behaviour if the NCHITTEST is in the close button.

--Saurabh
 
H

Herfried K. Wagner [MVP]

* "craig said:
I was wondering if anyone might have any idea at all what might cause the
close button on a Windows Form to stop responding.

When my form is first brough up, the close button works as it should, but
after a while it stops repsonding when clicked on. The form can still be
closed through code, but not the button. What could I possibly have done to
cause this without explicitely disabling this button??

Maybe the famous "form close bug"?

C# code to repro the close bug:

<http://www.jelovic.com/binaries/WindowsFormsCloseBugDemo.zip>

Some information on the bug:

<http://makeashorterlink.com/?T2FC26194>

Fixed in .NET 1.1.
 
C

craig

Sorry for the delay....I ran the sample program but I did not experience the
bug. The form closed as it should on my system.

I wonder if I have discovered another bug???


craig said:
Thanks.....I will check this out and let you know if I experience the bug.
 
H

Herfried K. Wagner [MVP]

* "craig said:
Sorry for the delay....I ran the sample program but I did not experience the
bug. The form closed as it should on my system.

I wonder if I have discovered another bug???

I don't know about another bug. But now we are sure that it's another
bug. Do you use any 3rd party components on the form?
 
C

craig

Yes, I am using Infragistics controls in the form. I will try to determine
at what point in the execution of the code I notice the close button
beginning to stop responding.
 
H

Herfried K. Wagner [MVP]

* "craig said:
Yes, I am using Infragistics controls in the form. I will try to determine
at what point in the execution of the code I notice the close button
beginning to stop responding.

Would be great if you post your experiences with the problem here.
 
C

craig

Well......I didn a little research today into the problem I was having in
which my main form would not close using the close button.

I was able to isolate the problem to a line of code that removed a form from
a panel control collection. In other words, if, in the course of running my
app, the following line of code executed:

panel1.Controls.Remove(_form2);

I could no longer close the form using the control button. But if I
commented out this line, everything worked as it should.

I noticed that if I added a form closing event handler and checked the event
arguments, that e.Cancel was set to true in the handler. I never set it to
true anywhere, so I am not sure how this was happening.


craig said:
I will do my best!
 

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