From 0aabda8caff1db84cdf096357fed75e4da9232f2 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Thu, 9 Sep 2010 10:47:48 +0200 Subject: [PATCH] added ExtendedPopup --- .../ExtendedPopup.cs | 54 +++++++++++++++++++ .../ICSharpCode.Core.Presentation.csproj | 1 + 2 files changed, 55 insertions(+) create mode 100644 src/Main/ICSharpCode.Core.Presentation/ExtendedPopup.cs diff --git a/src/Main/ICSharpCode.Core.Presentation/ExtendedPopup.cs b/src/Main/ICSharpCode.Core.Presentation/ExtendedPopup.cs new file mode 100644 index 0000000000..cc0e2399ed --- /dev/null +++ b/src/Main/ICSharpCode.Core.Presentation/ExtendedPopup.cs @@ -0,0 +1,54 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using System.Runtime.InteropServices; +using System.Windows; +using System.Windows.Controls.Primitives; +using System.Windows.Interop; + +namespace ICSharpCode.Core.Presentation +{ + /// + /// Description of ExtendedPopup. + /// + public class ExtendedPopup : Popup + { + RoutedEventHandler lostFocus; + RoutedEventHandler gotFocus; + +// protected override void OnOpened(EventArgs e) +// { +// IntPtr hwnd = ((HwndSource)PresentationSource.FromVisual(Child)).Handle; +// SetWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); +// lostFocus = new RoutedEventHandler(MainWindowLostFocus); +// gotFocus = new RoutedEventHandler(MainWindowGotFocus); +// AddHandler(Window., lostFocus); +// AddHandler(Window.GotFocusEvent, gotFocus); +// +// } +// +// protected override void OnClosed(EventArgs e) +// { +// RemoveHandler(Window.LostFocusEvent, lostFocus); +// RemoveHandler(Window.GotFocusEvent, gotFocus); +// } +// +// void MainWindowLostFocus(object sender, RoutedEventArgs e) +// { +// Visibility = Visibility.Collapsed; +// } +// +// void MainWindowGotFocus(object sender, RoutedEventArgs e) +// { +// Visibility = Visibility.Visible; +// } + + const int SWP_NOMOVE = 0x002; + const int SWP_NOSIZE = 0x001; + static readonly IntPtr HWND_NOTOPMOST = new IntPtr(-2); + + [DllImport("user32", EntryPoint="SetWindowPos")] + static extern int SetWindowPos(IntPtr hWnd, IntPtr hwndInsertAfter, int x, int y, int cx, int cy, uint uFlags); + } +} diff --git a/src/Main/ICSharpCode.Core.Presentation/ICSharpCode.Core.Presentation.csproj b/src/Main/ICSharpCode.Core.Presentation/ICSharpCode.Core.Presentation.csproj index 5cc665459c..ecf4c7e574 100644 --- a/src/Main/ICSharpCode.Core.Presentation/ICSharpCode.Core.Presentation.csproj +++ b/src/Main/ICSharpCode.Core.Presentation/ICSharpCode.Core.Presentation.csproj @@ -69,6 +69,7 @@ Properties\GlobalAssemblyInfo.cs +