我正在尝试将 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 成功。我错过了什么吗?