// 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不是已经返回左上角和右边的位置了吗?发布于 2020-10-08 10:53:08
我不清楚你在问什么,但你可以找到API信息这里。
您将发现GetWindowRect只返回boolean,而不返回RECT。
但是,它写入第二个参数以设置RECT结构。
在最终修改了值之后,他们检索了从rect获得的GetWindowrect()。
https://stackoverflow.com/questions/64260916
复制相似问题