내 winforms 프로젝트를 WPF로 변환하고 WPF를 배우면서 수행 중입니다. WPF VB.NET WM_APPCOMMAND
나는이 코드는 미디어 키보드 또는 미디어 센터 리모컨을 누르면 버튼을 감지이 코드에 문제가 다 퉜다.
Protected Overrides Sub WndProc(ByRef msg As Message)
If msg.Msg = &H319 Then
' WM_APPCOMMAND message
' extract cmd from LPARAM (as GET_APPCOMMAND_LPARAM macro does)
Dim cmd As Integer = CInt(CUInt(msg.LParam) >> 16 And Not &HF000)
Select Case cmd
Case 13
MessageBox.Show("Stop Button")
Exit Select
Case 47
MessageBox.Show("Pause Button")
Exit Select
Case 46
MessageBox.Show("Play Button")
Exit Select
End Select
End If
MyBase.WndProc(msg)
end sub
WPF에서 작동 시키거나 유사한 작업을 수행 할 수있는 방법이 있는지 궁금합니다.
편집
내 최신 시도, 나는 그것이 어쩌면 잘못 될 수 있도록 C 번호로 변환하려고 노력했다.
Dim src As HwndSource = HwndSource.FromHwnd(New WindowInteropHelper(Me).Handle)
src.AddHook(New HwndSourceHook(AddressOf WndProc))
및
Public Function WndProc(hwnd As IntPtr, msg As Integer, wParam As IntPtr, lParam As IntPtr, ByRef handled As Boolean) As IntPtr
'Do something here
If msg = "WM_APPCOMMAND" Then
MessageBox.Show("dd")
End If
Return IntPtr.Zero
End Function
은 내가 곧 정상 궤도에 오전 또는 내가 해제 방법입니다 (이것은 단지 내 응용 프로그램 충돌)?
그래서 당신은 WPF 응용 프로그램에서의 WndProc을 대체하려면? –
예, 멀티미디어 키를 쉽게 캡처 할 수있는 경우가 아니면. – Mattigins
가능한 중복 [WPF에서 WndProc 메시지를 처리하는 방법] (http://stackoverflow.com/questions/624367/how-to-handle-wndproc-messages-in-wpf) –