tags:

views:

487

answers:

1

Hello. I have a WPF application embedded in a Microsoft Outlook 2003 window. Everything is working fine, except none of my TextBox controls accept the backspace key. I've done some research, and the problem exists only when my window is a child of the outlook window and not if it's another window (I injected it into firefox and it works fine, and if I put my wpf UserControl into a dialog window it also works). This seems to be the converse problem that people are reporting (textbox only accepting delete/arrow keys/etc), and this thread was somewhat informative (though did not fix my issue): http://stackoverflow.com/questions/835878/wpf-textbox-not-accepting-input-when-in-elementhost-in-window-forms

Here is my setup: I create a WPF UserControl, which I then put in an ElementHost. I put that host into a Windows Forms UserControl, which gets put in another Forms UserControl, which gets put into a NativeWindow (I've tried removing some of the UserControl wrapping, but with no effect). This Native window then becomes a child of the Outlook window and gets placed where I need it to be in Outlook.

Does anyone have any idea? Maybe I need to handle the windows messages differently? I did some research and found out that Outlook gets a WM_COMMAND message when I hit the backspace key, but not when I don't hit anything else. Maybe it's interpreting the backspace key as a menu accelerator or something like that?

Thanks.

A: 

I found a way to get around this. I extended Outlook's WndProc and listened for the WM_COMMAND. Whenever it came up I tell my WPF UserControl system to send the backspace key to the currently keyboard focused control.

I can't seem to get WM_COMMAND to fire on any other keypress besides backspace so it's working pretty well right now.

Max
Out of interest, do you also compare the value of the WParam or are you only seeing if the event occurs at all? Is this solution still working correctly for you? :-)
traskjd
I just send the backspace on WM_COMMAND because it worked fine. However, Ctrl-Z's also fire a backspace, but it is pretty hard to notice since you are deleting characters anyways in the undo. My thought: I got it working, I've got other things to worry about that actually matter and haven't already been solved :)
Max