Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / System / Windows / Interop / WindowInteropHelper.cs / 1305600 / WindowInteropHelper.cs
//---------------------------------------------------------------------------- // // File: WindowInteropHelper.cs // // Description: Implements Avalon WindowInteropHelper classes, which helps // interop b/w legacy and Avalon Window. // // Created: 05/06/03 // // Copyright (C) 2001 by Microsoft Corporation. All rights reserved. // //--------------------------------------------------------------------------- using System; using System.Windows; using System.Windows.Interop; using System.Security; using System.Security.Permissions; using System.Diagnostics; using MS.Internal; using MS.Win32; namespace System.Windows.Interop { #region class WindowInteropHelper ////// Implements Avalon WindowInteropHelper classes, which helps /// interop b/w legacy and Avalon Window. /// public sealed class WindowInteropHelper { //--------------------------------------------------- // // Constructors // //--------------------------------------------------- #region Constructors ////// /// /// public WindowInteropHelper(Window window) { if (window == null) throw new ArgumentNullException("window"); _window = window; } #endregion Constructors //---------------------------------------------------- // // Public Properties // //--------------------------------------------------- #region Public Properties ////// Get the Handle of the window /// ////// Callers must have UIPermission(UIPermissionWindow.AllWindows) to call this API. /// ////// Critical: Exposes a handle /// PublicOK: There is a demand , this API not available in internet zone /// public IntPtr Handle { [SecurityCritical] get { SecurityHelper.DemandUIWindowPermission(); return CriticalHandle; } } ////// Critical: Exposes a handle /// internal IntPtr CriticalHandle { [SecurityCritical] get { Invariant.Assert(_window != null, "Cannot be null since we verify in the constructor"); return _window.CriticalHandle; } } ////// Get/Set the Owner handle of the window /// ////// Callers must have UIPermission(UIPermissionWindow.AllWindows) to call this API. /// ////// Critical: Exposes a handle /// PublicOK: There is a demand , this API not available in internet zone /// public IntPtr Owner { [SecurityCritical] get { SecurityHelper.DemandUIWindowPermission(); Debug.Assert(_window != null, "Cannot be null since we verify in the constructor"); return _window.OwnerHandle; } [SecurityCritical] set { SecurityHelper.DemandUIWindowPermission(); Debug.Assert(_window != null, "Cannot be null since we verify in the constructor"); // error checking done in Window _window.OwnerHandle = value; } } #endregion Public Properties //---------------------------------------------------- // // Public Methods // //---------------------------------------------------- #region Public Methods ////// Create the hwnd of the Window if the hwnd is not created yet. /// ////// Critical: Create and exposes the window handle. /// PublicOK: We demand UIPermission. /// [SecurityCritical] public IntPtr EnsureHandle() { SecurityHelper.DemandUIWindowPermission(); if (CriticalHandle == IntPtr.Zero) { _window.CreateSourceWindow(false /*create hwnd during show*/); } return CriticalHandle; } #endregion Public Methods //---------------------------------------------- // // Private Fields // //---------------------------------------------- #region Private Fields private Window _window; #endregion Private Members } #endregion class WindowInteropHelper } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. //---------------------------------------------------------------------------- // // File: WindowInteropHelper.cs // // Description: Implements Avalon WindowInteropHelper classes, which helps // interop b/w legacy and Avalon Window. // // Created: 05/06/03 // // Copyright (C) 2001 by Microsoft Corporation. All rights reserved. // //--------------------------------------------------------------------------- using System; using System.Windows; using System.Windows.Interop; using System.Security; using System.Security.Permissions; using System.Diagnostics; using MS.Internal; using MS.Win32; namespace System.Windows.Interop { #region class WindowInteropHelper ////// Implements Avalon WindowInteropHelper classes, which helps /// interop b/w legacy and Avalon Window. /// public sealed class WindowInteropHelper { //--------------------------------------------------- // // Constructors // //--------------------------------------------------- #region Constructors ////// /// /// public WindowInteropHelper(Window window) { if (window == null) throw new ArgumentNullException("window"); _window = window; } #endregion Constructors //---------------------------------------------------- // // Public Properties // //--------------------------------------------------- #region Public Properties ////// Get the Handle of the window /// ////// Callers must have UIPermission(UIPermissionWindow.AllWindows) to call this API. /// ////// Critical: Exposes a handle /// PublicOK: There is a demand , this API not available in internet zone /// public IntPtr Handle { [SecurityCritical] get { SecurityHelper.DemandUIWindowPermission(); return CriticalHandle; } } ////// Critical: Exposes a handle /// internal IntPtr CriticalHandle { [SecurityCritical] get { Invariant.Assert(_window != null, "Cannot be null since we verify in the constructor"); return _window.CriticalHandle; } } ////// Get/Set the Owner handle of the window /// ////// Callers must have UIPermission(UIPermissionWindow.AllWindows) to call this API. /// ////// Critical: Exposes a handle /// PublicOK: There is a demand , this API not available in internet zone /// public IntPtr Owner { [SecurityCritical] get { SecurityHelper.DemandUIWindowPermission(); Debug.Assert(_window != null, "Cannot be null since we verify in the constructor"); return _window.OwnerHandle; } [SecurityCritical] set { SecurityHelper.DemandUIWindowPermission(); Debug.Assert(_window != null, "Cannot be null since we verify in the constructor"); // error checking done in Window _window.OwnerHandle = value; } } #endregion Public Properties //---------------------------------------------------- // // Public Methods // //---------------------------------------------------- #region Public Methods ////// Create the hwnd of the Window if the hwnd is not created yet. /// ////// Critical: Create and exposes the window handle. /// PublicOK: We demand UIPermission. /// [SecurityCritical] public IntPtr EnsureHandle() { SecurityHelper.DemandUIWindowPermission(); if (CriticalHandle == IntPtr.Zero) { _window.CreateSourceWindow(false /*create hwnd during show*/); } return CriticalHandle; } #endregion Public Methods //---------------------------------------------- // // Private Fields // //---------------------------------------------- #region Private Fields private Window _window; #endregion Private Members } #endregion class WindowInteropHelper } // 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
- CancelEventArgs.cs
- TailCallAnalyzer.cs
- WebResourceAttribute.cs
- TextEndOfLine.cs
- LogEntrySerialization.cs
- ControlPaint.cs
- HttpListenerRequest.cs
- MessageQueuePermission.cs
- VisualTransition.cs
- DataKeyArray.cs
- SQLDouble.cs
- ScrollChangedEventArgs.cs
- XmlDocumentType.cs
- IconHelper.cs
- TextComposition.cs
- SafeTimerHandle.cs
- PointAnimation.cs
- RoleService.cs
- RegexStringValidator.cs
- Exceptions.cs
- ControlBuilderAttribute.cs
- SystemInformation.cs
- AppearanceEditorPart.cs
- DecoderExceptionFallback.cs
- IsolatedStorageSecurityState.cs
- SqlMultiplexer.cs
- StructuredTypeEmitter.cs
- PerformanceCounterPermission.cs
- SqlErrorCollection.cs
- RuntimeHelpers.cs
- BaseParaClient.cs
- DbLambda.cs
- DataGridViewAutoSizeModeEventArgs.cs
- StylusButtonEventArgs.cs
- NumberSubstitution.cs
- DocumentPageViewAutomationPeer.cs
- SqlSelectStatement.cs
- PropertySet.cs
- PageContent.cs
- XmlSchemaIdentityConstraint.cs
- recordstatefactory.cs
- PerformanceCounterPermissionEntryCollection.cs
- Stack.cs
- FixedHyperLink.cs
- MonitorWrapper.cs
- VisualStyleRenderer.cs
- ListViewTableRow.cs
- NextPreviousPagerField.cs
- ErrorReporting.cs
- SqlColumnizer.cs
- IdentityNotMappedException.cs
- Knowncolors.cs
- SettingsSection.cs
- CollectionBuilder.cs
- StorageEndPropertyMapping.cs
- CodeAccessSecurityEngine.cs
- UrlMappingCollection.cs
- DataFormats.cs
- DeferredSelectedIndexReference.cs
- FolderLevelBuildProviderCollection.cs
- VariableModifiersHelper.cs
- MaskedTextBox.cs
- TableRowCollection.cs
- ContentPlaceHolder.cs
- DbFunctionCommandTree.cs
- EmptyCollection.cs
- Duration.cs
- UnsafeNativeMethods.cs
- SamlAuthorizationDecisionClaimResource.cs
- VoiceObjectToken.cs
- ToolStripSplitButton.cs
- LogLogRecord.cs
- BackStopAuthenticationModule.cs
- Evaluator.cs
- HttpListener.cs
- SR.Designer.cs
- IsolatedStorageFileStream.cs
- ObjectConverter.cs
- InvalidOleVariantTypeException.cs
- LongMinMaxAggregationOperator.cs
- SignatureToken.cs
- PageAsyncTaskManager.cs
- NullableIntMinMaxAggregationOperator.cs
- DocumentXmlWriter.cs
- ObjectDataSourceSelectingEventArgs.cs
- UInt64Converter.cs
- RadioButtonRenderer.cs
- MissingMemberException.cs
- DATA_BLOB.cs
- WebConfigurationHost.cs
- XmlAnyElementAttribute.cs
- DbInsertCommandTree.cs
- ResourceContainer.cs
- ReflectionHelper.cs
- SetStateEventArgs.cs
- Utility.cs
- SQLSingle.cs
- FormViewPageEventArgs.cs
- ViewPort3D.cs
- GridViewColumnHeaderAutomationPeer.cs