Anyway, Ron, I've just tested the solution you were proposing but no luck: it still happens the same. Application hangs. It seems as though the problem is more on the MFC side than on the WPF side, but it's only a guess... Thanks, Oscar
OscarOrtega
Posts
-
WebBrowser hosted in a WPF user control called from MFC dialog hangs when pressing the TAB key. -
WebBrowser hosted in a WPF user control called from MFC dialog hangs when pressing the TAB key.Thank you for your answer Ron. The problem is that I'm using the browser to display an InfoPath form, so the user will expect the TAB to be working "as usual" in order to change focus from control to control. So if I tell the user that he's going to lose the TAB key... well, maybe he's not going to be very happy. But thanks, it's a good a idea if everything else fails to work. Oscar
-
WebBrowser hosted in a WPF user control called from MFC dialog hangs when pressing the TAB key.Hello again, I've reproduced the problem in a small program. First, I've built a WPF Control Library with a WebBrowser embedded. Then, I've built a simple MFC application that calls this control. The result is the same: Whenever I press the TAB key inside the WebBrowser the application hangs and stops responding. Next, I'm posting the code of this simple project. Please, could someone give me any clue about could be happening? The WPF control library contains the following code: In the XAML file: Then in the .cs file:
namespace WpfControlLibrary1 { /// <summary> /// Interaction logic for UserControl1.xaml /// </summary> public partial class UserControl1 : UserControl { public UserControl1() { InitializeComponent(); } private void UserControl_Loaded(object sender, RoutedEventArgs e) { string destUrl = "http://www.google.es"; webBrowser1.Url = new Uri(destUrl); } /* Uncomment for WPF frame test private void Frame_LoadCompleted(object sender, NavigationEventArgs e) { } */ } }
For the application holding the WPF control, I've built a simple MFC application in which I added a class compiled with the /clr option to manage the transition between MFC (unmanaged) and WPF (managed). Following these lines is the code of this class:{...} #include <vcclr.h> using namespace System; using namespace System::Windows; using namespace System::Windows::Controls; using namespace System::Windows::Interop; using namespace WpfControlLibrary1; ref class Globals { public: static System::Windows::I
-
WebBrowser hosted in a WPF user control called from MFC dialog hangs when pressing the TAB key.Hi colleagues, I'm dealing with a weird scenario that I will try to explain here. I don't know what more can I do to find a solution, so I'm posting here with the expectation that someone can help me. I created a user control using WPF & C# in .NET 3.5 with VS2008. This control is placed in a dll. The control has a toolbar, a tree view on the right side and a browser on the left. Inside the XAML code, I'm inserting the WebBrowser control hosted in a WindowsFormsHost. If I use this control from a Container that uses WPF as well everything works fine. The problems arise when I try to call the mentioned control from an MFC application. I created a modeless dialog and call my WPF control. The first problem was that WM_CHARS messages were eaten up by someone, and I didn't receive any keystroke in my WPF control. Hopefully, I found this useful link that helped me to solve the problem: http://devonethatdevelops.wordpress.com/2007/10/30/wpf-win32-interop-with-hwndsource/ But the main problem is that when I put the focus in the web browser and press the TAB key, both the modeless dialog and the application hang. The only thing I can do is go to the task manager and end the process. I've been searching similar problems but found nothing. I've tried to put breakpoints on every KeyDown event both in the containing dialog and in the user control but nothing happens. It seems as though the TAB key absolutely swollen by don't-know-who. I've executed the WPF control from a WPF container and the KeyDown events reach my control on every key I press, but when I call it from the MFC dialog the program don't stop in the breakpoints. The only thing I know is that pressing the TAB key inside the web browser control frozens the application. Please, do you have any idea of what could be happening? Any clue? Well, thanks anyway for having had the patience of reading this. Oscar Ortega