Popup topmost only outlook window - wpf

I have created a Outlook Addin Project and I used WPF user control as element host in UserControl(WinForm) which is loaded using Custom Task Pane.
I have some dragoperation in wpf usercontrol which will open Popup.
The problem is the popup is showing topmost window for all the windows.
I need to show/visible only when outlook window activated. Appreciate your help

You need to make sure your popup is a child of the appropriate Outlook window. You cast Outlook Inspector or Explorer object to IOleWindow interface and call IOleWindow.GetWindow to retrieve HWND. You can then use WindowInteropHelper class along with the retrieved HWND to display your window.

Related

Windows form hidden web browser control does not bring the IE window to foreground

I have created add in for Outlook 2013. It has got a hidden web browser control within it. On button click Web browser loads the speciified data in Internet Explorer window. Content is loading but the IE window does not come to foreground and my outlook will continue be in focus. IE keeps blinking at the task bar.
I want the IE window be in foreground.
If you want to show a Windows Form on top of Outlook window you need to specify the parent window handle. In your case it will be the explorer window handle. To get the handle you need to cast an instance of the Explorer class to the IOleWindow interface which provides the GetWindow method.
The Show or ShowDialog methods of the System.Windows.Form class accepts an instance of the IWin32Window inteface which represents the handle of the parent window. Thus, your window will be shown on top of the parent one.
"Want to launch IE outside the outlook window. – "
In that case use - https://msdn.microsoft.com/en-us/library/System.Diagnostics.Process.Start(v=vs.110).aspx
Process.Start("http://URL");
This will launch the default browser and navigate to the URL specified.

ActiveX control doesn't get focus when right-clicked

I'm working on an ActiveX control which is hosted in MFC and VB6 applications.
This ActiveX contains a WPF control, itself hosted by a WinForms ElementHost, i.e.:
MFC > .NET ActiveX > WinForms ElementHost > WPF UserControl
When an user right-clicks on the control, he must be able to navigate in the contextual menu using the keyboard arrow keys.
If my control has the focus when the right-click occurs, everything works fine.
But if the focus is in the host application when the user right-clicks, keyboard events continue to be sent to the host MFC application.
I tried to call the Focus() method on my WPF control when I detect the right click, but it doesn't work.
Does anybody have an idea ?
Thanks.
I have found a workaround.
When the PreviewMouseRightButtonDown event occurs on the WPF form, I call the Focus method on the WinForm host control.
I don't really understand why, but this lets users use their keyboards to navigate in the contextual menu.

How to handle the MouseRightButtonDown Event for a Window in Silverlight OOB

I want to disable Silverlight contex menu for a Window in Silverlight OOB application
Window wn = new Window();
wn.Show();
For ChildWindow in silverlight I was able to disable the silverlight default context menu which displays "Silverlight" and "Remove this Application" by handling its MouseRightButtonDownEvent
ChilWindow.MouseRightButtonDownEvent +=(s,e)=>{e.handled=true;};
But I am not able to handle the default contex menu here because the Window class is missing the MouseRightButtonDownEvent
If I put a usercontrol inside the window i am able to handle it for the content inside the window however the contex menu is not disabled in the windows title bar.

How to Open modal window/dialog in XBAP Application?

In WPF, if i want to open a modal/response window then i write code like
Window1 _windowObj1 = new Window1();
_windowObj1.Owner = mainWindowObject;
_window1Obj.ShowDialog();
How to do the same in XBAP. I tried it, but the window is opened independently from the parent page as i cant assign it as a Owner of modal window.
How to Open modal window/dialog in XBAP Application?
I'm not really experienced with XBAP apps, but I believe you should try displaying "popups" in an adorner layer. This has the same effect (you can't access the rest of the application), but doesn't actually open another window according to windows. Google for "wpf adorner dialog" and you should get some results.
Here are some links:
How do I make modal dialog for a Page in my WPF-application?
http://www.codeproject.com/KB/silverlight/slmodal.aspx
http://www.codeproject.com/KB/WPF/wpfmodaldialog.aspx
You did implement Window of WPF? If so, it will not work in XBAP. Please host your UserControl to Windows.Form, then you can open modal window/dialog in XBAP Application

How to prevent WebBrowser control from stealing focus from other text box in my WPF form

My WPF app has a window with various text boxes and a WebBrowser control.
The WebBrower control is used to show a web site (I doesn't own) and then a Login button in the WPF window fills the fields in the site from the text boxes.
The problem is that the web site calls focus() method on one of its input fields on load, and that still the focus from the text box in my WPF window. I want the focus to be on the WPF window field and not in the web page within the WebBrowser control.
I tryed calling MyTextBox.Focus() in the WebBrowser's LoadCompleted event, but to no avail. Setting the WebBrowser's IsEnabled or even Visibility properties didn't help either.
Does anyone have an idea how I can overcome this and move the focus to the WPF control instead of the web page input field?
Don't think you can extend the control site to add IProtectFocus to the site. Try interop the Windows Forms version of the webbrowser control and override the CreateWebBrowserSiteBase method to provide your own control site.

Resources