サブクラスでかいけつ
Dim Button as HWND
Dim DefaultWndProc As DWord
'SubClass
Function SubClass(hWnd As HWND, dwMsg As DWord, wParam As WPARAM, lParam As LPARAM) As DWord
If dwMsg = WM_RBUTTONUP Then
MessageBox(hMainWnd, "右クリック", "test", MB_OK)
End If
SubClass=CallWindowProc(DefaultWndProc, hWnd,dwMsg,wParam,lParam)
End Function
Sub MainWnd_Create(ByRef CreateStruct As CREATESTRUCT)
Button = GetDlgItem(hMainWnd, CommandButton1)
DefaultWndProc=GetWindowLong(Button,GWL_WNDPROC)
SetWindowLong(Button,GWL_WNDPROC,AddressOf(SubClass))
End Sub
|