momar33 Posted April 17, 2008 Share Posted April 17, 2008 If you run the code below and maximize the child window, you'll notice that while it is maximized, you can still move the window by dragging the title bar. How can i prevent the child window from moving? Keep in mind that i want to keep the restore, minimize, and close buttons on the child. expandcollapse popup;-------------------------Includes-------------------------------------------- #include <GUIConstants.au3> #Include <GuiListView.au3> #Include <GuiComboBox.au3> ;#include "ADO.au3" ;#include "Variables.au3" ;-------------------------Options-------------------------------------------- ;Opt("MustDeclareVars" , 1) Opt("GUIOnEventMode" , 1) Opt("WinSearchChildren", 1) Global $openWindows[1] Global $child[100] Global $numChildGuis Global $spellEdit Global $first_SpellbookComboEvent = 0 ;----------Parent Window Dimensions---------- Local $parentWidth = 1000 Local $parentHeight = 600 Local $parentLeft = -1 Local $parentTop = -1 ;----------Tool Bar Dimensions--------------- Local $toolBarWidth = $parentWidth Local $toolBarHeight = 30 Local $toolBarLeft = 0 Local $toolBarTop = 0 ;----------Main Window Dimensions------------ Local $mainWidth = $parentWidth Local $mainHeight = $parentHeight - 50 Local $mainLeft = 0 Local $mainTop = $toolBarHeight ;-------------------------Gui Creation-------------------------------------------- ;Create the "parent" container window $parentGui = GUICreate("Spell Inventory", $parentWidth, $parentHeight, $parentLeft, $parentTop, $WS_OVERLAPPEDWINDOW) $openWindows[0] = "Spell Inventory" ;Create Events for $parentGui GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") GUISetOnEvent($GUI_EVENT_RESIZED, "_UpdateChildGui") GUISetOnEvent($GUI_EVENT_MAXIMIZE, "_UpdateChildGui") GUISetOnEvent($GUI_EVENT_RESTORE, "_UpdateChildGui") ;Create the Menu bar ;-----File Menu----- Global $fileMenu = GuiCtrlCreateMenu ("File") Global $importMI = GuiCtrlCreateMenuitem ("Import File", $filemenu) Global $separator = GuiCtrlCreateMenuitem ("", $filemenu) Global $ppOptionsMenu = GuiCtrlCreateMenu ("Print Preview Options", $filemenu) Global $separator = GuiCtrlCreateMenuitem ("", $filemenu) Global $exitMI = GuiCtrlCreateMenuitem ("Exit", $filemenu) ;-----Tools Menu----- Global $toolsMenu = GuiCtrlCreateMenu ("Tools") Global $manageSpellbooksMI = GuiCtrlCreateMenuitem ("Manage Spellbooks", $toolsMenu) Global $manageSchoolsMI = GuiCtrlCreateMenuitem ("Manage Schools", $toolsMenu) Global $manageSpellsMI = GuiCtrlCreateMenuitem ("Manage Spells", $toolsMenu) Global $separator = GuiCtrlCreateMenuitem ("", $toolsMenu) Global $manageScrollsMI = GuiCtrlCreateMenuitem ("Manage Scrolls", $toolsMenu) Global $separator = GuiCtrlCreateMenuitem ("", $toolsMenu) Global $searchMI = GuiCtrlCreateMenuitem ("Search", $toolsMenu) ;-----Window Menu----- Global $windowMenu = GuiCtrlCreateMenu ("Window") Global $tileMI = GuiCtrlCreateMenuitem ("Tile", $windowMenu) Global $separator = GuiCtrlCreateMenuitem ("", $windowMenu) Global $cascadeMI = GuiCtrlCreateMenuitem ("Cascade", $windowMenu) ;-----About Menu----- Global $aboutMenu = GuiCtrlCreateMenu ("About") Global $helpTopicsMI = GuiCtrlCreateMenuitem ("Help Topics", $aboutMenu) Global $separator = GuiCtrlCreateMenuitem ("", $aboutMenu) Global $aboutMI = GuiCtrlCreateMenuitem ("About SI", $aboutMenu) _CreateToolbar() $mainGui = GUICreate("mainGui", $mainWidth, $mainHeight, 0, 30, $WS_CHILD, Default, $parentGui) GUISetBkColor (0x888888) GUISetState() GUISetState(@SW_SHOW, $parentGui) if $numChildGuis < 100 then $child[$numChildGuis] = GUICreate(" Spellbook", 600, 420, 100 + $numChildGuis * 5, 0 + $numChildGuis * 5, $WS_OVERLAPPEDWINDOW, Default, $mainGui) DllCall("user32.dll", "int", "SetParent", "hwnd", WinGetHandle($child[$numChildGuis]), "hwnd", WinGetHandle($mainGui)) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") ;;GUISetOnEvent($GUI_EVENT_DROPPED, "Drop") $numChildGuis = $numChildGuis + 1 EndIf GUISetState() ;-------------------------Main Loop-------------------------------------------- While 1 Sleep(10) Wend ;-------------------------Functions-------------------------------------------- Func _Exit() If @GUI_WINHANDLE = $parentGui Then Exit ElseIf @GUI_WINHANDLE = WinGetHandle($child[$numChildGuis]) Then GUISwitch(WinGetHandle($child[$numChildGuis])) _ArrayDelete($openWindows, _ArraySearch($openWindows, WinGetTitle($child[$numChildGuis]))) GuiDelete() WinActivate("Spell Inventory") EndIf EndFunc Func _UpdateChildGui() Local $state, $array GUISetState (@SW_LOCK, $child[1]) $array = WinGetPos($parentGui) WinMove($mainGui, '', 0, 30, ($array[2]-8), ($array[3]-84)) ConsoleWrite("--"&$child[0]&@CR) If $child[0] <> 0 then For $i = 0 to $numChildGuis-1 step 1 ConsoleWrite("----"&$i&@CR) $state = WinGetState($child[$i]) If BitAnd($state, 32) Then WinMove($child[$i], '', -4, -4, $array[2], ($array[3]-76)) EndIf Next EndIf EndFunc Func _CreateToolbar() ;~ Local $spellBooksArray = _GetSpellBookList() Local $toolbar = GUICreate("toolbar", $toolBarWidth, $toolBarHeight, $toolBarLeft, $toolBarTop, $WS_CHILD , Default, $parentGui) $spellBooksCombo = GUICtrlCreateCombo ("", 5, 5, 120, 20, $CBS_DROPDOWN) ;GUICtrlSetOnEvent(-1, "_SpellbookComboEvent") GUICtrlSetData(-1,"Select Spellbook", "Select Spellbook") _GUICtrlComboBox_DeleteString($spellBooksCombo, 0) ;~ For $SB = 1 to $spellBooksArray[0] Step 1 ;~ GUICtrlSetData($spellBooksCombo, $spellBooksArray[$SB]) ;~ Next ;~ Global $viewSpell = GUICtrlCreateButton ("Spell", 120,0,50,20) ;~ GUICtrlSetOnEvent(-1, "_Create_VeiwSpell_Window") ;Global $testLabel = GUICtrlCreateLabel("khlskj", 170, 0, 100, 20) ;GUICtrlSetData(-1, GUICtrlRead($spellBooksCombo)) GUISetState () EndFunc Link to comment Share on other sites More sharing options...
martin Posted April 17, 2008 Share Posted April 17, 2008 If you run the code below and maximize the child window, you'll notice that while it is maximized, you can still move the window by dragging the title bar. How can i prevent the child window from moving? Keep in mind that i want to keep the restore, minimize, and close buttons on the child. expandcollapse popup;-------------------------Includes-------------------------------------------- #include <GUIConstants.au3> #Include <GuiListView.au3> #Include <GuiComboBox.au3> ;#include "ADO.au3" ;#include "Variables.au3" ;-------------------------Options-------------------------------------------- ;Opt("MustDeclareVars" , 1) Opt("GUIOnEventMode" , 1) Opt("WinSearchChildren", 1) Global $openWindows[1] Global $child[100] Global $numChildGuis Global $spellEdit Global $first_SpellbookComboEvent = 0 ;----------Parent Window Dimensions---------- Local $parentWidth = 1000 Local $parentHeight = 600 Local $parentLeft = -1 Local $parentTop = -1 ;----------Tool Bar Dimensions--------------- Local $toolBarWidth = $parentWidth Local $toolBarHeight = 30 Local $toolBarLeft = 0 Local $toolBarTop = 0 ;----------Main Window Dimensions------------ Local $mainWidth = $parentWidth Local $mainHeight = $parentHeight - 50 Local $mainLeft = 0 Local $mainTop = $toolBarHeight ;-------------------------Gui Creation-------------------------------------------- ;Create the "parent" container window $parentGui = GUICreate("Spell Inventory", $parentWidth, $parentHeight, $parentLeft, $parentTop, $WS_OVERLAPPEDWINDOW) $openWindows[0] = "Spell Inventory" ;Create Events for $parentGui GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") GUISetOnEvent($GUI_EVENT_RESIZED, "_UpdateChildGui") GUISetOnEvent($GUI_EVENT_MAXIMIZE, "_UpdateChildGui") GUISetOnEvent($GUI_EVENT_RESTORE, "_UpdateChildGui") ;Create the Menu bar ;-----File Menu----- Global $fileMenu = GuiCtrlCreateMenu ("File") Global $importMI = GuiCtrlCreateMenuitem ("Import File", $filemenu) Global $separator = GuiCtrlCreateMenuitem ("", $filemenu) Global $ppOptionsMenu = GuiCtrlCreateMenu ("Print Preview Options", $filemenu) Global $separator = GuiCtrlCreateMenuitem ("", $filemenu) Global $exitMI = GuiCtrlCreateMenuitem ("Exit", $filemenu) ;-----Tools Menu----- Global $toolsMenu = GuiCtrlCreateMenu ("Tools") Global $manageSpellbooksMI = GuiCtrlCreateMenuitem ("Manage Spellbooks", $toolsMenu) Global $manageSchoolsMI = GuiCtrlCreateMenuitem ("Manage Schools", $toolsMenu) Global $manageSpellsMI = GuiCtrlCreateMenuitem ("Manage Spells", $toolsMenu) Global $separator = GuiCtrlCreateMenuitem ("", $toolsMenu) Global $manageScrollsMI = GuiCtrlCreateMenuitem ("Manage Scrolls", $toolsMenu) Global $separator = GuiCtrlCreateMenuitem ("", $toolsMenu) Global $searchMI = GuiCtrlCreateMenuitem ("Search", $toolsMenu) ;-----Window Menu----- Global $windowMenu = GuiCtrlCreateMenu ("Window") Global $tileMI = GuiCtrlCreateMenuitem ("Tile", $windowMenu) Global $separator = GuiCtrlCreateMenuitem ("", $windowMenu) Global $cascadeMI = GuiCtrlCreateMenuitem ("Cascade", $windowMenu) ;-----About Menu----- Global $aboutMenu = GuiCtrlCreateMenu ("About") Global $helpTopicsMI = GuiCtrlCreateMenuitem ("Help Topics", $aboutMenu) Global $separator = GuiCtrlCreateMenuitem ("", $aboutMenu) Global $aboutMI = GuiCtrlCreateMenuitem ("About SI", $aboutMenu) _CreateToolbar() $mainGui = GUICreate("mainGui", $mainWidth, $mainHeight, 0, 30, $WS_CHILD, Default, $parentGui) GUISetBkColor (0x888888) GUISetState() GUISetState(@SW_SHOW, $parentGui) if $numChildGuis < 100 then $child[$numChildGuis] = GUICreate(" Spellbook", 600, 420, 100 + $numChildGuis * 5, 0 + $numChildGuis * 5, $WS_OVERLAPPEDWINDOW, Default, $mainGui) DllCall("user32.dll", "int", "SetParent", "hwnd", WinGetHandle($child[$numChildGuis]), "hwnd", WinGetHandle($mainGui)) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") ;;GUISetOnEvent($GUI_EVENT_DROPPED, "Drop") $numChildGuis = $numChildGuis + 1 EndIf GUISetState() ;-------------------------Main Loop-------------------------------------------- While 1 Sleep(10) Wend ;-------------------------Functions-------------------------------------------- Func _Exit() If @GUI_WINHANDLE = $parentGui Then Exit ElseIf @GUI_WINHANDLE = WinGetHandle($child[$numChildGuis]) Then GUISwitch(WinGetHandle($child[$numChildGuis])) _ArrayDelete($openWindows, _ArraySearch($openWindows, WinGetTitle($child[$numChildGuis]))) GuiDelete() WinActivate("Spell Inventory") EndIf EndFunc Func _UpdateChildGui() Local $state, $array GUISetState (@SW_LOCK, $child[1]) $array = WinGetPos($parentGui) WinMove($mainGui, '', 0, 30, ($array[2]-8), ($array[3]-84)) ConsoleWrite("--"&$child[0]&@CR) If $child[0] <> 0 then For $i = 0 to $numChildGuis-1 step 1 ConsoleWrite("----"&$i&@CR) $state = WinGetState($child[$i]) If BitAnd($state, 32) Then WinMove($child[$i], '', -4, -4, $array[2], ($array[3]-76)) EndIf Next EndIf EndFunc Func _CreateToolbar() ;~ Local $spellBooksArray = _GetSpellBookList() Local $toolbar = GUICreate("toolbar", $toolBarWidth, $toolBarHeight, $toolBarLeft, $toolBarTop, $WS_CHILD , Default, $parentGui) $spellBooksCombo = GUICtrlCreateCombo ("", 5, 5, 120, 20, $CBS_DROPDOWN) ;GUICtrlSetOnEvent(-1, "_SpellbookComboEvent") GUICtrlSetData(-1,"Select Spellbook", "Select Spellbook") _GUICtrlComboBox_DeleteString($spellBooksCombo, 0) ;~ For $SB = 1 to $spellBooksArray[0] Step 1 ;~ GUICtrlSetData($spellBooksCombo, $spellBooksArray[$SB]) ;~ Next ;~ Global $viewSpell = GUICtrlCreateButton ("Spell", 120,0,50,20) ;~ GUICtrlSetOnEvent(-1, "_Create_VeiwSpell_Window") ;Global $testLabel = GUICtrlCreateLabel("khlskj", 170, 0, 100, 20) ;GUICtrlSetData(-1, GUICtrlRead($spellBooksCombo)) GUISetState () EndFunc This doesn't stop resizing, just moving expandcollapse popup;-------------------------Includes-------------------------------------------- #include <GUIConstants.au3> #include <GuiListView.au3> #include <GuiComboBox.au3> ;#include "ADO.au3" ;#include "Variables.au3" ;-------------------------Options-------------------------------------------- ;Opt("MustDeclareVars" , 1) Opt("GUIOnEventMode", 1) Opt("WinSearchChildren", 1) Global $openWindows[1] Global $child[100] Global $numChildGuis Global $spellEdit Global $first_SpellbookComboEvent = 0 ;----------Parent Window Dimensions---------- Local $parentWidth = 1000 Local $parentHeight = 600 Local $parentLeft = -1 Local $parentTop = -1 ;----------Tool Bar Dimensions--------------- Local $toolBarWidth = $parentWidth Local $toolBarHeight = 30 Local $toolBarLeft = 0 Local $toolBarTop = 0 ;----------Main Window Dimensions------------ Local $mainWidth = $parentWidth Local $mainHeight = $parentHeight - 50 Local $mainLeft = 0 Local $mainTop = $toolBarHeight ;-------------------------Gui Creation-------------------------------------------- ;Create the "parent" container window $parentGui = GUICreate("Spell Inventory", $parentWidth, $parentHeight, $parentLeft, $parentTop, $WS_OVERLAPPEDWINDOW) $openWindows[0] = "Spell Inventory" ;Create Events for $parentGui GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") GUISetOnEvent($GUI_EVENT_RESIZED, "_UpdateChildGui") GUISetOnEvent($GUI_EVENT_MAXIMIZE, "_UpdateChildGui") GUISetOnEvent($GUI_EVENT_RESTORE, "_UpdateChildGui") ;Create the Menu bar ;-----File Menu----- Global $fileMenu = GUICtrlCreateMenu("File") Global $importMI = GUICtrlCreateMenuItem("Import File", $fileMenu) Global $separator = GUICtrlCreateMenuItem("", $fileMenu) Global $ppOptionsMenu = GUICtrlCreateMenu("Print Preview Options", $fileMenu) Global $separator = GUICtrlCreateMenuItem("", $fileMenu) Global $exitMI = GUICtrlCreateMenuItem("Exit", $fileMenu) ;-----Tools Menu----- Global $toolsMenu = GUICtrlCreateMenu("Tools") Global $manageSpellbooksMI = GUICtrlCreateMenuItem("Manage Spellbooks", $toolsMenu) Global $manageSchoolsMI = GUICtrlCreateMenuItem("Manage Schools", $toolsMenu) Global $manageSpellsMI = GUICtrlCreateMenuItem("Manage Spells", $toolsMenu) Global $separator = GUICtrlCreateMenuItem("", $toolsMenu) Global $manageScrollsMI = GUICtrlCreateMenuItem("Manage Scrolls", $toolsMenu) Global $separator = GUICtrlCreateMenuItem("", $toolsMenu) Global $searchMI = GUICtrlCreateMenuItem("Search", $toolsMenu) ;-----Window Menu----- Global $windowMenu = GUICtrlCreateMenu("Window") Global $tileMI = GUICtrlCreateMenuItem("Tile", $windowMenu) Global $separator = GUICtrlCreateMenuItem("", $windowMenu) Global $cascadeMI = GUICtrlCreateMenuItem("Cascade", $windowMenu) ;-----About Menu----- Global $aboutMenu = GUICtrlCreateMenu("About") Global $helpTopicsMI = GUICtrlCreateMenuItem("Help Topics", $aboutMenu) Global $separator = GUICtrlCreateMenuItem("", $aboutMenu) Global $aboutMI = GUICtrlCreateMenuItem("About SI", $aboutMenu) _CreateToolbar() $mainGui = GUICreate("mainGui", $mainWidth, $mainHeight, 0, 30, $WS_CHILD, Default, $parentGui) GUISetBkColor(0x888888) GUISetState() GUISetState(@SW_SHOW, $parentGui) If $numChildGuis < 100 Then $child[$numChildGuis] = GUICreate(" Spellbook", 600, 420, 100 + $numChildGuis * 5, 0 + $numChildGuis * 5, $WS_OVERLAPPEDWINDOW, Default, $mainGui) DllCall("user32.dll", "int", "SetParent", "hwnd", WinGetHandle($child[$numChildGuis]), "hwnd", WinGetHandle($mainGui)) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") ;;GUISetOnEvent($GUI_EVENT_DROPPED, "Drop") $numChildGuis = $numChildGuis + 1 EndIf GUISetState() ;--------------------add to stop moving child Const $SC_MOVE = 0xF010 GUIRegisterMsg($WM_SYSCOMMAND, "On_WM_SYSCOMMAND") ;-------------------------Main Loop-------------------------------------------- While 1 Sleep(10) WEnd ;-------------------------Functions-------------------------------------------- Func _Exit() If @GUI_WinHandle = $parentGui Then Exit ElseIf @GUI_WinHandle = WinGetHandle($child[$numChildGuis]) Then GUISwitch(WinGetHandle($child[$numChildGuis])) _ArrayDelete($openWindows, _ArraySearch($openWindows, WinGetTitle($child[$numChildGuis]))) GUIDelete() WinActivate("Spell Inventory") EndIf EndFunc ;==>_Exit Func _UpdateChildGui() Local $state, $array GUISetState(@SW_LOCK, $child[1]) $array = WinGetPos($parentGui) WinMove($mainGui, '', 0, 30, ($array[2] - 8), ($array[3] - 84)) ConsoleWrite("--" & $child[0] & @CR) If $child[0] <> 0 Then For $i = 0 To $numChildGuis - 1 Step 1 ConsoleWrite("----" & $i & @CR) $state = WinGetState($child[$i]) If BitAND($state, 32) Then WinMove($child[$i], '', -4, -4, $array[2], ($array[3] - 76)) EndIf Next EndIf EndFunc ;==>_UpdateChildGui Func _CreateToolbar() ;~ Local $spellBooksArray = _GetSpellBookList() Local $toolbar = GUICreate("toolbar", $toolBarWidth, $toolBarHeight, $toolBarLeft, $toolBarTop, $WS_CHILD, Default, $parentGui) $spellBooksCombo = GUICtrlCreateCombo("", 5, 5, 120, 20, $CBS_DROPDOWN) ;GUICtrlSetOnEvent(-1, "_SpellbookComboEvent") GUICtrlSetData(-1, "Select Spellbook", "Select Spellbook") _GUICtrlComboBox_DeleteString($spellBooksCombo, 0) ;~ For $SB = 1 to $spellBooksArray[0] Step 1 ;~ GUICtrlSetData($spellBooksCombo, $spellBooksArray[$SB]) ;~ Next ;~ Global $viewSpell = GUICtrlCreateButton ("Spell", 120,0,50,20) ;~ GUICtrlSetOnEvent(-1, "_Create_VeiwSpell_Window") ;Global $testLabel = GUICtrlCreateLabel("khlskj", 170, 0, 100, 20) ;GUICtrlSetData(-1, GUICtrlRead($spellBooksCombo)) GUISetState() EndFunc ;==>_CreateToolbar Func On_WM_SYSCOMMAND($hWnd, $Msg, $wParam, $lParam) If BitAND($wParam, 0xFFF0) = $SC_MOVE Then ;This is the only way I could think of to determine which window is being moved If WinGetHandle(WinGetTitle("","")) = $parentGui Then Return $GUI_RUNDEFMSG Else Return 0 EndIf EndIf Return $GUI_RUNDEFMSG EndFunc ;==>On_WM_SYSCOMMAND Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
momar33 Posted April 18, 2008 Author Share Posted April 18, 2008 Ok, now it doesn't move when it is not maximized. I think i can solve this problem, but i need more information. Could you add some comments to the "On_WM_SYSCOMMAND" function. I am mostly wondering what this line does: If BitAND($wParam, 0xFFF0) = $SC_MOVE Then Thanks Link to comment Share on other sites More sharing options...
momar33 Posted April 18, 2008 Author Share Posted April 18, 2008 After messing around with the code for awhile i have a pretty good idea what the function is doing. I have one question though. Why did you use BitAND($wParam, 0xFFF0) instead of BitAND($wParam, 0xF010)? Link to comment Share on other sites More sharing options...
martin Posted April 18, 2008 Share Posted April 18, 2008 After messing around with the code for awhile i have a pretty good idea what the function is doing.I have one question though.Why did you use BitAND($wParam, 0xFFF0) instead of BitAND($wParam, 0xF010)?From MSDN info on WM_SYSCOMMANDIn WM_SYSCOMMAND messages, the four low-order bits of the wParam parameter are used internally by the system. To obtain the correct result when testing the value of wParam, an application must combine the value 0xFFF0 with the wParam value by using the bitwise AND operator. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. 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