System.Windows.Controls.TextBox手柄手柄、Windows、System、TextBox

2023-09-07 10:02:13 作者:塮绝/~↘勾对

我觉得我失去了一些东西真的很明显这里。

I feel like I'm missing something really obvious here.

我知道,形式一般有一个处理属性,但我使用的是 System.Windows.Controls.TextBox 并没有一个处理属性。

I know that forms in general have a Handle property, but I am using a System.Windows.Controls.TextBox and it does not have a Handle property.

我如何访问文本框的处理?我注意到的RichTextBox 的Handle属性,那么为什么不正规文本框

How do I access the TextBox's handle? I noticed that RichTextBox has the Handle property, so why not the regular TextBox?

推荐答案

您只需拨打的处理上的文本框。距离 System.Windows.Forms.Control的继承的属性。

You can just call Handle on the TextBox. It is an inherited property from System.Windows.Forms.Control.

编辑:问题进行了更新,询问WPF

WPF不使用像一个典型的Win32应用程序或WinForms应用程序句柄。每个控件是不是在WPF其自己的窗口。您可以验证这一点与间谍++,它无法控制每一个区分。因此,你不能SendMessage函数到各个控件,如你可以与WinForms和的Win32应用程序。

WPF doesn't use handles like a typical Win32 application or WinForms application. Each control is not its own Window in WPF. You can verify this with Spy++, it cannot differentiate between each control. Therefore you cannot SendMessage to the individual controls like you can with WinForms and Win32 apps.

您可以使用 WindowInteropHelper 获得WPF窗口的父窗口的句柄。

You can use WindowInteropHelper to get the parent window handle of a WPF window.