Sign in to follow this  
Followers 0
guinness

WM_SYSCOMMAND & $SC_SIZE not catching Windows 7 "docking feature."

3 posts in this topic

#1 ·  Posted (edited)

The following code works as intended. When the "Intercept" button is selected the GUI can't be resized/maximised. But with Windows 7 you can still drag the window to the left/right or top and it will resize accordingly, therefore suggesting $SC_SIZE isn't being "caught" with this "Windows 7 feature."

I was therefore wondering did anyone have a workaround to to stop the GUI resizing when a user docks in Windows 7? Any help would be greatly appreciated.

#include <WindowsConstants.au3>

Global $iIntercept = 0
_Main()

Func _Main()
    Local $iButton

    GUICreate("GUI", 200, 100, -1, -1, BitOR($WS_MAXIMIZEBOX, $WS_SIZEBOX))
    $iButton = GUICtrlCreateButton("Intercept", 5, 5, 85, 25)
    GUICtrlSetResizing($iButton, 802) ; $GUI_DOCKALL
    GUIRegisterMsg(0x0112, "WM_SYSCOMMAND")
    GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case -3
                Exit

            Case $iButton
                Switch GUICtrlRead($iButton)
                    Case "Intercept"
                        GUICtrlSetData($iButton, "Intercepted")
                        $iIntercept = 1

                    Case Else
                        GUICtrlSetData($iButton, "Intercept")
                        $iIntercept = 0

                EndSwitch

        EndSwitch
    WEnd
EndFunc   ;==>_Main

Func WM_SYSCOMMAND($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $lParam
    Local Const $SC_MAXIMIZE = 0xF030
    Local Const $SC_SIZE = 0xF000

    Switch BitAND($wParam, 0xFFF0)
        Case $SC_MAXIMIZE, $SC_SIZE
            If $iIntercept = 1 Then
                Return -1
            EndIf
    EndSwitch
    Return "GUI_RUNDEFMSG"
EndFunc   ;==>WM_SYSCOMMAND
Edited by guinness

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites



Currently working on a XP machine :), but how about this?

#include <WindowsConstants.au3>

Global $iIntercept = 0, $aWinPos
_Main()

Func _Main()
    Local $iButton

    GUICreate("GUI", 200, 100, -1, -1, BitOR($WS_MAXIMIZEBOX, $WS_SIZEBOX))
    $iButton = GUICtrlCreateButton("Intercept", 5, 5, 85, 25)
    GUICtrlSetResizing($iButton, 802) ; $GUI_DOCKALL
    GUIRegisterMsg(0x0024, "WM_GETMINMAXINFO")
    GUIRegisterMsg(0x0112, "WM_SYSCOMMAND")
    GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case -3
                Exit

            Case $iButton
                Switch GUICtrlRead($iButton)
                    Case "Intercept"
                        GUICtrlSetData($iButton, "Intercepted")
                        $iIntercept = 1

                    Case Else
                        GUICtrlSetData($iButton, "Intercept")
                        $iIntercept = 0

                EndSwitch

        EndSwitch
    WEnd
EndFunc   ;==>_Main

Func WM_GETMINMAXINFO($hWnd, $MsgID, $wParam, $lParam)
    #forceref $MsgID, $wParam
    If $iIntercept Then
        $structmaxinfo = DllStructCreate("int;int;int;int;int;int;int;int;int;int", $lParam)
        DllStructSetData($structmaxinfo, 7, $aWinPos[2]); min X
        DllStructSetData($structmaxinfo, 8, $aWinPos[3]); min Y
        DllStructSetData($structmaxinfo, 9, $aWinPos[2]); max X
        DllStructSetData($structmaxinfo, 10, $aWinPos[3]); max Y
    Else
        $aWinPos = WinGetPos($hWnd, "")
        ;ConsoleWrite($aWinPos[2] & @TAB & $aWinPos[3] & @CRLF)
    EndIf
    Return "GUI_RUNDEFMSG"
EndFunc   ;==>WM_GETMINMAXINFO


Func WM_SYSCOMMAND($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $lParam
    Local Const $SC_MAXIMIZE = 0xF030
    Local Const $SC_SIZE = 0xF000

    Switch BitAND($wParam, 0xFFF0)
        Case $SC_MAXIMIZE, $SC_SIZE
            If $iIntercept = 1 Then
                Return -1
            EndIf
    EndSwitch

    Return "GUI_RUNDEFMSG"
EndFunc   ;==>WM_SYSCOMMAND

Share this post


Link to post
Share on other sites

Wow! I always use WM_GETMINMAXINFO to set the minimum GUI height/width, but really didn't think about using it here :) Thanks ever so much KaFu, you showed me how to think outside the box :)


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

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