【发布时间】:2021-01-23 09:44:39
【问题描述】:
// Get the size of the window to capture
Rectangle rect = new Rectangle();
GetWindowRect(handle, ref rect);
// GetWindowRect returns Top/Left and Bottom/Right, so fix it
rect.Width = rect.Width - rect.X;
rect.Height = rect.Height - rect.Y;
我的英语不是很好,但我对 C# 编码很感兴趣,如果我发布了一个愚蠢的问题,请见谅。
无论如何,我读到了GetWindowRect(handle, ref rect);,我知道这个函数会将句柄的Top/Left 和Bottom/Right 返回到“rect”。但是为什么这段代码需要通过
rect.Width = rect.Width - rect.X;
rect.Height = rect.Height - rect.Y;
-
有什么意义?
GetWindowRect不是已经返回左上角和右上角的位置了吗? -
他们为什么要修复它?
【问题讨论】:
-
只是一个糟糕的 [DllImport] 声明,使用 Rectangle 而不是 RECT。所以他们不得不在之后修复几何。
-
我可以说他们很懒吗?