如何禁止和允许窗体部分或全部的视觉主题?
How to disable some or all controls in my delphi program?
By Kingron
Delphi中没有直接提供UxTheme.pas单元,可以自己去JEDI下载或者去网络上面找找这个单元即可。
uses UxTheme;
{ 禁止部分控件的视觉主题 }
{ Disable Theme for some controls }
procedure DisableTheme ( Control : TWinControl ); var i : Integer ; begin LockWindowUpdate ( Control . Handle ); try SetWindowTheme ( Control . Handle , '' , '' ); for i := 0 to Control . ControlCount - 1 do if Control . Controls [ i ] is TWinControl then DisableTheme ( TWinControl ( Control . Controls [ i ])); finally LockWindowUpdate ( 0 ); end ; end ; procedure TForm1 . Button1Click ( Sender : TObject ); begin DisableTheme ( Self ); end ;
如果要禁止程序所有的Theme,则只要去掉 那个WinXP.RES中的24号资源即可。