using System;
using System.Windows;
using System.Runtime.InteropServices;
using System.Windows.Interop;
namespace DTS.Common.Dialogs
{
///
/// Interaction logic for ConfirmationWindow.xaml
///
public partial class ConfirmationWindow
{
///
/// The content template to use when showing data.
///
public static readonly DependencyProperty ConfirmationTemplateProperty =
DependencyProperty.Register(
"ConfirmationTemplate",
typeof (DataTemplate),
typeof (ConfirmationWindow),
new PropertyMetadata(null));
///
/// Creates a new instance of ConfirmationChildWindow.
///
public ConfirmationWindow()
{
// Hook the SourceInitialized event and then using the SetWindowLong function to strip off the WS_SYSMENU bit.
SourceInitialized += ConfirmationWindow_SourceInitialized;
InitializeComponent();
}
///
/// The content template to use when showing data.
///
public DataTemplate ConfirmationTemplate
{
get => (DataTemplate) GetValue(ConfirmationTemplateProperty);
set => SetValue(ConfirmationTemplateProperty, value);
}
private void ConfirmationWindow_SourceInitialized(object sender, EventArgs e)
{
// Removing the Close Button on a WPF window.
// The key here is hooking the SourceInitialized event and then using the SetWindowLong function to strip off the WS_SYSMENU bit.
var wih = new WindowInteropHelper(this);
var style = GetWindowLong(wih.Handle, GWL_STYLE);
SetWindowLong(wih.Handle, GWL_STYLE, style & ~WS_SYSMENU);
}
private const int GWL_STYLE = -16;
private const int WS_SYSMENU = 0x00080000;
[DllImport("user32.dll")]
private static extern int SetWindowLong(IntPtr hwnd, int index, int value);
[DllImport("user32.dll")]
private static extern int GetWindowLong(IntPtr hwnd, int index);
public void Connect(int connectionId, object target)
{
throw new NotImplementedException();
}
}
}