Void CreateSubWindow()
{
TestWindow ts = new TestWindow(2);
ts.Title = "TP-" + (i + 1);
ts.TestFormIndex = i;
ts.WindowStartupLocation = WindowStartupLocation.Manual;
ResizeSubWindow(ts);
ts.Owner = this;
ts.TestReadyEvent += new TestReadyEventHandler(OneTestReady);
ts.TestFinishEvent += new TestFinishEventHandler(OneTestFinish);
ts.Show();
}
void ResizeSubWindow(TestWindow ts)
{
GetWindowSize();
ts.Width = (WindowMax.W_Width - 7) / SubFormCount;
ts.Height = WindowMax.W_Height - 110;
ts.Left = WindowMax.W_Left + (ts.Width - 10) * ts.TestFormIndex + 5;
ts.Top = WindowMax.W_Top + 82;
}
#region 主窗口大小和位置改变后自动调整子窗口大小位置
private void Window_LocationChanged(object sender, EventArgs e)
{
Window_SizeChanged(sender, null);
}
void GetWindowSize()
{
if (this.WindowState == WindowState.Maximized)
{
WindowMax.W_Width = WF.SystemInformation.WorkingArea.Width;
WindowMax.W_Height = WF.SystemInformation.WorkingArea.Height;
WindowMax.W_Top = 0;
WindowMax.W_Left = 0;
return;
}
else
{
WindowMax.W_Height = this.Height;
WindowMax.W_Width = this.Width;
WindowMax.W_Top = this.Top;
WindowMax.W_Left = this.Left;
}
}
private void Window_SizeChanged(object sender, SizeChangedEventArgs e)
WPF 子窗口在父窗口固定位置显示,跟随父窗口移动改变大小
最新推荐文章于 2022-05-11 10:55:33 发布
本文探讨了如何在WPF中实现子窗口在父窗口的特定位置显示,并确保子窗口随父窗口移动和改变大小时保持相对位置。同时讲解了子窗口如何重写Window的最小化、最大化和关闭按钮行为,以及实现子窗口状态与父窗口的同步。
摘要由CSDN通过智能技术生成