2
votes

We have a WPF window hosted in Win32 Window. The implementation is such that when user presses CTRL+V, the text in clipboard is pasted to the TextBox in KeyUp event and not in KeyDown event (due to limitation with TextBox control when being hosted inside MFC). Hence we have overridden KeyUp event to paste the text.

However, in some machines it was noticed that the text is pasted twice on doing CTRL+V only once. On further investigation found that it is pasted for KeyDown (default window behaviour) and also on KeyUp event (overridden by us).

Wondering why is it pasting only on KeyUp even in some machine and in some machine for both KeyDown and KeyUp?

Help will be appreciated.

-Nayan

1
SOME MORE DETAILS Have added a handler for KeyDown event now. Noticed that handler gets called for all the keys except the combination of keys like CTRL+V, CTRL+C.. etc.. here.. handler is not called for V and C keys when pressed with CTRL key.. - Nayan Soni

1 Answers

0
votes

I think it would depend on which control has the focus when you press CTRL+V.

If the edit control has the focus, it would get a WM_PASTE notification and the default WindowProc will paste the clipboard contents into the text box.

If another control has the focus, you'll need to handle CTRL+V yourself to paste into the edit control.