我正在尝试将Ctrl + C命令(复制文本)发送到自定义句柄,因此无法获得焦点。
我在Spy ++中查看了消息:
<000001> 00540824 S WM_GETDLGCODE wParam:00000011 lParam:0018D218
<000002> 00540824 R WM_GETDLGCODE fuDlgCode:DLGC_WANTARROWS [lResult:00000001]
<000003> 00540824 S WM_GETDLGCODE wParam:00000043 lParam:0018D218
<000004> 00540824 R WM_GETDLGCODE fuDlgCode:DLGC_WANTARROWS [lResult:00000001]
<000005> 00540824 S WM_GETDLGCODE wParam:00000003 lParam:0018D218
<000006> 00540824 R WM_GETDLGCODE fuDlgCode:DLGC_WANTALLKEYS [lResult:00000004]
所以我尝试重现这个C#(WM_GETDLGCODE = 0x0087):
[DllImport("user32.dll")]
public static extern int SendMessage(IntPtr hWnd, uint Msg, uint wParam, uint lParam);
...
SendMessage(new IntPtr(0x00540824), 0x0087, 0x00000011, 0x0018D218);
SendMessage(new IntPtr(0x00540824), 0x0087, 0x00000043, 0x0018D218);
SendMessage(new IntPtr(0x00540824), 0x0087, 0x00000003, 0x0018D218);
但是,结果,Spy ++告诉我:
<000001> 00540824 S WM_GETDLGCODE wParam:00000011 lParam:0018D3C4
<000002> 00540824 R WM_GETDLGCODE fuDlgCode:DLGC_WANTARROWS [lResult:00000001]
<000003> 00540824 S WM_GETDLGCODE wParam:00000043 lParam:0018D3C4
<000004> 00540824 R WM_GETDLGCODE fuDlgCode:DLGC_WANTARROWS [lResult:00000001]
<000005> 00540824 S WM_GETDLGCODE wParam:00000003 lParam:0018D3C4
<000006> 00540824 R WM_GETDLGCODE fuDlgCode:DLGC_WANTALLKEYS [lResult:00000004]
我不明白lParam的变化。 Ctrl + C命令不会执行。单击鼠标的PostMessage成功。我错过了什么吗?