Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Event called after windows maximized

I'm looking for an event from a form that called after a window is maximized or minimized.

As far as I know there is such event as SizeChanged or WndProc that can handle maximized window, but it's called right away after user try to maximize the window, and it's not called after the window is fully maximized.

I'm looking for event like ResizeEnd, but maybe this one is called MaximizedEnd or MinimizedEnd

Is there anyway to do that?

like image 334
euclid135 Avatar asked May 04 '12 01:05

euclid135


1 Answers

I think it's as simple as this:

protected override void OnSizeChanged(EventArgs e) {
  if (this.WindowState == FormWindowState.Maximized) {
    MessageBox.Show("Max!");
  }
  base.OnSizeChanged(e);
}

Not sure what you mean by after the window is sized. This might work, too:

protected override void OnSizeChanged(EventArgs e) {
  if (this.WindowState == FormWindowState.Maximized) {
    this.BeginInvoke(new MethodInvoker(delegate { MessageBox.Show("Maxed"); }));
  }
  base.OnSizeChanged(e);
}

Replace the MessageBox.Show(...) with your code.

like image 171
LarsTech Avatar answered Sep 20 '22 04:09

LarsTech