如题,为什么结果都是不重合?请指教,谢谢!
我用的是 VS2008,目标 Framework 是 2.0,OS 是 Windows7 64位
using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
private struct RECT
{
public int Left;
public int Top;
public int Right;
public int Bottom;
}
[DllImport("user32.dll")]
private static extern int IntersectRect(RECT lpDestRect, RECT lpSrc1Rect, RECT lpSrc2Rect);
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
RECT destRect = new RECT();
RECT src1Rect = new RECT();
RECT src2Rect = new RECT();
src1Rect.Left = pictureBox1.Left;
src1Rect.Top = pictureBox1.Top;
src1Rect.Right = pictureBox1.Right;
src1Rect.Bottom = pictureBox1.Bottom;
src2Rect.Left = pictureBox2.Left;
src2Rect.Top = pictureBox2.Top;
src2Rect.Right = pictureBox2.Right;
src2Rect.Bottom = pictureBox2.Bottom;
int result = IntersectRect(destRect, src1Rect, src2Rect);
if (result != 0)
{
Console.WriteLine("重合");
} else {
Console.WriteLine("不重合");
}
}
}
}
我用的是 VS2008,目标 Framework 是 2.0,OS 是 Windows7 64位
using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
private struct RECT
{
public int Left;
public int Top;
public int Right;
public int Bottom;
}
[DllImport("user32.dll")]
private static extern int IntersectRect(RECT lpDestRect, RECT lpSrc1Rect, RECT lpSrc2Rect);
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
RECT destRect = new RECT();
RECT src1Rect = new RECT();
RECT src2Rect = new RECT();
src1Rect.Left = pictureBox1.Left;
src1Rect.Top = pictureBox1.Top;
src1Rect.Right = pictureBox1.Right;
src1Rect.Bottom = pictureBox1.Bottom;
src2Rect.Left = pictureBox2.Left;
src2Rect.Top = pictureBox2.Top;
src2Rect.Right = pictureBox2.Right;
src2Rect.Bottom = pictureBox2.Bottom;
int result = IntersectRect(destRect, src1Rect, src2Rect);
if (result != 0)
{
Console.WriteLine("重合");
} else {
Console.WriteLine("不重合");
}
}
}
}