Sign in to follow this  
Followers 0
orbs

SnapFix UDF - prevent Windows 10 from molesting your non-resizable GUI

3 posts in this topic

#1 ·  Posted (edited)

Summary

following this discussion in the GUI H&S forum:

this UDF attempts to provide an easy fix for the issue in Windows 10 Snap feature, that wrongly resizes a window when dragged way off-screen.

the issue is apparent for non-resizable windows, when the Snap feature is turned OFF.

 

How To Test

on a Windows 10 machine (also tested on a VM), disable the Snap feature (right-click the desktop > Display settings > Multitasking).

download the UDF and the example into the same folder, and run the example. it will create 4 windows which you can drag around to see how they react (and a MsgBox you can confirm to close the example script):

1. "Default" - drag this over the top of the screen (use the "drag" label) and see that it is being incorrectly resized.

2. "SnapFix" - this window uses the UDF to demonstrate that the issue is resolved.

3. "SnapFix_NoTitleBar" - this window demonstrates that the issue is resolved even for windows without a title bar

4. "SnapFix_PopUp" -  this window demonstrates that the $WS_POPUP style alone is NOT WORKING properly! must be combined with $WS_BORDER or $WS_THICKFRAME to work.

 

How To Use

first, the UDF needs to be included and initialized. add this at the top of your script:

#include <SnapFix.au3>

_SnapFix_Init()

to enable the UDF for you GUI (multiple GUI's supported, not all your GUI's must be fixed), add this line after creating a GUI:

_SnapFix($hGUI)

where $hGUI is the GUI handle as returned by GUICreate()

 

The UDF

 SnapFix.au3

 SnapFix_Example.au3

 

What Next

as described above, $WS_POPUP alone is not working. an override is suggested, but perhaps a solution exists.

the UDF sets some global conditions: it changes the default GUI resize mode, and registers the window message WM_SIZE, so if your script registers the WM_SIZE message for its own purposes, then in your registered function, you must call the internal UDF function __SnapFix_WM_SIZE(), like this:

Func MY_WM_SIZE($hWnd, $iMsg, $wParam, $lParam)
    __SnapFix_WM_SIZE($hWnd, $iMsg, $wParam, $lParam)
    ; your original function contents here
EndFunc   ;==>MY_WM_SIZE

 

the global conditions are not thoroughly tested, so use with caution!

 

Edited by orbs
1 person likes this

Share this post


Link to post
Share on other sites



Thank you @orbs  for your work in putting this UDF together. I'm happy to hear about your workaround.  Just a couple of questions:

  1. Will this have any effect on our GUI's under the previous versions of Windows?
  2. Will we need to code for first checking the OS Version before implementing a "snapfix"?

Thank you.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

this UDF has no apparent effect on Windows 7, as well as on Windows 10 with Snap set to ON. (well, more precisely, it mimics the expected behavior, which occurs anyways). the effect of this UDF is only apparent on Windows 10 with Snap set to OFF.

not tested on the following versions of Windows:

8

8.1

8.1 Update 1

8.1 Update 1 mark 1

8.1 Update 1 mark 1 RC1

8.1 Update 1 mark 1 RC1.1

8.1 Update 1 mark 1 RC1.1 HotFix 1

...and the rest of the Windows 8 series.

 

EDIT: reminder: do NOT "SnapFix" your GUI if it is resizable. only non-resizable GUI should use SnapFix.

 

Edited by orbs

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0