Increasing Size Problem When Handling WM_NCCALCSIZE

semih artan 41 Reputation points
2020-12-30T15:12:00.563+00:00

Hello,

When I process the WM_NCCALCSIZE message, after minimizing and restoring the window, the window gains some size each time. I know it is caused by the function RestoreBoundsIfNecessary called in the WM_WINDOWPOSCHANGED message handler. And a solution has been provided for the issue in that stackoverflow question. But could there be a better solution? I'm waiting for your ideas. Also, this is a gif picture describing the issue.

52277-upload.gif
Best wishes

Windows Forms
Windows Forms
A set of .NET Framework managed libraries for developing graphical user interfaces.
1,863 questions
Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,471 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,480 questions
0 comments No comments
{count} votes

Accepted answer
  1. Castorix31 82,321 Reputation points
    2020-12-30T15:50:46.427+00:00

    A way (tested on Windows 10, 1909, .NET 4.7.2) =>

    protected override void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified)
    {
        base.SetBoundsCore(RestoreBounds.Left, RestoreBounds.Top, RestoreBounds.Width, RestoreBounds.Height, BoundsSpecified.All);
    }
    
    2 people found this answer helpful.

0 additional answers

Sort by: Most helpful