| VB.NET | |
|
001 002 003 004 005 006 007 008 009 010 011 012 013 014 015 016 017 018 019 020 021 022 023 024 025 026 027 028 029 030 031 032 033 034 035 036 037 038 039 040 041 042 043 044 |
Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows フォーム デザイナで生成されたコード " #End Region ' WndProcメソッドをオーバーライド Protected Overloads Overrides Sub WndProc(ByRef m As Message) Const WM_SYSCOMMAND As Integer= &H112 Const SC_RESTORE As Integer = &HF120 Const SC_TASKLIST As Integer = &HF130 Const SC_MOVE As Integer = &HF010 ' メッセージがWM_SYSCOMMANDの時 If m.Msg = WM_SYSCOMMAND Then ' 下位4ビット以外を取得 Dim command As Integer = m.WParam.ToInt32() And &HFFF0 If command = SC_MOVE OrElse _ command = SC_TASKLIST OrElse _ command = SC_RESTORE Then ' 戻り値に0を指定する m.Result = New IntPtr(0) Else ' デフォルトの処理を行う MyBase.WndProc(m) End If Else ' デフォルトの処理を行う MyBase.WndProc(m) End If End Sub End Class |
| C# | |
|
001 002 003 004 005 006 007 008 009 010 011 012 013 014 015 016 017 018 019 020 021 022 023 024 025 026 027 028 029 030 031 032 033 034 035 036 |
public class Form1 : System.Windows.Forms.Form { // 途中略 // WndProcメソッドをオーバーライド protected override void WndProc( ref Message m ) { const int WM_SYSCOMMAND = 0x0112; const int SC_RESTORE = 0xf120; const int SC_TASKLIST = 0xf130; const int SC_MOVE = 0xf010; // メッセージがWM_SYSCOMMANDの時 if ( m.Msg == WM_SYSCOMMAND ) { // 下位4ビット以外を取得 int command = m.WParam.ToInt32() & 0xfff0; if ( command == SC_MOVE || command == SC_TASKLIST || command == SC_RESTORE ) { // 戻り値に0を指定する m.Result = IntPtr.Zero; } else { // デフォルトの処理を行う base.WndProc( ref m ); } } else { // デフォルトの処理を行う base.WndProc( ref m ); } } } |