【问题标题】:Call GetClientRect winAPI调用 GetClientRect winAPI
【发布时间】:2012-10-26 12:27:55
【问题描述】:

我在尝试调用 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 取回左上右下角的值

【问题讨论】:

  • 你把这些行放在哪里了?
  • 当你说我再看一遍时,我忘了在 if 之后包装我的代码 {}。谢谢!

标签: c# winapi getclientrect


【解决方案1】:

我找到了,我把代码放在 if 之后忘记添加 { } 所以我现在很好。

【讨论】:

    猜你喜欢
    • 2011-11-25
    • 1970-01-01
    • 2011-11-04
    • 2016-05-16
    • 1970-01-01
    • 1970-01-01
    • 2013-07-13
    • 1970-01-01
    • 2022-07-06
    相关资源
    最近更新 更多