PC Review


Reply
Thread Tools Rate Thread

Application.EnableVisualStyles() breaks my program!

 
 
Michael A. Covington
Guest
Posts: n/a
 
      21st Jun 2006
I added Application.EnableVisualStyles() as the first statement in Main() of
my program, and didn't notice much change in visual appearance, but what I
*did* notice is that some of my buttons stopped working! They were enabled
but no longer called their OnClick methods.

I tried adding Application.DoEvents() right after EnableVisualStyles and
that didn't help.

What gives? In VS 2005/.NET 2.0, is EnableVisualStyles broken? This is
under Windows XP.


 
Reply With Quote
 
 
 
 
Marc Gravell
Guest
Posts: n/a
 
      21st Jun 2006
Works fine from everything I have seen... Does it fix itself if you
remove this line again?

I suspect that what has happened is that at some point you have gone
into the form designer, and it has decided to drop your events from the
init step; this always happens if you cut / paste a control around on
the form, but the designer is also notorious for doing freaky things at
the most inoportune times.

Just check the current (form) class against an old (working) version -
see what changed; I suspect a missing "this.{control}.{event} += {blah
handler};".

And if you think events are brittle in the designer, don't go *near*
data-binding in the designer ;-p

Marc

 
Reply With Quote
 
Tom Spink
Guest
Posts: n/a
 
      21st Jun 2006
Michael A. Covington wrote:

> I added Application.EnableVisualStyles() as the first statement in Main()
> of my program, and didn't notice much change in visual appearance, but
> what I
> *did* notice is that some of my buttons stopped working! They were
> enabled but no longer called their OnClick methods.
>
> I tried adding Application.DoEvents() right after EnableVisualStyles and
> that didn't help.
>
> What gives? In VS 2005/.NET 2.0, is EnableVisualStyles broken? This is
> under Windows XP.


Hi Michael,

Without more information, I'm unable to reproduce your bug. However, a
couple of things to look for is the FlatStyle property of your buttons. It
needs to be set to System in order for them to render in the System's
visual style. Are you using the Windows Forms Designer? Do the visual
styles show up there while you are designing your form?

Thanks,
-- Tom Spink
 
Reply With Quote
 
Michael A. Covington
Guest
Posts: n/a
 
      21st Jun 2006
"Tom Spink" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Michael A. Covington wrote:
>
>> I added Application.EnableVisualStyles() as the first statement in Main()
>> of my program, and didn't notice much change in visual appearance, but
>> what I
>> *did* notice is that some of my buttons stopped working! They were
>> enabled but no longer called their OnClick methods.

>
> Hi Michael,
>
> Without more information, I'm unable to reproduce your bug. However, a
> couple of things to look for is the FlatStyle property of your buttons.
> It
> needs to be set to System in order for them to render in the System's
> visual style. Are you using the Windows Forms Designer? Do the visual
> styles show up there while you are designing your form?
>
> Thanks,
> -- Tom Spink


Thanks for responding. I'm going to check out the FlatStyle property, and
in fact any other property that might distinguish the afflicted buttons from
other ones. Also, the way I create my initial form is rather complicated
(several forms pop up at once when the program starts) and I'm going to
experiment with cutting out all the complexity (even if I lose part of the
program) to see if I can get the problem to go away.

What is really bizarre is that one of the buttons works OK until I put data
into a DataGridView that is on the same form, and then it stops working
properly.


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
(More info) EnableVisualStyles breaks my program! Michael A. Covington Microsoft C# .NET 3 23rd Jun 2006 03:52 PM
NotifyIcon Bug, Application.EnableVisualStyles, Application.DoEvents, and Memory Leaks Michael S. Malley Microsoft Dot NET Framework Forms 0 11th Mar 2004 08:42 PM
NotifyIcon Bug, Application.EnableVisualStyles, Application.DoEvents, and Memory Leaks Michael S. Malley Microsoft Dot NET Framework Forms 0 11th Mar 2004 06:22 PM
NotifyIcon Bug, Application.EnableVisualStyles, Application.DoEvents, and Memory Leaks Michael S. Malley Microsoft Dot NET Framework Forms 0 10th Mar 2004 09:52 PM
EnableVisualStyles breaks PropertyGrid.. =?Utf-8?B?SXVsaWFuIElvbmVzY3U=?= Microsoft Dot NET Framework Forms 3 4th Feb 2004 04:16 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:51 AM.