Jump to content

Freeze father GUI completely when a child GUI active


lhw
 Share

Recommended Posts

How could i make all controls freeze at father GUI when a child GUI active also keep child GUI stay at the center of father GUI?

a couple hours on this without success,could anyone kinldly give me some pointers or sample codes for doing this,help is always appreciated.

Link to comment
Share on other sites

  • Moderators

lhw,

I would do it like this - try actioning the main GUI or the "Test" button while the child is visible: :)

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$hGUI = GUICreate("Test", 500, 500)

$hButton_1 = GUICtrlCreateButton("Test", 10, 10, 80, 30)

$hButton_2 = GUICtrlCreateButton("Child", 10, 100, 80, 30)

GUISetState()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hButton_1
            MsgBox(0, "Button", "Pressed")
        Case $hButton_2
            ; Disable parent GUI
            GUISetState(@SW_DISABLE, $hGUI)
            ; Create child = adjust the coordinates to get it into the middle of the parent
            $hGUI_Child = GUICreate("Child", 200, 200, 150, 150, $GUI_SS_DEFAULT_GUI, $WS_EX_MDICHILD, $hGUI)
            GUISetState()
            ; Intercept attempts to move the child
            GUIRegisterMsg($WM_SYSCOMMAND, "On_WM_SYSCOMMAND")
            ; Wait for the child to close
            While 1
                If GUIGetMsg() = $GUI_EVENT_CLOSE Then ExitLoop
            WEnd
            ; Stop move message interception
            GUIRegisterMsg($WM_SYSCOMMAND, "")
            ; Re-enable main GUI
            GUISetState(@SW_ENABLE, $hGUI)
            ; Delete child
            GUIDelete($hGUI_Child)

    EndSwitch

WEnd

Func On_WM_SYSCOMMAND($hWnd, $Msg, $wParam, $lParam)
    ; Is it the child sending the message?
    If $hWnd = $hGUI_Child Then
        ; Is it a move message?
        If BitAND($wParam, 0xFFF0) = 0xF010 Then Return False ; $SC_MOVE
    EndIf

    Return $GUI_RUNDEFMSG
EndFunc

If you are not too familiar with GUIRegisterMsg, then I recommend the GUIRegisterMsg tutorial in the Wiki.

Please ask if you have any questions. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Also, have a look in my signature for _GUIDisable() to create a dark effect on the Main GUI.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_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: 22/04/2018

Link to comment
Share on other sites

  • 1 month later...

@guinness : do you have some solution to handle this that drag n dropped item penetrate child GUI to main GUI when a input control on child GUI just hang over a input control on parent GUI and both input controls have DnD featrues,sorry my poor enlish, its just like the followings

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$MAINGUI = GUICreate("Program", 300, 200,  -1, -1, -1, $WS_EX_ACCEPTFILES)
$Input = GUICtrlCreateInput('', 56, 50, 137, 21)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
$MenuTool = GUICtrlCreateMenu('&Tool')
$subTool = GUICtrlCreateMenuItem('subtool', $MenuTool)

GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $GUI_EVENT_DROPPED
            If FileGetAttrib(@GUI_DragFile) == 'D' Then 
               GUICtrlSetData($Input, @GUI_DragFile)
            Else
                MsgBox(0, '', 'Only folder accepted')
            ENDIF
        Case $subTool
            GUISetState(@SW_DISABLE, $MainGUI)
            ;child GUI
            $Tool1 = GUICreate('Tool1', 240, 115,  10, 0, $GUI_SS_DEFAULT_GUI, $WS_EX_ACCEPTFILES+$WS_EX_MDICHILD, $MAINGUI)
            $Input2 = GUICtrlCreateInput('', 56, 10, 137, 21)
            GUICtrlSetState(-1, $GUI_DROPACCEPTED)
            GUISetState(@SW_SHOW)
 
            While 1
                $nMsg = GUIGetMsg()
                Switch $nMsg
                    Case $GUI_EVENT_CLOSE
                        GUISetState(@SW_ENABLE, $MainGUI)
                        GUIDelete($Tool1)
                        exitloop
                    Case $GUI_EVENT_DROPPED
            
                    If FileGetAttrib(@GUI_DragFile)== 'D' Then 
                        GUICtrlSetData($Input2, @GUI_DragFile)
                    Else
                        MsgBox(0, '', 'Only folder accepted')
                    EndIf
                EndSwitch
            WEND
    EndSwitch
WEnd
Func _GUIDisable($hHandle = -1, $iBrightness = 5, $hColor = 0x000000)
    If Not IsDeclared("Global_GUIDisable") Then Global $Global_GUIDisable = 0

    If $hHandle = -1 Then
        Local $hLabel = GUICtrlCreateLabel("", -99, -99, 1, 1)
        Local $aReturn = DllCall("User32.dll", "hwnd", "GetParent", "hwnd", GUICtrlGetHandle($hLabel))
        If @error Then Return SetError(1, 0 * GUICtrlDelete($hLabel), 0)
        GUICtrlDelete($hLabel)
        $hHandle = $aReturn[0]
    EndIf

    Local $iIsHWnd = IsHWnd($Global_GUIDisable)
    Switch $iIsHWnd
        Case 0
            Local $aWinGetPos = WinGetClientSize($hHandle)
            $Global_GUIDisable = GUICreate("", $aWinGetPos[0], $aWinGetPos[1], 0, 0, 0x80000000, 0x00000040, $hHandle)
            GUISetBkColor($hColor, $Global_GUIDisable)
            WinSetTrans($Global_GUIDisable, "", Round($iBrightness * (255 / 100)))
            GUISetState(@SW_SHOW, $Global_GUIDisable)
        Case 1
            GUIDelete($Global_GUIDisable)
    EndSwitch
    Return $Global_GUIDisable
EndFunc   ;==>_GUIDisable

BTW, i use GUICtrlSetState($Input, $GUI_NODROPACCEPTED) to avoid this happen when child GUI works,but i think its not a good way,

Edited by lhw
Link to comment
Share on other sites

@Melba23 : do you have some solution to handle this that drag n dropped item penetrate child GUI to main GUI when a input control on child GUI just hang over a input control on parent GUI and both input controls have DnD featrues,sorry my poor enlish, its just like the followings,sorry i'm confused yours parent GUI disable function with Guiness's GUI disable

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$MAINGUI = GUICreate("Program", 300, 200,  -1, -1, -1, $WS_EX_ACCEPTFILES)
$Input = GUICtrlCreateInput('', 56, 50, 137, 21)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
$MenuTool = GUICtrlCreateMenu('&Tool')
$subTool = GUICtrlCreateMenuItem('subtool', $MenuTool)

GUISetState()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $GUI_EVENT_DROPPED
            If StringInStr(FileGetAttrib(@GUI_DragFile), 'D') Then 
               GUICtrlSetData($Input, @GUI_DragFile)
            Else
                MsgBox(0, '', 'Only folder accepted')
            ENDIF

        Case $subTool
            ; Disable parent GUI
            GUISetState(@SW_DISABLE, $MAINGUI)
            ; Create child = adjust the coordinates to get it into the middle of the parent
            $hGUI_Child = GUICreate('Tool1', 240, 115,  10, 0, $GUI_SS_DEFAULT_GUI, $WS_EX_ACCEPTFILES+$WS_EX_MDICHILD, $MAINGUI)
            $Input2 = GUICtrlCreateInput('', 56, 10, 137, 21)
            GUICtrlSetState(-1, $GUI_DROPACCEPTED)
            GUISetState(@SW_SHOW)
            ; Intercept attempts to move the child
            GUIRegisterMsg($WM_SYSCOMMAND, "On_WM_SYSCOMMAND")
            ; Wait for the child to close
            While 1
                Switch GUIGetMsg()
                Case $GUI_EVENT_CLOSE 
                        GUISetState(@SW_ENABLE, $MainGUI)
                        GUIDelete($hGUI_Child)
                        exitloop
                Case $GUI_EVENT_DROPPED
                     If StringInStr(FileGetAttrib(@GUI_DragFile), 'D') Then 
                        GUICtrlSetData($Input2, @GUI_DragFile)
                     Else
                        MsgBox(0, '', 'Only folder accepted')
                     ENDIF
                EndSwitch
            WEnd
            ; Stop move message interception
            GUIRegisterMsg($WM_SYSCOMMAND, "")
            ; Re-enable main GUI
            GUISetState(@SW_ENABLE, $MAINGUI)

    EndSwitch

WEnd

Func On_WM_SYSCOMMAND($hWnd, $Msg, $wParam, $lParam)
    ; Is it the child sending the message?
    If $hWnd = $hGUI_Child Then
        ; Is it a move message?
        If BitAND($wParam, 0xFFF0) = 0xF010 Then Return False ; $SC_MOVE
    EndIf

    Return $GUI_RUNDEFMSG
EndFunc
Edited by lhw
Link to comment
Share on other sites

  • Moderators

lhw,

Why not just make sure that there is nothing in the "main" input like this? :>

If StringInStr(FileGetAttrib(@GUI_DragFile), 'D') Then
    GUICtrlSetData($Input2, @GUI_DragFile)
    GUICtrlSetData($Input, "")
Else

Does that solve your problem? :unsure:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Probably best to use Melba23's advice :unsure:

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_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: 22/04/2018

Link to comment
Share on other sites

lhw,

Why not just make sure that there is nothing in the "main" input like this? ;)

If StringInStr(FileGetAttrib(@GUI_DragFile), 'D') Then
    GUICtrlSetData($Input2, @GUI_DragFile)
    GUICtrlSetData($Input, "")
Else

Does that solve your problem? :>

M23

sweet solution should be also the best solution :D ,now no more need make $input dropaccepted and nodropaccepted again and again and again :unsure:, Edited by lhw
Link to comment
Share on other sites

  • 2 months later...

Hello,

Not trying to get out of line here, but would there be a way a child GUI could act the same way as an InputBox, MsgBox or FileOpenDialog?

When these functions are called with the parent GUI parameter defined, they do "block" the parent GUI; that would be the exact behavior I'd be looking for:

$GUI_parent=GUICreate("",500,400)
GUISetState()
InputBox("","As you can see, clicking the parent GUI isn't possible until you close this child window.","","",-1,-1,200,200,0,$GUI_parent)

If I have to use GUI_DISABLE and GUI_ENABLE, this will add a whole lot of "noise" to the script.

So I was wondering if there is another way... any ideas?

Regards,

footswitch

Link to comment
Share on other sites

  • Moderators

footswitch,

A couple of additional lines each time you create a child GUI does not seem very "noisy" to me. :)

Of course you can always filter the events to prevent those from the main GUI being actioned while the child is active - the Managing Multiple GUIs tutorial in the Wiki shows you how to go about this - but I would suggest that this might make your script even louder. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

@M23

Come to think about it, you're probably right.

I have functions inside other include files, and these functions create child GUIs. Evidently I need to pass the parent GUI's handle as a parameter.

So if I'm thinking straight, if I turn my child GUI's creations and deletions into their own functions, it won't be that "noisy" to include those lines inside of them.

Thank you for making me think :)

Sometimes that's all we need, right?

footswitch

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...