我想通过其句柄检查表单是否具有表单边框。而且,句柄来自另一个应用程序。
我该如何处理?请帮助我..谢谢!
[DllImport("user32.dll")]
extern static int GetWindowLong(IntPtr hWnd, int nIndex);
const int GWL_STYLE = -16;
const int WS_BORDER = 0x00800000; // thin border
const int WS_THICKFRAME = 0x00040000; // sizing (thick) border
public static bool NativeWindowHasBorder(IntPtr hWnd)
{
return (GetWindowLong(hWnd, GWL_STYLE) & (WS_BORDER | WS_THICKFRAME)) != 0;
}
Control
s 本身实际上并没有句柄。Control.Handle
实际上返回它的父窗口的.Handle
.
获取控件绑定到的窗口句柄。
如果您查看反编译的源代码Control
,您会看到:
internal IntPtr HandleInternal
{
get
{
return this.window.Handle;
}
}
编辑
我上面所说的完全不正确。出于历史原因,我要离开它。
Button
可以通过将 a放在a 上Form
并查看IntPtr Handle
它们的值来很容易地证明这一点。它们是不同的。