Code:
/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / wcp / Framework / MS / Internal / Controls / webbrowsersite.cs / 1 / webbrowsersite.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
//
// Description:
// WebBrowserSite is a sub-class of ActiveXSite.
// Used to implement IDocHostUIHandler.
//
// Copied from WebBrowser.cs in winforms
//
// History
// 06/16/05 - [....] - Created
//
//-----------------------------------------------------------------------------
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Windows;
using MS.Win32;
using System.Security ;
using MS.Internal.PresentationFramework;
using IComDataObject = System.Runtime.InteropServices.ComTypes.IDataObject;
namespace MS.Internal.Controls
{
//
// WebBrowserSite class:
//
///
///
///
/// Provides a default WebBrowserSite implementation for use in the CreateWebBrowserSite
/// method in the WebBrowser class.
///
///
internal class WebBrowserSite : ActiveXSite , UnsafeNativeMethods.IDocHostUIHandler
{
///
///
/// WebBrowser implementation of ActiveXSite. Used to override GetHostInfo.
/// and "turn on" our redirect notifications.
///
///
/// Critical - calls base class ctor which is critical.
///
[ SecurityCritical ]
internal WebBrowserSite(WebBrowser host) : base(host)
{
}
//
// IDocHostUIHandler Implementation
//
///
int UnsafeNativeMethods.IDocHostUIHandler.ShowContextMenu(int dwID, NativeMethods.POINT pt, object pcmdtReserved, object pdispReserved)
{
//
// Returning S_FALSE will allow the native control to do default processing,
// i.e., execute the shortcut key. Returning S_OK will cancel the context menu
//
return NativeMethods.S_FALSE;
}
///
/// Critical - calls critical code.
/// If you change this method - you could affect mitigations.
/// **Needs to be critical.**
/// TreatAsSafe - information returned from this method is innocous.
/// lists the set of browser features/options we've enabled.
///
[ SecurityCritical, SecurityTreatAsSafe ]
int UnsafeNativeMethods.IDocHostUIHandler.GetHostInfo(NativeMethods.DOCHOSTUIINFO info)
{
WebBrowser wb = (WebBrowser)this.Host;
info.dwDoubleClick = (int) NativeMethods.DOCHOSTUIDBLCLICK.DEFAULT;
//
// These are the current flags shdocvw uses. Assumed we want the same.
//
info.dwFlags = (int) ( NativeMethods.DOCHOSTUIFLAG.DISABLE_HELP_MENU |
NativeMethods.DOCHOSTUIFLAG.DISABLE_SCRIPT_INACTIVE |
NativeMethods.DOCHOSTUIFLAG.ENABLE_INPLACE_NAVIGATION |
NativeMethods.DOCHOSTUIFLAG.IME_ENABLE_RECONVERSION |
NativeMethods.DOCHOSTUIFLAG.THEME |
NativeMethods.DOCHOSTUIFLAG.ENABLE_FORMS_AUTOCOMPLETE |
NativeMethods.DOCHOSTUIFLAG.DISABLE_UNTRUSTEDPROTOCOL |
NativeMethods.DOCHOSTUIFLAG.LOCAL_MACHINE_ACCESS_CHECK |
NativeMethods.DOCHOSTUIFLAG.ENABLE_REDIRECT_NOTIFICATION );
return NativeMethods.S_OK;
}
int UnsafeNativeMethods.IDocHostUIHandler.EnableModeless(bool fEnable)
{
return NativeMethods.E_NOTIMPL;
}
int UnsafeNativeMethods.IDocHostUIHandler.ShowUI(int dwID, UnsafeNativeMethods.IOleInPlaceActiveObject activeObject,
NativeMethods.IOleCommandTarget commandTarget, UnsafeNativeMethods.IOleInPlaceFrame frame,
UnsafeNativeMethods.IOleInPlaceUIWindow doc)
{
return NativeMethods.E_NOTIMPL;
}
int UnsafeNativeMethods.IDocHostUIHandler.HideUI()
{
return NativeMethods.E_NOTIMPL;
}
int UnsafeNativeMethods.IDocHostUIHandler.UpdateUI() {
return NativeMethods.E_NOTIMPL;
}
int UnsafeNativeMethods.IDocHostUIHandler.OnDocWindowActivate(bool fActivate)
{
return NativeMethods.E_NOTIMPL;
}
int UnsafeNativeMethods.IDocHostUIHandler.OnFrameWindowActivate(bool fActivate)
{
return NativeMethods.E_NOTIMPL;
}
int UnsafeNativeMethods.IDocHostUIHandler.ResizeBorder(NativeMethods.COMRECT rect, UnsafeNativeMethods.IOleInPlaceUIWindow doc, bool fFrameWindow)
{
return NativeMethods.E_NOTIMPL;
}
int UnsafeNativeMethods.IDocHostUIHandler.GetOptionKeyPath(string[] pbstrKey, int dw)
{
return NativeMethods.E_NOTIMPL;
}
int UnsafeNativeMethods.IDocHostUIHandler.GetDropTarget(UnsafeNativeMethods.IOleDropTarget pDropTarget, out UnsafeNativeMethods.IOleDropTarget ppDropTarget)
{
//
// Set to null no matter what we return, to prevent the marshaller
// from going crazy if the pointer points to random stuff.
ppDropTarget = null;
return NativeMethods.E_NOTIMPL;
}
int UnsafeNativeMethods.IDocHostUIHandler.GetExternal(out object ppDispatch)
{
/*
WebBrowser wb = (WebBrowser)this.Host;
ppDispatch = wb.ObjectForScripting;
return NativeMethods.S_OK; */
ppDispatch = null;
return NativeMethods.E_NOTIMPL;
}
int UnsafeNativeMethods.IDocHostUIHandler.TranslateAccelerator(ref System.Windows.Interop.MSG msg, ref Guid group, int nCmdID)
{
//
// Returning S_FALSE will allow the native control to do default processing,
// i.e., execute the shortcut key. Returning S_OK will cancel the shortcut key.
/* WebBrowser wb = (WebBrowser)this.Host;
if (!wb.WebBrowserShortcutsEnabled)
{
int keyCode = (int)msg.wParam | (int)Control.ModifierKeys;
if (msg.message != NativeMethods.WM_CHAR
&& Enum.IsDefined(typeof(Shortcut), (Shortcut)keyCode)) {
return NativeMethods.S_OK;
}
return NativeMethods.S_FALSE;
}
*/
return NativeMethods.S_FALSE;
}
int UnsafeNativeMethods.IDocHostUIHandler.TranslateUrl(int dwTranslate, string strUrlIn, out string pstrUrlOut)
{
//
// Set to null no matter what we return, to prevent the marshaller
// from going crazy if the pointer points to random stuff.
pstrUrlOut = null;
return NativeMethods.E_NOTIMPL;
}
int UnsafeNativeMethods.IDocHostUIHandler.FilterDataObject(IComDataObject pDO, out IComDataObject ppDORet)
{
//
// Set to null no matter what we return, to prevent the marshaller
// from going crazy if the pointer points to random stuff.
ppDORet = null;
return NativeMethods.E_NOTIMPL;
}
//
// Internal methods
//
/* internal override void OnPropertyChanged(int dispid)
{
if (dispid != NativeMethods.ActiveX.DISPID_READYSTATE) {
base.OnPropertyChanged(dispid);
}
}
*/
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ConfigXmlCDataSection.cs
- ElapsedEventArgs.cs
- FileLogRecord.cs
- Visitors.cs
- NetTcpSecurityElement.cs
- XmlDocumentFragment.cs
- AutomationTextAttribute.cs
- AdornerDecorator.cs
- FilteredDataSetHelper.cs
- DataGridViewButtonColumn.cs
- BaseResourcesBuildProvider.cs
- DesigntimeLicenseContext.cs
- ImageDrawing.cs
- HashCodeCombiner.cs
- CatalogPartCollection.cs
- ActivityTypeDesigner.xaml.cs
- FragmentNavigationEventArgs.cs
- DataBoundControlHelper.cs
- SHA256CryptoServiceProvider.cs
- Dispatcher.cs
- ISAPIWorkerRequest.cs
- WebPartMenuStyle.cs
- QilUnary.cs
- TimelineCollection.cs
- ImpersonationContext.cs
- mediaeventshelper.cs
- CodeTypeDeclaration.cs
- Cursors.cs
- Themes.cs
- UriTemplateEquivalenceComparer.cs
- PointKeyFrameCollection.cs
- PrintPreviewGraphics.cs
- SqlBulkCopy.cs
- Effect.cs
- ConfigurationSectionGroupCollection.cs
- Int16Animation.cs
- LocalServiceSecuritySettings.cs
- CompilerState.cs
- EventEntry.cs
- Msmq4PoisonHandler.cs
- LocationSectionRecord.cs
- DeviceContext2.cs
- WorkflowDesignerColors.cs
- PrivilegedConfigurationManager.cs
- ContentFilePart.cs
- ListViewGroup.cs
- DeviceContext.cs
- ObjectDataProvider.cs
- BitmapEffectRenderDataResource.cs
- FilterException.cs
- SRDisplayNameAttribute.cs
- CompositeFontFamily.cs
- XmlSchemaChoice.cs
- ResolveNextArgumentWorkItem.cs
- RelationshipManager.cs
- BaseInfoTable.cs
- SystemWebCachingSectionGroup.cs
- FormViewDeleteEventArgs.cs
- Material.cs
- PolyBezierSegmentFigureLogic.cs
- WindowsGraphics.cs
- XmlUtilWriter.cs
- OciHandle.cs
- StateManagedCollection.cs
- BindableTemplateBuilder.cs
- SqlClientMetaDataCollectionNames.cs
- FigureParagraph.cs
- SelectionRangeConverter.cs
- WorkflowWebService.cs
- ScriptRegistrationManager.cs
- ServiceOperationListItem.cs
- EndOfStreamException.cs
- TemplateParser.cs
- InvalidPrinterException.cs
- BaseValidator.cs
- BackStopAuthenticationModule.cs
- DesignerToolStripControlHost.cs
- CaseInsensitiveHashCodeProvider.cs
- XmlSerializerNamespaces.cs
- Menu.cs
- BackgroundWorker.cs
- ProcessModelSection.cs
- HttpConfigurationSystem.cs
- RegexBoyerMoore.cs
- DbConnectionOptions.cs
- DetailsViewDeletedEventArgs.cs
- TrackBarDesigner.cs
- FilteredXmlReader.cs
- CompositeTypefaceMetrics.cs
- MembershipSection.cs
- GeometryDrawing.cs
- ApplicationBuildProvider.cs
- EngineSiteSapi.cs
- StackSpiller.Generated.cs
- ImageSourceValueSerializer.cs
- DCSafeHandle.cs
- SpeechRecognizer.cs
- ToolStripPanelSelectionBehavior.cs
- MimeWriter.cs
- ProfilePropertyNameValidator.cs