VisualStyleRenderer.GetPoint(PointProperty) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Returns the value of the specified point property for the current visual style element.
public:
System::Drawing::Point GetPoint(System::Windows::Forms::VisualStyles::PointProperty prop);
public System.Drawing.Point GetPoint (System.Windows.Forms.VisualStyles.PointProperty prop);
member this.GetPoint : System.Windows.Forms.VisualStyles.PointProperty -> System.Drawing.Point
Public Function GetPoint (prop As PointProperty) As Point
Parameters
- prop
- PointProperty
One of the PointProperty values that specifies which property value to retrieve for the current visual style element.
Returns
A Point that contains the value of the property specified by the prop
parameter for the current visual style element.
Exceptions
prop
is not one of the PointProperty values.
Examples
The following code example demonstrates how to use the GetPoint method in a custom control to get the offset of the window Close button in relation to the upper-right corner of the title bar. This code example is part of a larger example provided for the VisualStyleRenderer class overview.
// Get the sizes and offsets for the window parts as specified
// by the visual style.
private:
void GetPartDetails()
{
// Do nothing further if visual styles are not enabled.
if (!Application::RenderWithVisualStyles)
{
return;
}
Graphics^ g = this->CreateGraphics();
// Get the size and offset of the close button.
if (SetRenderer(windowElements["windowClose"]))
{
closeButtonSize =
renderer->GetPartSize(g, ThemeSizeType::True);
closeButtonOffset =
renderer->GetPoint(PointProperty::Offset);
}
// Get the height of the window caption.
if (SetRenderer(windowElements["windowCaption"]))
{
captionHeight = renderer->GetPartSize(g,
ThemeSizeType::True).Height;
}
// Get the thickness of the left, bottom,
// and right window frame.
if (SetRenderer(windowElements["windowLeft"]))
{
frameThickness = renderer->GetPartSize(g,
ThemeSizeType::True).Width;
}
// Get the size of the resizing gripper.
if (SetRenderer(windowElements["statusGripper"]))
{
gripperSize = renderer->GetPartSize(g,
ThemeSizeType::True);
}
}
// Get the sizes and offsets for the window parts as specified
// by the visual style.
private void GetPartDetails()
{
// Do nothing further if visual styles are not enabled.
if (!Application.RenderWithVisualStyles)
{
return;
}
using (Graphics g = this.CreateGraphics())
{
// Get the size and offset of the close button.
if (SetRenderer(windowElements["windowClose"]))
{
closeButtonSize =
renderer.GetPartSize(g, ThemeSizeType.True);
closeButtonOffset =
renderer.GetPoint(PointProperty.Offset);
}
// Get the height of the window caption.
if (SetRenderer(windowElements["windowCaption"]))
{
captionHeight = renderer.GetPartSize(g,
ThemeSizeType.True).Height;
}
// Get the thickness of the left, bottom,
// and right window frame.
if (SetRenderer(windowElements["windowLeft"]))
{
frameThickness = renderer.GetPartSize(g,
ThemeSizeType.True).Width;
}
// Get the size of the resizing gripper.
if (SetRenderer(windowElements["statusGripper"]))
{
gripperSize = renderer.GetPartSize(g,
ThemeSizeType.True);
}
}
}
' Get the sizes and offsets for the window parts as specified
' by the visual style.
Private Sub GetPartDetails()
' Do nothing further if visual styles are not enabled.
If Not Application.RenderWithVisualStyles Then
Return
End If
Using g As Graphics = Me.CreateGraphics()
' Get the size and offset of the close button.
If SetRenderer(windowElements("windowClose")) Then
closeButtonSize = _
renderer.GetPartSize(g, ThemeSizeType.True)
closeButtonOffset = _
renderer.GetPoint(PointProperty.Offset)
End If
' Get the height of the window caption.
If SetRenderer(windowElements("windowCaption")) Then
captionHeight = renderer.GetPartSize(g, _
ThemeSizeType.True).Height
End If
' Get the thickness of the left, bottom, and right
' window frame.
If SetRenderer(windowElements("windowLeft")) Then
frameThickness = renderer.GetPartSize(g, _
ThemeSizeType.True).Width
End If
' Get the size of the resizing gripper.
If SetRenderer(windowElements("statusGripper")) Then
gripperSize = renderer.GetPartSize(g, _
ThemeSizeType.True)
End If
End Using
End Sub
Remarks
Visual styles use a set of point values to describe some properties of the elements defined by a style. These properties are encapsulated by the PointProperty values.