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
- ViewStateModeByIdAttribute.cs
- RequestQueryParser.cs
- EncryptedReference.cs
- EntityTypeBase.cs
- TextViewSelectionProcessor.cs
- EdmItemError.cs
- SelectionWordBreaker.cs
- WSDualHttpSecurityMode.cs
- RadioButton.cs
- ReaderOutput.cs
- TdsParserStaticMethods.cs
- DataGridHeaderBorder.cs
- QueryGeneratorBase.cs
- SystemInfo.cs
- TimeIntervalCollection.cs
- Track.cs
- XsltArgumentList.cs
- initElementDictionary.cs
- CacheChildrenQuery.cs
- EntityWrapper.cs
- clipboard.cs
- MultiPartWriter.cs
- InputLanguageProfileNotifySink.cs
- RootBrowserWindow.cs
- ContextQuery.cs
- DataGridToolTip.cs
- BinaryWriter.cs
- Axis.cs
- PartialTrustVisibleAssemblyCollection.cs
- CustomLineCap.cs
- SiteIdentityPermission.cs
- HtmlWindow.cs
- ProxyAttribute.cs
- BaseParaClient.cs
- ForAllOperator.cs
- ValueTypeFixupInfo.cs
- WindowsListViewGroupSubsetLink.cs
- Serializer.cs
- LinqToSqlWrapper.cs
- SqlUtils.cs
- ShellProvider.cs
- VisualStyleElement.cs
- HttpContext.cs
- FormsAuthenticationConfiguration.cs
- MenuItem.cs
- Helpers.cs
- ToolStripSettings.cs
- InputBinder.cs
- TypeUsage.cs
- RequestCacheValidator.cs
- MimeFormatter.cs
- Border.cs
- WindowsFormsHostPropertyMap.cs
- ReliabilityContractAttribute.cs
- HostingPreferredMapPath.cs
- ExeConfigurationFileMap.cs
- DragDropManager.cs
- CompiledELinqQueryState.cs
- CodeDefaultValueExpression.cs
- ByteStreamMessageEncoder.cs
- Model3DGroup.cs
- LockCookie.cs
- ParenthesizePropertyNameAttribute.cs
- DecoderExceptionFallback.cs
- HeaderPanel.cs
- SchemaCollectionPreprocessor.cs
- BuildDependencySet.cs
- ListSourceHelper.cs
- LineProperties.cs
- ByteAnimationBase.cs
- SourceFileInfo.cs
- ClusterRegistryConfigurationProvider.cs
- ClassGenerator.cs
- ToolStripItemImageRenderEventArgs.cs
- EdmComplexPropertyAttribute.cs
- RemotingConfigParser.cs
- UrlMappingsModule.cs
- _NegotiateClient.cs
- Visual.cs
- DBConnection.cs
- BitmapEffectGeneralTransform.cs
- StringPropertyBuilder.cs
- ProjectionAnalyzer.cs
- AffineTransform3D.cs
- ListViewSelectEventArgs.cs
- CellTreeNodeVisitors.cs
- FormViewInsertedEventArgs.cs
- EntityProviderFactory.cs
- Path.cs
- FrameworkElement.cs
- TrustSection.cs
- TextServicesPropertyRanges.cs
- SyncOperationState.cs
- SmtpNtlmAuthenticationModule.cs
- StrokeFIndices.cs
- GridViewItemAutomationPeer.cs
- WpfWebRequestHelper.cs
- TreeWalker.cs
- CryptoApi.cs
- RelationshipWrapper.cs