Form1のコンストラクタで、各種EnableVisualStyleメソッドを使っている事を前提としています。
GWL_STYLEでBS_THEMEを設定後、GWL_EXSTYLEでBS_EX_SIZEWITHCONTROLを設定する。但しButtonには適用できない。
ネイティブの場合CreateWindow関数時にButtonにテーマを設定すればテーマを設定することが可能なのですが、.NET Compact Framework上では簡単にテーマの設定は出来ない様です。(CreateWindow関数を直接P/Invokeで使えば出来るかもしれません。)
C#
[DllImport("coredll")] private static extern int GetWindowLong(IntPtr hwnd, int nIndex); [DllImport("coredll")] private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong); private const int GWL_STYLE = -16; private const int GWL_EXSTYLE = -20; private const int BS_THEME = 0x8000; private const int BS_EX_SIZEWITHCONTROL = 0x0002; public void EnableVisualStyle(ButtonBase button) { int style = GetWindowLong(button.Handle, GWL_STYLE); SetWindowLong(button.Handle, GWL_STYLE, style | BS_THEME); int exstyle = GetWindowLong(button.Handle, GWL_EXSTYLE); SetWindowLong(button.Handle, GWL_EXSTYLE, exstyle | BS_EX_SIZEWITHCONTROL); }






