
Untitled
By: a guest on
May 21st, 2012 | syntax:
None | size: 1.70 KB | hits: 17 | expires: Never
Moving 2 forms at the same time
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);
}
private Point lastPos;
protected override void OnLoad(EventArgs e) {
base.OnLoad(e);
lastPos = this.Location;
}
protected override void OnLocationChanged(EventArgs e) {
base.OnLocationChanged(e);
foreach (var frm in this.OwnedForms) {
frm.Location = new Point(frm.Location.X + this.Left - lastPos.X,
frm.Location.Y + this.Top - lastPos.Y);
}
lastPos = this.Location;
}
protected override void WndProc(ref Message m) {
// Move borderless window with click-and-drag on client window
if (m.Msg == 0x84) m.Result = (IntPtr)2;
else base.WndProc(ref m);
}
protected override void WndProc(ref Message m)
{
Form temp = this.Owner;
if (m.Msg == 0x0084)
{
m.Result = (IntPtr)2;
return;
}
if (m.Msg == 0x0216 && temp != null)
{
if (!movedonce)
{
oldlocationx = this.Location.X;
oldlocationy = this.Location.Y;
movedonce = true;
}
temp.Location = new Point(temp.Location.X + this.Location.X - oldlocationx, temp.Location.Y + this.Location.Y - oldlocationy);
oldlocationx = this.Location.X;
oldlocationy = this.Location.Y;
}
base.WndProc(ref m);
}