Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / UIAutomation / Win32Providers / MS / Internal / AutomationProxies / WindowsGrip.cs / 1305600 / WindowsGrip.cs
//----------------------------------------------------------------------------
//
//
// Copyright (C) Microsoft Corporation. All rights reserved.
//
//
//
// Description: Windows Button Proxy
//
// History:
// 07/01/2003 : preid Created
//---------------------------------------------------------------------------
using System;
using System.Collections;
using System.Text;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Automation;
using System.Windows.Automation.Provider;
using System.ComponentModel;
using MS.Win32;
namespace MS.Internal.AutomationProxies
{
class WindowsGrip: ProxyFragment
{
// -----------------------------------------------------
//
// Constructors
//
//-----------------------------------------------------
#region Constructors
public WindowsGrip (IntPtr hwnd, ProxyHwnd parent, int item)
: base( hwnd, parent, item)
{
_sType = ST.Get(STID.LocalizedControlTypeGrip);
_sAutomationId = "Window.Grip"; // This string is a non-localizable string
}
#endregion
//------------------------------------------------------
//
// Patterns Implementation
//
//-----------------------------------------------------
#region ProxySimple Interface
///
/// Gets the bounding rectangle for this element
///
internal override Rect BoundingRectangle
{
get
{
if (IsGripPresent(_hwnd, false))
{
NativeMethods.Win32Rect client = new NativeMethods.Win32Rect();
if (Misc.GetClientRectInScreenCoordinates(_hwnd, ref client))
{
NativeMethods.SIZE sizeGrip = GetGripSize(_hwnd, false);
if (Misc.IsLayoutRTL(_hwnd))
{
return new Rect(client.left - sizeGrip.cx, client.bottom, sizeGrip.cx, sizeGrip.cy);
}
else
{
return new Rect(client.right, client.bottom, sizeGrip.cx, sizeGrip.cy);
}
}
}
return Rect.Empty;
}
}
#endregion
//------------------------------------------------------
//
// Internal Methods
//
//------------------------------------------------------
#region Internal Methods
static internal bool IsGripPresent(IntPtr hwnd, bool onStatusBar)
{
NativeMethods.Win32Rect client = new NativeMethods.Win32Rect();
if (!Misc.GetClientRectInScreenCoordinates(hwnd, ref client))
{
return false;
}
// According to the documentation of GetClientRect, the left and top members are zero. So if
// they are negitive the control must be minimized, therefore the grip is not present.
if (client.left < 0 && client.top < 0 )
{
return false;
}
NativeMethods.SIZE sizeGrip = GetGripSize(hwnd, onStatusBar);
if (!onStatusBar)
{
// When not on a status bar the grip should be out side of the client area.
sizeGrip.cx *= -1;
sizeGrip.cy *= -1;
}
if (Misc.IsLayoutRTL(hwnd))
{
int x = client.left + (int)(sizeGrip.cx / 2);
int y = client.bottom - (int)(sizeGrip.cy / 2);
int hit = Misc.ProxySendMessageInt(hwnd, NativeMethods.WM_NCHITTEST, IntPtr.Zero, NativeMethods.Util.MAKELPARAM(x, y));
return hit == NativeMethods.HTBOTTOMLEFT;
}
else
{
int x = client.right - (int)(sizeGrip.cx / 2);
int y = client.bottom - (int)(sizeGrip.cy / 2);
int hit = Misc.ProxySendMessageInt(hwnd, NativeMethods.WM_NCHITTEST, IntPtr.Zero, NativeMethods.Util.MAKELPARAM(x, y));
return hit == NativeMethods.HTBOTTOMRIGHT;
}
}
internal static NativeMethods.SIZE GetGripSize(IntPtr hwnd, bool onStatusBar)
{
using (ThemePart themePart = new ThemePart(hwnd, onStatusBar ? "STATUS" : "SCROLLBAR"))
{
return themePart.Size(onStatusBar ? (int)ThemePart.STATUSPARTS.SP_GRIPPER : (int)ThemePart.SCROLLBARPARTS.SBP_SIZEBOX, 0);
}
}
#endregion
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------------------------
//
//
// Copyright (C) Microsoft Corporation. All rights reserved.
//
//
//
// Description: Windows Button Proxy
//
// History:
// 07/01/2003 : preid Created
//---------------------------------------------------------------------------
using System;
using System.Collections;
using System.Text;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Automation;
using System.Windows.Automation.Provider;
using System.ComponentModel;
using MS.Win32;
namespace MS.Internal.AutomationProxies
{
class WindowsGrip: ProxyFragment
{
// -----------------------------------------------------
//
// Constructors
//
//-----------------------------------------------------
#region Constructors
public WindowsGrip (IntPtr hwnd, ProxyHwnd parent, int item)
: base( hwnd, parent, item)
{
_sType = ST.Get(STID.LocalizedControlTypeGrip);
_sAutomationId = "Window.Grip"; // This string is a non-localizable string
}
#endregion
//------------------------------------------------------
//
// Patterns Implementation
//
//-----------------------------------------------------
#region ProxySimple Interface
///
/// Gets the bounding rectangle for this element
///
internal override Rect BoundingRectangle
{
get
{
if (IsGripPresent(_hwnd, false))
{
NativeMethods.Win32Rect client = new NativeMethods.Win32Rect();
if (Misc.GetClientRectInScreenCoordinates(_hwnd, ref client))
{
NativeMethods.SIZE sizeGrip = GetGripSize(_hwnd, false);
if (Misc.IsLayoutRTL(_hwnd))
{
return new Rect(client.left - sizeGrip.cx, client.bottom, sizeGrip.cx, sizeGrip.cy);
}
else
{
return new Rect(client.right, client.bottom, sizeGrip.cx, sizeGrip.cy);
}
}
}
return Rect.Empty;
}
}
#endregion
//------------------------------------------------------
//
// Internal Methods
//
//------------------------------------------------------
#region Internal Methods
static internal bool IsGripPresent(IntPtr hwnd, bool onStatusBar)
{
NativeMethods.Win32Rect client = new NativeMethods.Win32Rect();
if (!Misc.GetClientRectInScreenCoordinates(hwnd, ref client))
{
return false;
}
// According to the documentation of GetClientRect, the left and top members are zero. So if
// they are negitive the control must be minimized, therefore the grip is not present.
if (client.left < 0 && client.top < 0 )
{
return false;
}
NativeMethods.SIZE sizeGrip = GetGripSize(hwnd, onStatusBar);
if (!onStatusBar)
{
// When not on a status bar the grip should be out side of the client area.
sizeGrip.cx *= -1;
sizeGrip.cy *= -1;
}
if (Misc.IsLayoutRTL(hwnd))
{
int x = client.left + (int)(sizeGrip.cx / 2);
int y = client.bottom - (int)(sizeGrip.cy / 2);
int hit = Misc.ProxySendMessageInt(hwnd, NativeMethods.WM_NCHITTEST, IntPtr.Zero, NativeMethods.Util.MAKELPARAM(x, y));
return hit == NativeMethods.HTBOTTOMLEFT;
}
else
{
int x = client.right - (int)(sizeGrip.cx / 2);
int y = client.bottom - (int)(sizeGrip.cy / 2);
int hit = Misc.ProxySendMessageInt(hwnd, NativeMethods.WM_NCHITTEST, IntPtr.Zero, NativeMethods.Util.MAKELPARAM(x, y));
return hit == NativeMethods.HTBOTTOMRIGHT;
}
}
internal static NativeMethods.SIZE GetGripSize(IntPtr hwnd, bool onStatusBar)
{
using (ThemePart themePart = new ThemePart(hwnd, onStatusBar ? "STATUS" : "SCROLLBAR"))
{
return themePart.Size(onStatusBar ? (int)ThemePart.STATUSPARTS.SP_GRIPPER : (int)ThemePart.SCROLLBARPARTS.SBP_SIZEBOX, 0);
}
}
#endregion
}
}
// 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
- EncodingInfo.cs
- PropertyCollection.cs
- MSHTMLHost.cs
- PointF.cs
- FactoryId.cs
- PartialCachingAttribute.cs
- QilValidationVisitor.cs
- ConnectionPoolManager.cs
- XPathSelfQuery.cs
- DtdParser.cs
- LogExtent.cs
- BitmapPalettes.cs
- Cursors.cs
- GetWorkflowTree.cs
- XmlMtomReader.cs
- TextProviderWrapper.cs
- ObjectStateManager.cs
- DataGridViewCellConverter.cs
- FormViewModeEventArgs.cs
- CancelEventArgs.cs
- ArithmeticException.cs
- DictionarySectionHandler.cs
- Currency.cs
- CheckBox.cs
- BasicHttpSecurity.cs
- DesignerTransactionCloseEvent.cs
- StylusLogic.cs
- MenuRenderer.cs
- SaveRecipientRequest.cs
- FileSecurity.cs
- InternalEnumValidatorAttribute.cs
- HwndSourceKeyboardInputSite.cs
- DbConnectionFactory.cs
- DataGridViewColumnHeaderCell.cs
- ClientEventManager.cs
- ParagraphVisual.cs
- SourceElementsCollection.cs
- TextTrailingCharacterEllipsis.cs
- XsdDuration.cs
- CodeDOMUtility.cs
- DashStyles.cs
- DragEvent.cs
- Lease.cs
- WebColorConverter.cs
- XmlSchemaSimpleContentExtension.cs
- DecimalMinMaxAggregationOperator.cs
- LogoValidationException.cs
- TableProviderWrapper.cs
- Int64.cs
- ConnectionManagementSection.cs
- XamlRtfConverter.cs
- QueryRewriter.cs
- AccessDataSource.cs
- ToggleButtonAutomationPeer.cs
- ComponentRenameEvent.cs
- Visitors.cs
- UserControlParser.cs
- ClientRuntimeConfig.cs
- DefaultBinder.cs
- ComplexType.cs
- Menu.cs
- AstNode.cs
- EntityDataSourceConfigureObjectContext.cs
- _ProxyRegBlob.cs
- XmlChildNodes.cs
- SqlTrackingService.cs
- DesignerVerb.cs
- RelationshipConverter.cs
- DoubleLink.cs
- TokenizerHelper.cs
- DataBindingList.cs
- ConsoleEntryPoint.cs
- EventEntry.cs
- SqlUnionizer.cs
- WindowProviderWrapper.cs
- DbExpressionVisitor.cs
- CodeConstructor.cs
- ModuleBuilder.cs
- WebPartConnectionsDisconnectVerb.cs
- ControlType.cs
- TcpClientChannel.cs
- Thumb.cs
- DispatcherExceptionEventArgs.cs
- DataGridColumnStyleMappingNameEditor.cs
- WebEventCodes.cs
- BeginStoryboard.cs
- ChannelPoolSettingsElement.cs
- BinaryKeyIdentifierClause.cs
- DbgUtil.cs
- Vector3DValueSerializer.cs
- Table.cs
- X500Name.cs
- DocumentPageViewAutomationPeer.cs
- MenuItem.cs
- BitmapEffectDrawingContextState.cs
- SQLInt64Storage.cs
- MarkupExtensionParser.cs
- NoneExcludedImageIndexConverter.cs
- HierarchicalDataSourceControl.cs
- InheritablePropertyChangeInfo.cs