lhw Posted March 13, 2011 Share Posted March 13, 2011 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 More sharing options...
Moderators Melba23 Posted March 13, 2011 Moderators Share Posted March 13, 2011 lhw,I would do it like this - try actioning the main GUI or the "Test" button while the child is visible: expandcollapse popup#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 EndFuncIf you are not too familiar with GUIRegisterMsg, then I recommend the GUIRegisterMsg tutorial in the Wiki.Please ask if you have any questions. M23 kmaclamore 1 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
guinness Posted March 13, 2011 Share Posted March 13, 2011 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 parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
lhw Posted April 16, 2011 Author Share Posted April 16, 2011 (edited) @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 expandcollapse popup#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 April 16, 2011 by lhw Link to comment Share on other sites More sharing options...
lhw Posted April 16, 2011 Author Share Posted April 16, 2011 (edited) @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 expandcollapse popup#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 April 16, 2011 by lhw Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 16, 2011 Moderators Share Posted April 16, 2011 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, "") ElseDoes that solve your problem? M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
guinness Posted April 16, 2011 Share Posted April 16, 2011 Probably best to use Melba23's advice 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 parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
lhw Posted April 17, 2011 Author Share Posted April 17, 2011 (edited) 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 ,now no more need make $input dropaccepted and nodropaccepted again and again and again , Edited April 17, 2011 by lhw Link to comment Share on other sites More sharing options...
lhw Posted April 17, 2011 Author Share Posted April 17, 2011 Probably best to use Melba23's advice i'm with you Link to comment Share on other sites More sharing options...
footswitch Posted July 8, 2011 Share Posted July 8, 2011 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 More sharing options...
Moderators Melba23 Posted July 8, 2011 Moderators Share Posted July 8, 2011 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 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
footswitch Posted July 8, 2011 Share Posted July 8, 2011 @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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now