Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / Tools / System.Activities.Presentation / System / Activities / Presentation / DialogWindow.cs / 1407647 / DialogWindow.cs
//---------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. //--------------------------------------------------------------- namespace System.Activities.Presentation { using System.Windows; using System.Activities.Presentation.View; using System.Windows.Interop; using System.Windows.Input; using System.ComponentModel; internal class DialogWindow : Window { public static readonly DependencyProperty ContextProperty = DependencyProperty.Register("Context", typeof(EditingContext), typeof(DialogWindow)); string helpKeyword = HelpKeywords.HomePage; public EditingContext Context { get { return (EditingContext)GetValue(ContextProperty); } set { SetValue(ContextProperty, value); } } protected string HelpKeyword { get { return this.helpKeyword; } set { this.helpKeyword = value; } } protected override void OnSourceInitialized(EventArgs e) { base.OnSourceInitialized(e); this.HideMinMaxButton(); this.ShowContextHelpButton(); this.HideIcon(); this.AddWindowsHook(OnHookedWindowMessage); this.CommandBindings.Add(new CommandBinding(ApplicationCommands.Help, new ExecutedRoutedEventHandler(OnHelpExecuted))); this.Closing += new CancelEventHandler(OnWindowClosing); } static IntPtr OnHookedWindowMessage(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) { if (msg == Win32Interop.WM_SYSCOMMAND && wParam.ToInt64() == (long)Win32Interop.SC_CONTEXTHELP) { var rootVisual = HwndSource.FromHwnd(hwnd).RootVisual; var focusedElement = FocusManager.GetFocusedElement(rootVisual); if (focusedElement == null) { focusedElement = rootVisual as IInputElement; } ApplicationCommands.Help.Execute(null, focusedElement); handled = true; } // According to MSDN, zero should be returned after handling WM_SYSCOMMAND. // If this message is unhandled, it's still safe to return zero // because WPF framework (HwndSource) will return zero anyway if the // message is unhandled. return IntPtr.Zero; } void OnWindowClosing(object sender, CancelEventArgs e) { // Note: Do NOT remove the hook if the close operation needs to be canceled. this.RemoveWindowsHook(OnHookedWindowMessage); } void OnHelpExecuted(Object sender, ExecutedRoutedEventArgs e) { if (this.Context != null) { IIntegratedHelpService help = this.Context.Services.GetService(); if (help != null) { help.ShowHelpFromKeyword(this.helpKeyword); return; } } System.Diagnostics.Process.Start(SR.DefaultHelpUrl); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- PseudoWebRequest.cs
- ColorMap.cs
- ControlCachePolicy.cs
- ObjectNotFoundException.cs
- UdpConstants.cs
- CatalogPartChrome.cs
- ValueProviderWrapper.cs
- mediapermission.cs
- ServiceEndpoint.cs
- WebServiceReceiveDesigner.cs
- WebPartEditorCancelVerb.cs
- Operator.cs
- Operators.cs
- Attribute.cs
- ValueTypeFixupInfo.cs
- XmlSerializationWriter.cs
- MonitoringDescriptionAttribute.cs
- SerializationSectionGroup.cs
- Win32KeyboardDevice.cs
- IntellisenseTextBox.designer.cs
- XmlSchemaElement.cs
- XmlRootAttribute.cs
- SqlConnectionHelper.cs
- AssemblyNameEqualityComparer.cs
- WebPartCollection.cs
- CellPartitioner.cs
- OverflowException.cs
- CompilationUtil.cs
- arclist.cs
- TraceUtility.cs
- NetTcpBindingElement.cs
- CryptoHelper.cs
- TrackingExtract.cs
- AmbientProperties.cs
- QueryExpr.cs
- CompilationUtil.cs
- TemplateNameScope.cs
- ObjectStateFormatter.cs
- CustomErrorsSection.cs
- shaper.cs
- DataGridCaption.cs
- CollectionContainer.cs
- InteropExecutor.cs
- ContentPresenter.cs
- ForeignKeyConstraint.cs
- SourceFilter.cs
- DesignerImageAdapter.cs
- SQLDateTime.cs
- ClientTargetSection.cs
- PageTheme.cs
- DataGridCellsPanel.cs
- BasicAsyncResult.cs
- PerspectiveCamera.cs
- ViewStateException.cs
- PublisherMembershipCondition.cs
- HyperlinkAutomationPeer.cs
- TextBoxBase.cs
- Point4DValueSerializer.cs
- FileReservationCollection.cs
- DynamicPropertyHolder.cs
- MarkupExtensionParser.cs
- EntityContainerEmitter.cs
- CodeObjectCreateExpression.cs
- counter.cs
- WriteLine.cs
- XmlSchemaAttribute.cs
- DataObjectMethodAttribute.cs
- GlobalDataBindingHandler.cs
- AssemblyAssociatedContentFileAttribute.cs
- WebControlsSection.cs
- ComponentEvent.cs
- XmlSerializationReader.cs
- MemberAssignment.cs
- CursorEditor.cs
- DataGridViewColumnCollection.cs
- CryptoApi.cs
- CreateUserWizardStep.cs
- DbException.cs
- BrushProxy.cs
- AtomParser.cs
- UserControlCodeDomTreeGenerator.cs
- SerializationSectionGroup.cs
- UnsafeNativeMethods.cs
- EmptyQuery.cs
- SimpleWebHandlerParser.cs
- InvalidAsynchronousStateException.cs
- GridView.cs
- URLBuilder.cs
- ManifestResourceInfo.cs
- DataGridTable.cs
- AttachedPropertyBrowsableAttribute.cs
- TransactionProxy.cs
- SafeSystemMetrics.cs
- BookmarkInfo.cs
- MultipleViewPattern.cs
- altserialization.cs
- RequestCachePolicy.cs
- SafeLibraryHandle.cs
- WebBrowserPermission.cs
- StandardToolWindows.cs