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
.
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();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.