Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

How to close Tab of IE running XBAP Application, not the whole browser?

$
0
0

Hi All,

Using the following code, the entire IE browser gets closed and if any other tabs are open, it asks for confirmation.

 

privatevoid button1_Click(object sender, RoutedEventArgs e)
    {
      WindowInteropHelper wih = new WindowInteropHelper(Application.Current.MainWindow);
      IntPtr ieHwnd = GetAncestor(wih.Handle, 2 /*GA_ROOT*/);
      PostMessage(ieHwnd, 0x10/*WM_CLOSE*/, IntPtr.Zero, IntPtr.Zero);   
    } 

    [DllImport("user32", ExactSpelling = true, CharSet = CharSet.Auto)]privatestaticextern IntPtr GetAncestor(IntPtr hwnd, int flags); 

    [DllImport("user32", CharSet = CharSet.Auto)]privatestaticexternbool PostMessage(IntPtr hwnd, int msg, IntPtr wparam, IntPtr lparam);

Is there any way to close only the Tab which is running XBAP Application in IE? Any help will be greatly appreciated.

 

Regards,

Binaya

 


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>