473,387 Members | 1,578 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

(More info) EnableVisualStyles breaks my program!

Further to previous post...

I have a big, complex program which works fine as long as I don't call
EnableVisualStyles.

If I do this:

Application.EnableVisualStyles();
Application.DoEvents();
Application.Run(new FormOpeningMenu());

then in one of my subordinate forms, which consits of buttons on other
things on a tab control, the non-focused buttons cease to work. Only the
focused on will actually call its OnClick procedure, although all of them
look, visually, as if they are being pressed.

My other forms are unafflicted.

On the afflicted form, the focus is being set programmatically by things
like button1.Select() or button1.Focus() (it doesn't matter which I use).

Does this ring any bells for anyone?

Many thanks!
Jun 22 '06 #1
3 1422
See bottom...
I have a big, complex program which works fine as long as I don't call
EnableVisualStyles.

If I do this:

Application.EnableVisualStyles();
Application.DoEvents();
Application.Run(new FormOpeningMenu());

then in one of my subordinate forms, which consits of buttons on other
things on a tab control, the non-focused buttons cease to work. Only the
focused on will actually call its OnClick procedure, although all of them
look, visually, as if they are being pressed.
Also, you cannot change the focus by hitting Tab.
My other forms are unafflicted.

On the afflicted form, the focus is being set programmatically by things
like button1.Select() or button1.Focus() (it doesn't matter which I use).


In fact, if I do not set focus programmatically (with the Select() or
Focus() method) the problem goes away.

Yet I cannot reproduce the problem in a separate, simpler program. That
makes me wonder if there is something pathological about the form on which
it is happening.

Any ideas?
Jun 22 '06 #2
Many people had problems with EnableVisualStyles()

I know of two solutions - one is to enable visual styles by using manifest
file - see http://weblogs.asp.net/grobinson/arc...25/436464.aspx
another is to enable visual styles "in a custom manner" but I can't find it
now..

Let us know if the solution described in the blog post works for you.

"Michael A. Covington" <lo**@www.covingtoninnovations.com.for.address> wrote
in message news:Or**************@TK2MSFTNGP02.phx.gbl...
See bottom...
I have a big, complex program which works fine as long as I don't call
EnableVisualStyles.

If I do this:

Application.EnableVisualStyles();
Application.DoEvents();
Application.Run(new FormOpeningMenu());

then in one of my subordinate forms, which consits of buttons on other
things on a tab control, the non-focused buttons cease to work. Only the
focused on will actually call its OnClick procedure, although all of them
look, visually, as if they are being pressed.


Also, you cannot change the focus by hitting Tab.
My other forms are unafflicted.

On the afflicted form, the focus is being set programmatically by things
like button1.Select() or button1.Focus() (it doesn't matter which I use).


In fact, if I do not set focus programmatically (with the Select() or
Focus() method) the problem goes away.

Yet I cannot reproduce the problem in a separate, simpler program. That
makes me wonder if there is something pathological about the form on which
it is happening.

Any ideas?

Jun 22 '06 #3
Solved!

I was handling the Paint event of a form and setting focus to certain
buttons when it was painted.

With visual styles turned on, the Paint event arises a lot more often, and
in particular, it arises when the user is starting to press a button. (The
button border changes color.)

So I was stealing the focus away from the button that the user was pressing.

No longer doing that... and it works fine.
Jun 23 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Tom Petersen | last post by:
I am using a response.write to test the formatting of the output. I am supposed to get this: BEGIN:VCALENDAR VERSION:1.0 BEGIN:VEVENT DTSTART:20051022T090000Z DTEND:20051022T090000Z...
9
by: Guy | last post by:
I have extended the datetimepicker control to incorporate a ReadOnly property. I have used the new keyword to implement my own version of the value property, so that if readonly == true then it...
17
by: Lance | last post by:
I've noticed that calling DoEvents is much slower in an application that has called Application.EnableVisualStyles in Sub Main. Furthermore, the performance seems to worsen each time that DoEvents...
3
by: Michael A. Covington | last post by:
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
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...
0
Oralloy
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.