我正在子类化编辑控件以只接受十进制数字。
一切都很好,我唯一要做的就是处理当用户选择部分文本并按下Delete
键(VK_DELETE
)时的情况。
我的问题如下:
是否按下Delete
键(VK_DELETE
)发送一些消息,如WM_CLEAR
,我可以使用我的处理,或者我必须在子类化过程中处理WM_KEYDOWN
,并在那里进行处理?
谢谢。
问好。
在Notepad的编辑控件上运行spy++后,我得出的结论是WM_KEYDOWN
/WM_KEYUP
是所有你得到的。
<000001> 0015082E S WM_KILLFOCUS hwndGetFocus:0015082E
<000002> 0015082E R WM_KILLFOCUS
<000003> 0015082E S WM_SETFOCUS hwndLoseFocus:002D0830
<000004> 0015082E R WM_SETFOCUS
<000005> 0015082E P message:0x0118 [Unknown] wParam:0000FFFF lParam:FFFFF960001DA744
<000006> 0015082E P message:0x0118 [Unknown] wParam:0000FFFF lParam:FFFFF960001DA744
<000007> 0015082E P message:0x0118 [Unknown] wParam:0000FFFF lParam:FFFFF960001DA744
<000008> 0015082E P message:0x0118 [Unknown] wParam:0000FFFF lParam:FFFFF960001DA744
<000009> 0015082E P message:0x0118 [Unknown] wParam:0000FFFF lParam:FFFFF960001DA744
<000010> 0015082E P WM_KEYDOWN nVirtKey:VK_DELETE cRepeat:1 ScanCode:53 fExtended:1 fAltDown:0 fRepeat:0 fUp:0
<000011> 0015082E P WM_KEYUP nVirtKey:VK_DELETE cRepeat:1 ScanCode:53 fExtended:1 fAltDown:0 fRepeat:1 fUp:1
<000012> 0015082E P message:0x0118 [Unknown] wParam:0000FFFF lParam:FFFFF960001DA744
<000013> 0015082E P message:0x0118 [Unknown] wParam:0000FFFF lParam:FFFFF960001DA744
<000014> 0015082E P message:0x0118 [Unknown] wParam:0000FFFF lParam:FFFFF960001DA744
<000015> 0015082E P message:0x0118 [Unknown] wParam:0000FFFF lParam:FFFFF960001DA744
<000016> 0015082E P message:0x0118 [Unknown] wParam:0000FFFF lParam:FFFFF960001DA744
<000017> 0015082E S EM_GETSEL lpdwStart:0020F330 lpdwEnd:0020F334
<000018> 0015082E R EM_GETSEL wStart:2 wEnd:2 lpdwStart:0020F330 (2) lpdwEnd:0020F334 (2)
<000019> 0015082E S WM_KILLFOCUS hwndGetFocus:(null)
<000020> 0015082E R WM_KILLFOCUS
相关行是<000010>
和<000011>
: WM_KEYDOWN
和WM_KEYUP
是背靠背的。根本没有调用WM_CLEAR
。是一个有趣的0x0118消息,但它显示在每个按键上,而不仅仅是删除键。