Click here to Skip to main content
15,917,454 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi

I am new to WPF Browser Application/WPF.

I found code to close browswer when click Exit button,

but cannot find how to close Tab instead whole browser?

Normal our clients will run at least two XBAP in separated Tab of IE, when user close one XBAP it leavs a blank Tab using following code
VB
Application.Current.ShutdownMode = ShutdownMode.OnExplicitShutdown
Application.Current.Shutdown()


I need your help! Any ideas?

I am using Visual Studio 2010 on Windows 7/Vista machines.

Thanks

Fred


Following code will close whole browser:
VB
<DllImport("user32.dll", CharSet:=CharSet.Auto, ExactSpelling:=True)> _
Public Shared Function GetAncestor(ByVal hWnd As IntPtr, ByVal flags As Integer) As IntPtr
End Function

<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
Public Shared Function PostMessage(ByVal hWnd As IntPtr, ByVal Msg As UInteger, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As Boolean
End Function

Dim ieHwnd As New IntPtr
Dim wih As WindowInteropHelper = New WindowInteropHelper(Application.Current.MainWindow)
ieHwnd = GetAncestor(wih.Handle, 2)
PostMessage(ieHwnd, CLng("&H" & 10), IntPtr.Zero, IntPtr.Zero)
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900