0
app.xaml의 application_exit 및 session_ending 이벤트가 도움이되지 않습니다.Xbap 응용 프로그램 : 사용자가 브라우저 또는 브라우저 탭을 닫을 때 종료 여부를 묻는 메시지를 표시하려면 어떻게합니까?
이것을 달성 할 방법이 있습니까?
app.xaml의 application_exit 및 session_ending 이벤트가 도움이되지 않습니다.Xbap 응용 프로그램 : 사용자가 브라우저 또는 브라우저 탭을 닫을 때 종료 여부를 묻는 메시지를 표시하려면 어떻게합니까?
이것을 달성 할 방법이 있습니까?
XBAP 응용 프로그램의 경우 session_ending 이벤트가 무시됩니다. 그러나 Exit 이벤트는 발생하지만이 이벤트에서 나가는 것을 취소 할 수있는 방법이 표시되지 않습니다. Howevere, 왜 그냥 YES, 명시 적으로는 사용이
가 필요합니다
[DllImport("user32", ExactSpelling = true, CharSet = CharSet.Auto)]
private static extern IntPtr GetAncestor(IntPtr hwnd, int flags);
[DllImport("user32", CharSet = CharSet.Auto)]
private static extern bool PostMessage(IntPtr hwnd, int msg, IntPtr wparam, IntPtr lparam);
private void exitButton_Click(object sender, RoutedEventArgs e)
{
if (MessageBox.Show("Are you Sure you want to Exit?", "Confirm", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
{
// This will Shut entire IE down
WindowInteropHelper wih = new WindowInteropHelper(Application.Current.MainWindow);
IntPtr ieHwnd = GetAncestor(wih.Handle, 2);
PostMessage(ieHwnd, 0x10, IntPtr.Zero, IntPtr.Zero);
// Singularly will just shutdown single tab and leave white screen, however with above aborts the total IE shutdown
// and just shuts the current tab
Application.Current.Shutdown();
}
}
을 여기에 응용 프로그램을 종료하거나없는 경우 종료 버튼 종료를 요청하는 방법을 호출하고 있습니다 System.Windows.Interop; using System.Runtime.InteropServices;