Window Resizing and Windows Snap

Okay friends, after a long and very frustrating day I give up hoping that the wisdom of the collective can provide and answer. We have a cross-platform application written in Xojo 2019 R1.1 that has a canvas-based Toolbar across the top of the window, and a couple of container controls that fill the rest of the window. All of them are Locked top/left/right/bottom.

If I resize manually, maximize, minimize I don’t have any issues. Things act like they should. However, if I hold the Windows key down and the do a quick Right Arrow and then Left Arrow the canvas and the containers go all weird. I think this called the Windows ‘snap’ effect but I may not have the name right.

Anyway, why should the control locks suddenly stop working? I could maybe see the container controls but the canvas? It’s quite possibly the simplest thing on the whole window.

Any ideas?

Welcome Bob Keeney Pro :stuck_out_tongue:

I don’t see that here Bob (W10 19r1.1), I just threw a container control with a coloured background and a canvas on a window and its locking remained where I expected. Are you able to put a little demo together?

That’s been my issue. I don’t have it happen in a simple project it’s only when I have my big project that has multiple levels of containers.

For the record this Windows feature is called Aero Snap Assist. I’m wondering if there’s a way to programmatically disable it for my application since it causes so many issues.

For completeness sake here is my workaround. I disable the Aero snap by using the WindowsKeyFilterMBS class. I simply return true if the Windows key and either left/right arrows are used together. Seems to work like a champ.

I found another interesting side effect of the snap. Windows likes to force the size of the Window to half of the screen even if the Xojo window minimum width is larger than that. I think ultimately that is where it was getting screwed up.

1 Like

seems this should be reported as a framework bug or something ?

<https://xojo.com/issue/61107>

Hopefully this keeps someone else from getting frustrated trying to figure out why their Xojo app loses the lock left/right settings in Windows. The key is to have a minimum width more than half the screen. I didn’t check but I have to believe it won’t respect the maximum windows size either.

The easiest workaround I’ve found (so far) is to use WindowsKeyFilterMBS to tell the Windows OS to go shove off. I think the Aero Snap is on by default so most users have no idea what it is (I didn’t until this morning).

The first time I hit CMD-Left arrow and it did this (in a VM) I had to wonder who the hell though this “feature” was a good idea
I still wonder that every time I accidentally hit those keystrokes :stuck_out_tongue:

@Bob_Keeney2, does the Window’s maximize or minimize event fire when this happens? If so, you may be able to immediately call the Restore method to it it back.