This document is archived and information here might be outdated. Recommended version. |
ArcObjects namespaces > Controls > ESRI ArcGIS Controls > Interfaces > IT > IToolbarControl2 Interface > IToolbarControl2.Transparent Property (ArcObjects .NET 10.4 SDK) |
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(
VARIANT_BOOL* pVal
);
[C++]
HRESULT put_Transparent(
VARIANT_BOOL pVal
);
[C++]
Parameters pVal [out, retval] pVal is a parameter of type VARIANT_BOOL pVal [in] pVal is a parameter of type VARIANT_BOOL
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.
The BackColor, FadeColor and FillDirection properties do not affect the visual appearance of the ToolbarControl when Transparent is set to true.
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; } }
Public Class
Form1Inherits
System.Windows.Forms.Form <DllImport("User32", CharSet:=CharSet.Auto)> _Public Shared Function
GetWindowLong(ByVal
hWndAs Integer
,ByVal
indexAs Integer
)As Integer End Function
<DllImport("User32", CharSet:=CharSet.Auto)> _Public Shared Function
SetWindowLong(ByVal
hwndAs Integer
,ByVal
indexAs Integer
,ByVal
valueAs Integer
)As Integer End Function Const
GWL_STYLEAs
Int32=(-16)Const
WS_CLIPCHILDREN=&H2000000Private Sub
Form1_Load(ByVal
senderAs
System.Object,ByVal
eAs
System.EventArgs)Handles
MyBase.Load'Set label to not clip controls so ToolbarControl background is re-painted
Dim
styleAs Integer
=GetWindowLong(myTransparentLabel.Handle.ToInt32, GWL_STYLE) SetWindowLong(myTransparentLabel.Handle.ToInt32, GWL_STYLE, styleAnd 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=myTransparentLabelEnd Sub End
Class
Alternatively, add the following code to the containing windows form to disable 'WS_CLIPCHILDREN'.
Protected Overloads Overrides ReadOnly Property
CreateParams()As
CreateParamsGet Dim
createParametersAs
CreateParams=MyBase.CreateParamsConst
WS_CLIPCHILDRENAs Integer
=33554432 createParameters.Style=createParameters.StyleAnd Not
WS_CLIPCHILDRENReturn
createParametersEnd Get End
Property