This document is archived and information here might be outdated.  Recommended version.


IToolbarControlDefault.Transparent Property (ArcObjects .NET 10.6 SDK)
ArcObjects Library Reference (Controls)  

IToolbarControlDefault.Transparent Property

Indicates if the ToolbarControl has a transparent background.

[Visual Basic .NET]
Public Property Transparent As Boolean
[C#]
public bool Transparent {get; set;}
[C++]
HRESULT get_Transparent(
void
);
[C++]
HRESULT put_Transparent(
);

Product Availability

Available with ArcGIS Engine.

Description

Determines whether the background of the ToolbarControl is transparent. This property is false by default.

When Transparent is true, the parent window containing the ToolbarControl must not clip children windows for transparency to work. This ensures the area of the window under the ToolbarControl gets painted.

Remarks

The BackColor, FadeColor and FillDirection properties do not affect the visual appearance of the ToolbarControl when Transparent is set to true.

[C#]

public class Form1 : System.Windows.Forms.Form
{
  [DllImport("User32", CharSet=CharSet.Auto)]
  private static extern int GetWindowLong(IntPtr hWnd, int Index);
  [DllImport("User32", CharSet=CharSet.Auto)]
  private static extern int SetWindowLong(IntPtr hWnd, int Index, int Value);
  const int GWL_STYLE=-16;
  const int WS_CLIPCHILDREN=0x02000000;

  private void Form1_Load(object sender, System.EventArgs e)
  {
    //Set label to not clip controls so ToolbarControl background is re-painted
    int style=GetWindowLong(myTransparentLabel.Handle, GWL_STYLE);
    SetWindowLong(myTransparentLabel.Handle, GWL_STYLE, style & ~WS_CLIPCHILDREN);
    //Set the ToolbarControl to be transparent
    axToolbarControl1.Transparent=true;
    //Set the ToolbarControl to be a child control of the label
    axToolbarControl1.Parent=myTransparentLabel;
  }
}

[Visual Basic .NET]

Public Class Form1
    Inherits System.Windows.Forms.Form

    <DllImport("User32", CharSet:=CharSet.Auto)> _
    Public Shared Function GetWindowLong(ByVal hWnd As Integer, ByVal index As Integer) As Integer
    End Function
    <DllImport("User32", CharSet:=CharSet.Auto)> _
    Public Shared Function SetWindowLong(ByVal hwnd As Integer, ByVal index As Integer, ByVal value As Integer) As Integer
    End Function
    Const GWL_STYLE As Int32=(-16)
    Const WS_CLIPCHILDREN=&H2000000

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Set label to not clip controls so ToolbarControl background is re-painted
        Dim style As Integer=GetWindowLong(myTransparentLabel.Handle.ToInt32, GWL_STYLE)
        SetWindowLong(myTransparentLabel.Handle.ToInt32, GWL_STYLE, style And Not WS_CLIPCHILDREN)
        'Set the ToolbarControl to be transparent
        AxToolbarControl1.Transparent=True
        'Set the ToolbarControl to be a child control of the label
        AxToolbarControl1.Parent=myTransparentLabel
    End Sub
End Class

See Also

IToolbarControlDefault Interface