调用GetClientRect winAPI

时间:2012-10-26 12:27:56

标签: c# winapi getclientrect

我在尝试调用GetClientRect并传入Stuct时会遇到问题,以便填充返回的值。这是我的代码。

[return: MarshalAs(UnmanagedType.Bool)]
        [DllImport("user32.dll")]
        internal static extern bool GetClientRect(IntPtr hwnd, ref RECT lpRect);

        [StructLayout(LayoutKind.Sequential)]
        internal struct RECT
        {
            internal int left;
            internal int top;
            internal int right;
            internal int bottom;
        }
     RECT rect = new RECT();

     GetClientRect(PApplication.Instance.MdiMain.Handle, ref rect);

我一直在RECT上收到错误,说错误1嵌入式语句不能是声明或带标签的声明。

我只需要帮助从GetClientRect

中取回左上角的瓶底值

1 个答案:

答案 0 :(得分:0)

我发现它将代码放在if之后并忘记添加{}所以我现在很好。