Private Sub Form_Load() OldWindowProc = GetWindowLong(Form1.hwnd, GWL_WNDPROC) " 取得視窗函式的地址 Call SetWindowLong(Form1.hwnd, GWL_WNDPROC, AddressOf SubClass1_WndMessage) " 用SubClass1_WndMessage代替視窗函式處理訊息 SysMenuHwnd = GetSystemMenu(Form1.hwnd, False) Call AppendMenu(SysMenuHwnd, MF_SEPARATOR, 2000, vbNullString) Call AppendMenu(SysMenuHwnd, MF_STRING, 2001, "關於本程式(&A)") Call AppendMenu(SysMenuHwnd, MF_SEPARATOR, 2002, vbNullString) Call AppendMenu(SysMenuHwnd, MF_STRING, 2003, "恢復系統選單(&R)")End SubPrivate Sub Form_Unload(Cancel As Integer) If OldWindowProc <> GetWindowLong(Form1.hwnd, GWL_WNDPROC) Then Call SetWindowLong(Form1.hwnd, GWL_WNDPROC, OldWindowProc) End IfEnd Sub
Private Sub Form_Load() OldWindowProc = GetWindowLong(Form1.hwnd, GWL_WNDPROC) " 取得視窗函式的地址 Call SetWindowLong(Form1.hwnd, GWL_WNDPROC, AddressOf SubClass1_WndMessage) " 用SubClass1_WndMessage代替視窗函式處理訊息 SysMenuHwnd = GetSystemMenu(Form1.hwnd, False) Call AppendMenu(SysMenuHwnd, MF_SEPARATOR, 2000, vbNullString) Call AppendMenu(SysMenuHwnd, MF_STRING, 2001, "關於本程式(&A)") Call AppendMenu(SysMenuHwnd, MF_SEPARATOR, 2002, vbNullString) Call AppendMenu(SysMenuHwnd, MF_STRING, 2003, "恢復系統選單(&R)")End SubPrivate Sub Form_Unload(Cancel As Integer) If OldWindowProc <> GetWindowLong(Form1.hwnd, GWL_WNDPROC) Then Call SetWindowLong(Form1.hwnd, GWL_WNDPROC, OldWindowProc) End IfEnd Sub