Home All Groups Group Topic Archive Search About

Enable Visual Styles after application has started

Author
1 Jun 2010 9:55 PM
JB
Hi All,

I want to dynamically change the Application.EnableVisualStyles flag.
I have an application that uses a startup form (.Net Framework 2.0)
and if I set the EnableVisualStyles in the Application.Startup event
it doesn't work.
The only way it works is if I set this flag at design time in the
Application properties.
Any suggestions on how I can change this flag dynamically without
using Sub Main()?

Thanks
JB

Author
1 Jun 2010 10:39 PM
Armin Zingler
Am 01.06.2010 23:55, schrieb JB:
> Hi All,
>
> I want to dynamically change the Application.EnableVisualStyles flag.
> I have an application that uses a startup form (.Net Framework 2.0)
> and if I set the EnableVisualStyles in the Application.Startup event
> it doesn't work.
> The only way it works is if I set this flag at design time in the
> Application properties.
> Any suggestions on how I can change this flag dynamically without
> using Sub Main()?

My IDE is not able to correctly find 'EnableVisualStyles' (one of the
My.Crap issues), but you can try to set the property to False in the
project's properties and, in addition, conditionally call
System.Windows.Forms.Application.EnableVisualStyles().

--
Armin
Author
1 Jun 2010 10:54 PM
Armin Zingler
Am 02.06.2010 00:39, schrieb Armin Zingler:
> ... in addition, conditionally call
> System.Windows.Forms.Application.EnableVisualStyles().

I mean, call it from the Application.Startup event handler.


--
Armin
Author
1 Jun 2010 11:53 PM
JB
On 1 June, 15:54, Armin Zingler <az.nos***@freenet.de> wrote:
> Am 02.06.2010 00:39, schrieb Armin Zingler:
>
> > ... in addition, conditionally call
> > System.Windows.Forms.Application.EnableVisualStyles().
>
> I mean, call it from the Application.Startup event handler.
>
> --
> Armin

Hi Armin,

That's what I do. I call
System.Windows.Forms.Application.EnableVisualStyles() from the
Application.Startup. And it doesn't work.

JB
Author
2 Jun 2010 1:24 AM
Armin Zingler
Am 02.06.2010 01:53, schrieb JB:
> On 1 June, 15:54, Armin Zingler <az.nos***@freenet.de> wrote:
>> Am 02.06.2010 00:39, schrieb Armin Zingler:
>>
>>> ... in addition, conditionally call
>>> System.Windows.Forms.Application.EnableVisualStyles().
>>
>> I mean, call it from the Application.Startup event handler.
>>
>
> That's what I do.

Ok. You wrote "Application.EnableVisualStyles flag". Therefore I thought
you meant

    Application.EnableVisualStyles = True/False

which sets the property
Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.EnableVisualStyles.

> I call
> System.Windows.Forms.Application.EnableVisualStyles() from the
> Application.Startup. And it doesn't work.

I've tried it and it did work. Don't know what's different.
I haven't tried it with a Splash Screen. .... Now I did but it doesn't
make a difference.


--
Armin
Author
2 Jun 2010 2:36 PM
JB
On 1 June, 18:24, Armin Zingler <az.nos***@freenet.de> wrote:
Show quoteHide quote
> Am 02.06.2010 01:53, schrieb JB:
>
> > On 1 June, 15:54, Armin Zingler <az.nos***@freenet.de> wrote:
> >> Am 02.06.2010 00:39, schrieb Armin Zingler:
>
> >>> ... in addition, conditionally call
> >>> System.Windows.Forms.Application.EnableVisualStyles().
>
> >> I mean, call it from the Application.Startup event handler.
>
> > That's what I do.
>
> Ok. You wrote "Application.EnableVisualStyles flag". Therefore I thought
> you meant
>
>         Application.EnableVisualStyles = True/False
>
> which sets the property
> Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.EnableVisualStyles.
>
> > I call
> > System.Windows.Forms.Application.EnableVisualStyles() from the
> > Application.Startup. And it doesn't work.
>
> I've tried it and it did work. Don't know what's different.
> I haven't tried it with a Splash Screen. .... Now I did but it doesn't
> make a difference.
>
> --
> Armin

Hi Armin,

Sorry my mistake, I didn't read your post correctly.
I used System.Windows.Forms.Application.EnableVisualStyles() as you
suggested and it works perfectly.

Thank you very much.
JB