【发布时间】:2011-11-18 16:27:15
【问题描述】:
我在这里有点卡住了。我试图在不使用 OnMove、LocationChanged、Docking 等的情况下同时移动 2 个表单。
与其位置交互的唯一方法是覆盖 WndProc。可能有用的是表单 A 是表单 B 的所有者。因此,每当移动 A 时,我也想移动 B。不是同一个位置,而是同一个距离。
protected override void WndProc(ref Message m)
{
if (m.Msg == 0x0084)
{
Form[] temp = this.OwnedForms;
if(temp.Length > 0)
{
/* moving temp[0] to the same ratio as this form */
}
m.Result = (IntPtr)2;
return;
}
base.WndProc(ref m);
}
A 和 B 具有相同的 WndProc,因为它们是来自同一类的 2 个对象。
【问题讨论】: