Speed up the resizing of the control

In order to speed up the resizing of our control, it is possible to activate the culling feature even during its resizing.  Here is the snippet code for both WinForms and WPF. 

For WinForms:

 protected override void OnResizeBegin(EventArgs e)
        {
            base.OnResizeBegin(e);
 
            // speed up the resize of the control
            model1.ResizeBegin();
        }

For WPF:

 public class MainWindow : Window
    {
        public MainWindow()
        {
            ResizeBegin += MainWindow_ResizeBegin;                    
        }
        
        public event EventHandler ResizeBegin;
      	
        void MainWindow_ResizeBegin(object sender, EventArgs e)
	{
            model1.ResizeBegin();
	}

        private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            const int WM_ENTERSIZEMOVE = 0x0231;
            
            if (msg == WM_ENTERSIZEMOVE)
            {
                if (ResizeBegin != null)
                {
                    ResizeBegin(this, EventArgs.Empty);
                }
            }
            
            return IntPtr.Zero;
        }
        
        protected override void OnContentRendered(EventArgs e)
	{
    	    HwndSource source = HwndSource.FromHwnd(new WindowInteropHelper(this).Handle);
            source.AddHook(new HwndSourceHook(WndProc));
            base.OnContentRendered(e);
        }
        
    }
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.