我不断收到两个错误:"不一致的可访问性"表明" ...比方法更难以获取......"。
我已经找到了解决这个问题的方法,而且每个答案基本上都是"让课程公开。"
因此,我被卡住了,因为班级已经公开了。
以下是发生错误的地方:
[DllImport("User32.Dll")]
public static extern bool GetClientRect(IntPtr hWnd, out RECT lpRect);
/// <summary>
/// Get the inner bounds of client window
/// </summary>
/// <param name="hWnd"></param>
/// <returns></returns>
public static RECT GetClientRect(IntPtr hWnd)
{
RECT result;
GetClientRect(hWnd, out result);
return result;
}
答案 0 :(得分:0)
是的,我知道RECT应该有效。我意识到我做错了什么。
[DllImport("User32.Dll")]
public static extern bool GetClientRect(IntPtr hWnd, out RECT lpRect);
public static RECT GetClientRect(IntPtr hWnd)
{
RECT result;
GetClientRect1(hWnd, out result);
RECT appRect = result;
return result;
}
appRect应该是RECT而不是Rectangle,因为它们属于不同的类型。 RECT因其结构而起作用:
[StructLayout(LayoutKind.Sequential)]
public struct RECT
{
public int left;
public int top;
public int right;
public int bottom;
}