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


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

IToolbarControl2.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;
  }
}

Alternatively, add the following code to the containing windows form to disable 'WS_CLIPCHILDREN'.

protected override CreateParams CreateParams
{
    get
    {
        CreateParams createParams=base.CreateParams;
        const int WS_CLIPCHILDREN=0x02000000;
        createParams.Style &= ~WS_CLIPCHILDREN;
        return createParams;
    }
}
[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

Alternatively, add the following code to the containing windows form to disable 'WS_CLIPCHILDREN'.

Protected Overloads Overrides ReadOnly Property CreateParams() As CreateParams
    Get
        Dim createParameters As CreateParams=MyBase.CreateParams
        Const WS_CLIPCHILDREN As Integer=33554432
        createParameters.Style=createParameters.Style And Not WS_CLIPCHILDREN
        Return createParameters
    End Get
End Property

See Also

IToolbarControl2 Interface