2009-10-07 3 views

답변

0

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;

관련 문제