Code:
/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / AccessibleTech / longhorn / Automation / Win32Providers / MS / Internal / AutomationProxies / WindowsListViewScroll.cs / 1 / WindowsListViewScroll.cs
//---------------------------------------------------------------------------- // //// Copyright (C) Microsoft Corporation. All rights reserved. // // // // Description: Class to provide scroll bars for listview // // History: // [....] (in DotNet) // 2003/08/08 - alexsn Updated for WCP // 2004/08/19 - [....] Took this out of the class hierarchy for listview and made the // non-client area use to create the scroll bar children // //--------------------------------------------------------------------------- using System; using System.Runtime.InteropServices; using System.ComponentModel; using System.Windows.Automation; using System.Windows.Automation.Provider; using System.Windows; using MS.Win32; namespace MS.Internal.AutomationProxies { // The default implementation for scroll bars uses SB_THUMBTRACK and SB_THUMBPOSITION for SetValue // This does not work with listview so the Scrollbar is overloaded with a derived version that // uses LVM_SCROLL messages instead class WindowsListViewScrollBar: WindowsScrollBar, IRangeValueProvider { // ----------------------------------------------------- // // Constructors // //----------------------------------------------------- #region Constructors internal WindowsListViewScrollBar(IntPtr hwnd, ProxyFragment parent, int item, int sbFlag) : base( hwnd, parent, item, sbFlag){} #endregion Constructors //------------------------------------------------------ // // Patterns Implementation // //----------------------------------------------------- #region RangeValue Pattern void IRangeValueProvider.SetValue(double val) { // Check if the window is disabled if (!SafeNativeMethods.IsWindowEnabled (_hwnd)) { throw new ElementNotEnabledException(); } NativeMethods.ScrollInfo si = new NativeMethods.ScrollInfo (); si.fMask = NativeMethods.SIF_ALL; si.cbSize = Marshal.SizeOf (si.GetType ()); if (!Misc.GetScrollInfo(_hwnd, _sbFlag, ref si)) { return; } int pos = (int)val; // Throw if val is greater than the maximum or less than the minimum. // See remarks for WindowsScrollBar.GetScrollValue(ScrollBarInfo.MaximumPosition) // regarding this calculation of the allowed maximum. if (pos > si.nMax - si.nPage + (si.nPage > 0 ? 1 : 0)) { throw new ArgumentOutOfRangeException("value", val, SR.Get(SRID.RangeValueMax)); } else if (pos < si.nMin) { throw new ArgumentOutOfRangeException("value", val, SR.Get(SRID.RangeValueMin)); } // LVM_SCROLL does not work in mode Report, use SetScrollPos instead bool isVerticalScroll = IsScrollBarVertical(_hwnd, _sbFlag); if (isVerticalScroll && WindowsListView.InReportView (_hwnd)) { Misc.SetScrollPos(_hwnd, _sbFlag, pos, true); return; } // get the "full size" of the list-view int size = WindowsListView.ApproximateViewRect (_hwnd); // delta between current and user-requested position in pixels // since the cPelsAll contains the dimension in pels for all items + the 2 pels of the border // the operation below does a trunc on purpose int dx = 0, dy = 0; if (!isVerticalScroll) { int cPelsAll = NativeMethods.Util.LOWORD (size); dx = (int)((pos - si.nPos) * ((double)cPelsAll / (si.nMax + 1 - si.nMin))); } else { int cPelsAll = NativeMethods.Util.HIWORD (size); dy = (int)((pos - si.nPos) * ((double)cPelsAll / (si.nMax + 1 - si.nMin))); } if (WindowsListView.Scroll (_hwnd, (IntPtr) dx, (IntPtr) dy)) { // Check the result, on occasion the result will be different to given value // a-jeanp: I played a lot to figure out what it is not the case. // I am giving up and issuing instead a second call with a new delta. if (!Misc.GetScrollInfo(_hwnd, _sbFlag, ref si)) { return; } if (si.nPos != pos) { if (!isVerticalScroll) { int cPelsAll = NativeMethods.Util.LOWORD (size); dx = (pos - si.nPos) * (cPelsAll / (si.nMax + 1 - si.nMin)); } else { int cPelsAll = NativeMethods.Util.HIWORD (size); dy = (pos - si.nPos) * (cPelsAll / (si.nMax + 1 - si.nMin)); } WindowsListView.Scroll (_hwnd, (IntPtr) dx, (IntPtr) dy); } } } #endregion Value Pattern } } // 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
- ControlIdConverter.cs
- RelationshipEndMember.cs
- ImmComposition.cs
- HttpCacheVary.cs
- ReadOnlyNameValueCollection.cs
- AdornerHitTestResult.cs
- CommandSet.cs
- RuleSetReference.cs
- UInt64Converter.cs
- SemanticBasicElement.cs
- Relationship.cs
- AttachmentCollection.cs
- UIElementHelper.cs
- PagesChangedEventArgs.cs
- ScrollProperties.cs
- CodeTypeReferenceCollection.cs
- CompositeActivityMarkupSerializer.cs
- TransformerInfo.cs
- DataReaderContainer.cs
- X509Utils.cs
- CultureMapper.cs
- AccessDataSourceView.cs
- GeneralTransform3DGroup.cs
- ToolStripSplitButton.cs
- UpdatePanelControlTrigger.cs
- ListSourceHelper.cs
- ParserHooks.cs
- SimpleBitVector32.cs
- ColumnWidthChangingEvent.cs
- MailWriter.cs
- ValidatorCompatibilityHelper.cs
- PassportIdentity.cs
- SystemFonts.cs
- SchemaElementLookUpTableEnumerator.cs
- BuilderInfo.cs
- XmlDataSourceNodeDescriptor.cs
- ParameterCollection.cs
- RoleService.cs
- DbSourceParameterCollection.cs
- ClickablePoint.cs
- MenuTracker.cs
- CustomCategoryAttribute.cs
- Drawing.cs
- ConfigurationStrings.cs
- SyndicationSerializer.cs
- HideDisabledControlAdapter.cs
- ShapingWorkspace.cs
- DiagnosticSection.cs
- TextBlockAutomationPeer.cs
- BindingSource.cs
- HttpWriter.cs
- DataGridViewCellToolTipTextNeededEventArgs.cs
- UIElement3D.cs
- basecomparevalidator.cs
- CallbackException.cs
- PersonalizationStateInfo.cs
- DataGridViewRowPrePaintEventArgs.cs
- CorrelationManager.cs
- Span.cs
- FilePrompt.cs
- PasswordRecovery.cs
- SmiMetaData.cs
- Facet.cs
- HttpRequest.cs
- OdbcDataAdapter.cs
- Expressions.cs
- WindowProviderWrapper.cs
- TabRenderer.cs
- NameScope.cs
- AppDomainUnloadedException.cs
- XmlILAnnotation.cs
- GeometryModel3D.cs
- CancellationHandlerDesigner.cs
- MeasureItemEvent.cs
- Source.cs
- FixedStringLookup.cs
- ReflectionUtil.cs
- DataContractJsonSerializer.cs
- AlignmentYValidation.cs
- WebDisplayNameAttribute.cs
- MonitoringDescriptionAttribute.cs
- ElementsClipboardData.cs
- Model3D.cs
- TextSelection.cs
- FixUpCollection.cs
- FlowchartDesignerCommands.cs
- GridViewRowEventArgs.cs
- XPathChildIterator.cs
- ObjectSecurity.cs
- BrowserCapabilitiesFactory.cs
- XsltConvert.cs
- SingleQueryOperator.cs
- DateTimeConverter2.cs
- Sql8ConformanceChecker.cs
- HandleCollector.cs
- WhitespaceRuleLookup.cs
- DBAsyncResult.cs
- WebPartsPersonalizationAuthorization.cs
- IndentedWriter.cs
- InvariantComparer.cs