-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
WindowInteropHelper.xml
210 lines (193 loc) · 14.5 KB
/
WindowInteropHelper.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
<Type Name="WindowInteropHelper" FullName="System.Windows.Interop.WindowInteropHelper">
<TypeSignature Language="C#" Value="public sealed class WindowInteropHelper" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi sealed beforefieldinit WindowInteropHelper extends System.Object" />
<TypeSignature Language="DocId" Value="T:System.Windows.Interop.WindowInteropHelper" />
<TypeSignature Language="VB.NET" Value="Public NotInheritable Class WindowInteropHelper" />
<TypeSignature Language="F#" Value="type WindowInteropHelper = class" />
<TypeSignature Language="C++ CLI" Value="public ref class WindowInteropHelper sealed" />
<AssemblyInfo>
<AssemblyName>PresentationFramework</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Base>
<BaseTypeName>System.Object</BaseTypeName>
</Base>
<Interfaces />
<Docs>
<summary>Assists interoperation between Windows Presentation Foundation (WPF) and Win32 code.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Members of this class allows the caller to have internal access to the Win32 HWND and the parent HWND of a WPF <xref:System.Windows.Window>. The proper security checks are performed by those members.
Use this class whenever you need a more specific object based on its HWND.
An example scenario is if you need to host a WPF dialog box in a Win32 application. Initialize the <xref:System.Windows.Interop.WindowInteropHelper> with a WPF window object for the dialog box. You can then get the WPF window's handle (HWND) from the <xref:System.Windows.Interop.WindowInteropHelper.Handle%2A> property and specify the owner for the WPF window with the <xref:System.Windows.Interop.WindowInteropHelper.Owner%2A> property. The following code example shows how to use <xref:System.Windows.Interop.WindowInteropHelper> when hosting a WPF dialog box in a Win32 application.
:::code language="csharp" source="~/snippets/csharp/System.Windows/ComponentResourceKey/.ctor/corepseudocode.cs" id="Snippetwindowinterophelper":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Wpf/CorePseudocode/visualbasic/corepseudocode.vb" id="Snippetwindowinterophelper":::
Another scenario supported by this class is to obtain a <xref:System.Windows.Interop.HwndSource> object from a WPF <xref:System.Windows.Window> object. The <xref:System.Windows.Interop.HwndSource> enables direct processing of Win32 messages through the <xref:System.Windows.Interop.HwndSource.AddHook%2A> method. By using <xref:System.Windows.Interop.HwndSource> and <xref:System.Windows.Interop.HwndSource.AddHook%2A> in place of a <xref:System.Windows.Window> you can still handle messages that have no equivalent or handling in WPF. Create a <xref:System.Windows.Interop.WindowInteropHelper> with the <xref:System.Windows.Window> source, then call <xref:System.Windows.Interop.WindowInteropHelper.Handle%2A> on the <xref:System.Windows.Interop.WindowInteropHelper> to get from HWND to <xref:System.Windows.Interop.HwndSource>.
]]></format>
</remarks>
<altmember cref="T:System.Windows.Window" />
<altmember cref="T:System.Windows.Interop.HwndSource" />
<altmember cref="M:System.Windows.Interop.HwndSource.AddHook(System.Windows.Interop.HwndSourceHook)" />
</Docs>
<Members>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public WindowInteropHelper (System.Windows.Window window);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor(class System.Windows.Window window) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Windows.Interop.WindowInteropHelper.#ctor(System.Windows.Window)" />
<MemberSignature Language="VB.NET" Value="Public Sub New (window As Window)" />
<MemberSignature Language="F#" Value="new System.Windows.Interop.WindowInteropHelper : System.Windows.Window -> System.Windows.Interop.WindowInteropHelper" Usage="new System.Windows.Interop.WindowInteropHelper window" />
<MemberSignature Language="C++ CLI" Value="public:
 WindowInteropHelper(System::Windows::Window ^ window);" />
<MemberType>Constructor</MemberType>
<AssemblyInfo>
<AssemblyName>PresentationFramework</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Parameters>
<Parameter Name="window" Type="System.Windows.Window" />
</Parameters>
<Docs>
<param name="window">A WPF window object.</param>
<summary>Initializes a new instance of the <see cref="T:System.Windows.Interop.WindowInteropHelper" /> class for a specified Windows Presentation Foundation (WPF) window.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The window can be a dialog box, or a window that is otherwise not suitable for being hosted within the bounds of a Win32 application.
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="EnsureHandle">
<MemberSignature Language="C#" Value="public IntPtr EnsureHandle ();" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance native int EnsureHandle() cil managed" />
<MemberSignature Language="DocId" Value="M:System.Windows.Interop.WindowInteropHelper.EnsureHandle" />
<MemberSignature Language="VB.NET" Value="Public Function EnsureHandle () As IntPtr" />
<MemberSignature Language="F#" Value="member this.EnsureHandle : unit -> nativeint" Usage="windowInteropHelper.EnsureHandle " />
<MemberSignature Language="C++ CLI" Value="public:
 IntPtr EnsureHandle();" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>PresentationFramework</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netframework-4.8.1">
<AttributeName Language="C#">[System.Security.SecurityCritical]</AttributeName>
<AttributeName Language="F#">[<System.Security.SecurityCritical>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.IntPtr</ReturnType>
</ReturnValue>
<Parameters />
<Docs>
<summary>Creates the HWND of the window if the HWND has not been created yet.</summary>
<returns>An <see cref="T:System.IntPtr" /> that represents the HWND.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Use the <xref:System.Windows.Interop.WindowInteropHelper.EnsureHandle%2A> method when you want to separate window handle (HWND) creation from the actual showing of the managed <xref:System.Windows.Window>. This is useful when you have an automation client that can accomplish its tasks without the need for showing a window.
If the native window has not yet been created, this method creates the native window, sets the <xref:System.Windows.Interop.WindowInteropHelper.Handle%2A> property, and returns the HWND. If the native window has been created already, the handle of the existing native window is returned.
If the native window is created as a result of calling this method, the <xref:System.Windows.Window.SourceInitialized> event is raised.
Querying the <xref:System.Windows.Interop.WindowInteropHelper.Handle%2A> property after the <xref:System.Windows.Interop.WindowInteropHelper.EnsureHandle%2A> method is called returns the existing window handle. The visual tree is not attached to the window until after the <xref:System.Windows.Window.Show%2A> method is called.
Calling the <xref:System.Windows.Interop.WindowInteropHelper.EnsureHandle%2A> method more than one time does not create new window handles. Calling the <xref:System.Windows.Interop.WindowInteropHelper.EnsureHandle%2A> method when the handle has already been created by a call to the <xref:System.Windows.Window.Show%2A> method does not create a new window handle. A native window is only created when no handle exists when the <xref:System.Windows.Interop.WindowInteropHelper.EnsureHandle%2A> method is called.
Window properties that are set by using native window APIs via p/invoke may not appear in the managed window APIs. For example, if you set the window to be topmost by using the native MS_EX_TOPMOST flag after the <xref:System.Windows.Interop.WindowInteropHelper.EnsureHandle%2A> method is called, the <xref:System.Windows.Window.Topmost%2A> property is not guaranteed to reflect the native setting.
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="Handle">
<MemberSignature Language="C#" Value="public IntPtr Handle { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance native int Handle" />
<MemberSignature Language="DocId" Value="P:System.Windows.Interop.WindowInteropHelper.Handle" />
<MemberSignature Language="VB.NET" Value="Public ReadOnly Property Handle As IntPtr" />
<MemberSignature Language="F#" Value="member this.Handle : nativeint" Usage="System.Windows.Interop.WindowInteropHelper.Handle" />
<MemberSignature Language="C++ CLI" Value="public:
 property IntPtr Handle { IntPtr get(); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>PresentationFramework</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netframework-4.8.1">
<AttributeName Language="C#">[get: System.Security.SecurityCritical]</AttributeName>
<AttributeName Language="F#">[<get: System.Security.SecurityCritical>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.IntPtr</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets the window handle for a Windows Presentation Foundation (WPF) window that is used to create this <see cref="T:System.Windows.Interop.WindowInteropHelper" />.</summary>
<value>The Windows Presentation Foundation (WPF) window handle (HWND).</value>
<remarks>To be added.</remarks>
<altmember cref="T:System.Windows.Window" />
</Docs>
</Member>
<Member MemberName="Owner">
<MemberSignature Language="C#" Value="public IntPtr Owner { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property instance native int Owner" />
<MemberSignature Language="DocId" Value="P:System.Windows.Interop.WindowInteropHelper.Owner" />
<MemberSignature Language="VB.NET" Value="Public Property Owner As IntPtr" />
<MemberSignature Language="F#" Value="member this.Owner : nativeint with get, set" Usage="System.Windows.Interop.WindowInteropHelper.Owner" />
<MemberSignature Language="C++ CLI" Value="public:
 property IntPtr Owner { IntPtr get(); void set(IntPtr value); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>PresentationFramework</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netframework-4.8.1">
<AttributeName Language="C#">[get: System.Security.SecurityCritical]</AttributeName>
<AttributeName Language="F#">[<get: System.Security.SecurityCritical>]</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netframework-4.8.1">
<AttributeName Language="C#">[set: System.Security.SecurityCritical]</AttributeName>
<AttributeName Language="F#">[<set: System.Security.SecurityCritical>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.IntPtr</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets or sets the handle of the Windows Presentation Foundation (WPF) owner window.</summary>
<value>The owner window handle (HWND).</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
You can reparent windows by setting this property. As is true for general Win32 programming, do not reparent windows that are already in use.
]]></format>
</remarks>
<altmember cref="T:System.Windows.Window" />
</Docs>
</Member>
</Members>
</Type>