🌶️ Speed up the resizing of the control

Update for version 2022 and newer

Starting from Eyeshot 2022, this solution is no longer needed if Minimum Frame Rate is enabled.

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
    design1.ResizeBegin();
}

For WPF:

public class MainWindow
{
    public MainWindow()
    {
        ResizeBegin += MainWindow_ResizeBegin;
    }

    public event EventHandler ResizeBegin;

    void MainWindow_ResizeBegin(object sender, EventArgs e)
    {
        design1.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

Comments

0 comments

Please sign in to leave a comment.

Articles in this section

See more