21

What windows message or event can i listen to in order to stop a window from being redrawing every pixel of it's resize?

That is, when a user clicks on the edge of the window and starts to re-size it, i don't want to re-draw the entire contents until he lets go. This is because for some reason it's currently choppy at resizing probably because everything is re-docking and what not.

I tried WM_SIZING but that only tells me it's being re-sized, i wish to know the start and end of the sizing so i can suspend the layout until the user stops resizing.

default locale
  • 11,849
  • 13
  • 52
  • 59
Daniel
  • 805
  • 1
  • 8
  • 12

1 Answers1

47

Nevermind, just found these two events.

this.ResizeBegin += (s, e) => { this.SuspendLayout(); };
this.ResizeEnd += (s, e) => { this.ResumeLayout(true); };

Works a treat

Daniel
  • 805
  • 1
  • 8
  • 12
  • 3
    Accept this as the answer, will be useful for people searching for the same problem in the future – Nick Craver Mar 01 '10 at 01:26
  • It says i have to wait 2 days before i can answer my own question – Daniel Mar 01 '10 at 01:30
  • 3
    +1 for use of Lambda syntax in event assignment. But, users please note : if this type of syntax using 'e is used inside something like a Form Load event, or anything using the standard 'e name for an EventArgument type argument : the variable name 'e will already be in use, so changing to something else like 'evt might be handy. – BillW Mar 01 '10 at 05:25