Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Aero Snapping #223

Merged
merged 2 commits into from
Sep 26, 2021
Merged

Conversation

VolatilePulse
Copy link

Provides consistent control positioning by referencing client area instead of form area
Removed unnecessary WndProc code for resizing due to changes
Minimal code cleanup

Fixes maximize bug that allowed "drifting" of the window
Fixes maximize bug that prevented the form from being maximized on a second monitor
Fixes maximize bug that required the program to be maximized prior to snapping maximized

Provides consistent control positioning by referencing client area instead of form area
Removed unnecessary WndProc code for resizing due to changes
Minimal code cleanup

Fixes maximize bug that allowed "drifting" of the window
Fixes maximize bug that prevented the form from being maximized on a second monitor
Fixes maximize bug that required the program to be maximized prior to snapping maximized
@orapps44
Copy link
Collaborator

Thank you @VolatilePulse for this great work.

This code properly fix #84 #215 #219

@orapps44 orapps44 added this to the 2.3.0 milestone Sep 26, 2021
@orapps44 orapps44 merged commit 59a1221 into leocb:master Sep 26, 2021
@VolatilePulse VolatilePulse deleted the aero-snapping branch September 28, 2021 00:24
@orapps44
Copy link
Collaborator

@VolatilePulse : This PR seems to be root cause of issue #227.
Any idea what could be wrong ?

@VolatilePulse
Copy link
Author

VolatilePulse commented Sep 29, 2021

Yeah, I just noticed that last night but couldn't identify the cause of the issue. This helps me narrow down what's causing it and allow me to work on a solution. Unfortunately, I'll be out of town until next week.

Edit:
Additionally, my testing only increased the form size by 7 pixels per side, increasing it by 14px width and height. It's interesting to see they're experiencing twice that value.

@orapps44
Copy link
Collaborator

It seems to be related with WS_SIZEFRAME.

Issue is solved when WS_SIZEFRAME is removed from :

  par.Style = par.Style | WS_MINIMIZEBOX | WS_SYSMENU | WS_SIZEFRAME; // Turn on the WS_MINIMIZEBOX style flag

But without WS_SIZEFRAME, aero snap doesn't work ...

@VolatilePulse
Copy link
Author

VolatilePulse commented Sep 30, 2021

For the time being, this code will suffice for the designer. I'll have to do more investigating once I'm back as information is very limited.

        protected override CreateParams CreateParams
        {
            get
            {
                var par = base.CreateParams;
                par.Style |= WS_MINIMIZEBOX | WS.WS_SYSMENU;

                if (!DesignMode)
                    par.Style |= WS_SIZEFRAME;

                return par;
            }
        }

Edit:
This issue appears to actually be caused by the WM_NCCALCSIZE message just being discarded at the moment. Once I have time to play around with the code and do some testing, I'll release a fix for this.
https://docs.microsoft.com/en-us/windows/win32/winmsg/wm-nccalcsize

@orapps44
Copy link
Collaborator

Hi @VolatilePulse ,

Bug mentioned in #243, seems to be a side effect of this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Issue #215 is not solved WindowState property WindowState Maximized cover windows taskbar
2 participants