Disable/turn off visual styles/theming for just a single form

1.5k Views Asked by At

I have a winforms application. Main form has some buttons that open other forms on click.

There is a form I would like to disable visual styles/theme. Also I would like to disable visual styles for its childs. Is it possible? If so how?

For example, suppose I have three buttons on main form:

  • Button1 opens form1 on click
  • Button2 opens form2 on click
  • Button3 opens form3 on click

so when I click Button2 I would like to only disable visual styles on it but I would like to keep visual styles enabled for forms: form1 and form3.

1

There are 1 best solutions below

3
Bassie On

You can do this with PInvoke SetWindowTheme:

[DllImport("uxtheme.dll")]
private static extern int SetWindowTheme(IntPtr hWnd, string appname, string idlist);

Then for example in your button2 event handler:

var form2 = new Form2();
SetWindowTheme(form2.Handle, "", "");
form2.Show();