0

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.

Bassie
  • 9,529
  • 8
  • 68
  • 159
Willy
  • 9,848
  • 22
  • 141
  • 284

1 Answers1

0

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();
Bassie
  • 9,529
  • 8
  • 68
  • 159
  • I think it supports only "Windows Vista [desktop apps only]".. Could you please check here? https://msdn.microsoft.com/en-us/library/windows/desktop/bb759827(v=vs.85).aspx – Pavan Chandaka Apr 03 '17 at 20:52
  • 1
    @pavanc It looks like it says vista is a minimum requirement – Bassie Apr 03 '17 at 21:12
  • @Bassie Is it compatible with .NET Framework 1.1? and If I would like to disable visual styles for entire application how I should proceed? – Willy Apr 04 '17 at 08:18