Groups | Blog | Home
all groups > dotnet windows forms > february 2008 >

dotnet windows forms : Disabling EnableVisualStyles in C#



Herfried K. Wagner [MVP]
2/7/2008 12:00:00 AM
"Sujay Ghosh" <SujayGhosh@discussions.microsoft.com> schrieb:
[quoted text, click to view]

P/invoke with the 'SetWindowTheme' function can be used to disable Windows
XP visual styles for a certain window.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Sujay Ghosh
2/7/2008 8:23:04 AM
Hi ,

Environment : .NET 2.0 / VS2005

I am creating a usercontrol ( progressbar ) and every time I add my control
to the project it gives a XP progress bar because of the EnableVisualStyles
function .

I want to suppress the EnableVisualStyles from within my component .

I want the normal Windows 2000 look .

Please let me know how can I acheive this .

Thanks in advance .

Sujay

--
Sujay Ghosh
Bangalore, INDIA

Sujay Ghosh
2/8/2008 3:18:01 AM
Hi ,

I am calling SetWIndowTheme( ) in the InitializeComponent() , and then add
the DLL to my form - the look is proper ( like Windows 2000 ).

But when I start the progress bar using the following code . the theme color
reverts back to XP .

MY COMPONENT
// Progress Bar Component

InitializeComponent ()
{
Core.SetWindowsTheme(myprogressbar.handle, " " , " " )
}

void StartProgessBar ( )
{
myprogressbar.Step = 30;
myprogressbar.PerformStep( ) ;
}

WINDOWS FORMS

// WIndows Forms generated Code
// with EnableVisualStyles


// OnClickButton
{
// Start the progressbar
myProgressMeterComponent.StartProgessBar( );

// I get the XP look again
}


Am I going wrong somewhere .

Please let me know.

Thanks ,

Sujay


--
Sujay Ghosh
Bangalore, INDIA




[quoted text, click to view]
AddThis Social Bookmark Button