110,534
社区成员
发帖
与我相关
我的任务
分享
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
internal static extern bool GetWindowRect(IntPtr hWnd, ref Rect rect);
public class Rect
{
long left;
long top;
long right;
long bottom;
public string ToString()
{
string str = "";
str += "Left:" + left;
str += "Top:" + top;
str += "Right:" + right;
str += "Bottom:" + bottom;
return str;
}
}
private void button1_Click(object sender, EventArgs e)
{
IntPtr handle = Handle;
Rect rect = new Rect();
GetWindowRect(handle, ref rect);
MessageBox.Show(rect.ToString());
}
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
internal static extern bool GetWindowRect(IntPtr hWnd, ref Rect rect);
public struct Rect
{
int left;
int top;
int right;
int bottom;
public override string ToString()
{
string str = "";
str += "Left:" + left.ToString();
str += "Top:" + top.ToString();
str += "Right:" + right.ToString();
str += "Bottom:" + bottom.ToString();
return str;
}
}