Files
DP44/Common/DTS.Common/Dialogs/ConfirmationWindow.xaml.cs
2026-04-17 14:55:32 -04:00

67 lines
2.5 KiB
C#

using System;
using System.Windows;
using System.Runtime.InteropServices;
using System.Windows.Interop;
namespace DTS.Common.Dialogs
{
/// <summary>
/// Interaction logic for ConfirmationWindow.xaml
/// </summary>
public partial class ConfirmationWindow
{
/// <summary>
/// The content template to use when showing <see cref="DTS.Common.Interactivity.InteractionRequest.Confirmation"/> data.
/// </summary>
public static readonly DependencyProperty ConfirmationTemplateProperty =
DependencyProperty.Register(
"ConfirmationTemplate",
typeof(DataTemplate),
typeof(ConfirmationWindow),
new PropertyMetadata(null));
/// <summary>
/// Creates a new instance of ConfirmationChildWindow.
/// </summary>
public ConfirmationWindow()
{
// Hook the SourceInitialized event and then using the SetWindowLong function to strip off the WS_SYSMENU bit.
SourceInitialized += ConfirmationWindow_SourceInitialized;
InitializeComponent();
}
/// <summary>
/// The content template to use when showing <see cref="DTS.Common.Interactivity.InteractionRequest.Confirmation"/> data.
/// </summary>
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();
}
}
}