110,539
社区成员
发帖
与我相关
我的任务
分享
const int WM_SYSCOMMAND = 0x112;
const int SC_CLOSE = 0xF060;
const int SC_MINIMIZE = 0xF020;
const int SC_MAXIMIZE = 0xF030;
protected override void WndProc(ref Message SystemMessage)
{
switch (SystemMessage.Msg)
{
case WM_SYSCOMMAND:
if (((int)SystemMessage.WParam) == 0xf040)
{
//最小化事件代码
this.WindowState = FormWindowState.Normal;
f2.WindowState = FormWindowState.Normal;
}
else
{
base.WndProc(ref SystemMessage);
}
break;
default:
base.WndProc(ref SystemMessage);
break;
}
}
Form2 f2 = new Form2();
private void button1_Click(object sender, EventArgs e)
{
f2.Owner = this;
f2.ShowDialog();
}
public void Formmin()
{
this.WindowState = FormWindowState.Minimized;
}
private void Form1_Resize(object sender, EventArgs e)
{
if (this.WindowState == FormWindowState.Normal)
{
f2.ShowDialog();
}
}
const int WM_SYSCOMMAND = 0x112;
const int SC_CLOSE = 0xF060;
const int SC_MINIMIZE = 0xF020;
const int SC_MAXIMIZE = 0xF030;
protected override void WndProc(ref Message SystemMessage)
{
switch (SystemMessage.Msg)
{
case WM_SYSCOMMAND:
if (((int)SystemMessage.WParam) == SC_MINIMIZE)
{
//最小化事件代码
Form1 f1 = (Form1)this.Owner;
f1.Formmin();
this.WindowState = FormWindowState.Normal;
this.Hide();
}
else
{
base.WndProc(ref SystemMessage);
}
break;
default:
base.WndProc(ref SystemMessage);
break;
}
}
protected override void OnResize(EventArgs e)
{
if(WindowState == FormWindowState.Maximized)
{
//最大化时所需的操作
MessageBox.Show("max");
}
else if(WindowState == FormWindowState.Minimized)
{
//最小化时所需的操作
MessageBox.Show("min");
}
}
const int WM_SYSCOMMAND = 0x112;
const int SC_CLOSE = 0xF060;
const int SC_MINIMIZE = 0xF020;
const int SC_MAXIMIZE = 0xF030;
protected override void WndProc(ref Message SystemMessage)
{
switch (SystemMessage.Msg)
{
case WM_SYSCOMMAND:
if (((int)SystemMessage.WParam) == 0xF020)
{
//最小化事件代码
this.WindowState = FormWindowState.Normal;
f2.WindowState = FormWindowState.Normal;
}
else
{
base.WndProc(ref SystemMessage);
}
break;
default:
base.WndProc(ref SystemMessage);
break;
}
}
Form2 f2 = new Form2();
private void button1_Click(object sender, EventArgs e)
{
f2.Owner = this;
f2.TopLevel = false;
f2.Parent = this;
f2.Show();
}
public void Formmin()
{
this.WindowState = FormWindowState.Minimized;
}
private void Form1_Resize(object sender, EventArgs e)
{
if (this.WindowState == FormWindowState.Maximized)
{
this.WindowState = FormWindowState.Normal;
f2.WindowState = FormWindowState.Normal;
}
}
private void Form2_Resize(object sender, EventArgs e)
{
if (this.WindowState == FormWindowState.Minimized)
{
Form1 f1 = (Form1)this.ParentForm;
f1.Formmin();
}
}
private void button1_Click(object sender, EventArgs e)
{
WindowState = FormWindowState.Minimized;
Application.OpenForms["Form1"].WindowState = FormWindowState.Minimized;
}
private void Form2_Activated(object sender, EventArgs e)
{
if (WindowState == FormWindowState.Minimized)
{
WindowState = FormWindowState.Normal;
Application.OpenForms["Form1"].WindowState = FormWindowState.Normal;
}
}