| 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 |
Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows フォーム デザイナで生成されたコード " #End Region ' WndProcメソッドをオーバーライドし ' WM_CLOSEメッセージ自体を無視する Protected Overrides Sub WndProc(ByRef m As Message) Const WM_CLOSE As Integer = &H10 ' ウィンドウを閉じない If m.Msg = WM_CLOSE Then ' 閉じる処理をキャンセル m.Result = IntPtr.Zero 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 |
public class Form1 : System.Windows.Forms.Form { // 途中略 // WndProcメソッドをオーバーライドし // WM_CLOSEメッセージ自体を無視する protected override void WndProc( ref Message m ) { const int WM_CLOSE = 0x10; // ウィンドウを閉じない if ( m.Msg == WM_CLOSE ) { // 閉じる処理をキャンセル m.Result = IntPtr.Zero; } else { base.WndProc( ref m ); } } } |