Question

I am subclassing edit control to accept only decimal numbers.

Everything works fine, and the only thing left for me is processing the case when user selects portion of the text and presses Delete key ( VK_DELETE ).

My question is following:

Does pressing a Delete key ( VK_DELETE ) sends some message like WM_CLEAR that I can use for my processing, or do I have to handle WM_KEYDOWN in my subclassing procedure and do the processing there?

Thank you.

Best regards.

Was it helpful?

Solution

After running Spy++ on Notepad's edit control, I have arrived at the conclusion that WM_KEYDOWN/WM_KEYUP is all you get.

<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

The relevant lines are <000010> and <000011>: the WM_KEYDOWN and WM_KEYUP are back-to-back. There's no WM_CLEAR called at all. There is an interesting 0x0118 message, but that shows up on every keypress, not just the delete key.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top