TimRude Posted October 17, 2022 Share Posted October 17, 2022 How does one move or resize a ListView control that was created using _GUICtrlListView_Create? This doesn't work: #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <WindowsConstants.au3> ; Create GUI with a _GUICtrlListView control Global $hGUI = GUICreate("_GUICtrlListView", 700, 500, -1, -1, $WS_OVERLAPPEDWINDOW) Global $hListView = _GUICtrlListView_Create($hGUI, "", 100, 100, 500, 300, BitOR($LVS_ICON, $LVS_SINGLESEL, $LVS_SHOWSELALWAYS, $LVS_SORTASCENDING)) GUISetState(@SW_SHOW, $hGUI) MsgBox(0, "Note intial ListView position (centered on the GUI)", "Press OK to try to move ListView to bottom right corner of the GUI window.") GUICtrlSetPos($hListView, 200, 200) MsgBox(0, "GUICtrlSetPos($hListView, 100, 100)", "Why didn't it move?") GUICtrlSetPos($hListView, 100, 100, 600, 400) MsgBox(0, "GUICtrlSetPos($hListView, 100, 100, 600, 400)", "We can't change the size either.") ; Loop until the user exits the GUI Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() Link to comment Share on other sites More sharing options...
Solution mikell Posted October 17, 2022 Solution Share Posted October 17, 2022 (edited) GuiCtrlSetPos works using IDs not handles #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <WindowsConstants.au3> ; Create GUI with a _GUICtrlListView control Global $hGUI = GUICreate("_GUICtrlListView", 700, 500, -1, -1, $WS_OVERLAPPEDWINDOW) Global $hListView = _GUICtrlListView_Create($hGUI, "", 100, 100, 500, 300, BitOR($LVS_ICON, $LVS_SINGLESEL, $LVS_SHOWSELALWAYS, $LVS_SORTASCENDING)) GUISetState(@SW_SHOW, $hGUI) MsgBox(0, "Note intial ListView position (centered on the GUI)", "Press OK to try to move ListView to bottom right corner of the GUI window.") WinMove($hListView, "", 200, 200) ; or ControlMove($hListView, "", "", 200, 200) Sleep(1000) WinMove($hListView, "", 100, 100, 600, 400) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() Edited October 17, 2022 by mikell typo TimRude 1 Link to comment Share on other sites More sharing options...
TimRude Posted October 18, 2022 Author Share Posted October 18, 2022 @mikell Thanks! I tried both WinMove and ControlMove as you suggested and both worked perfectly well to move and/or resize the listview. Obviously I overlooked the important difference between a Control ID and a Handle, and that the built-in GUICtrlCreateListView function returns the identifier (controlID) of the new control, whereas the _GUICtrlListView_Create returns the handle to the ListView control. That's a distinction I will pay very careful attention to from now on. And logically that would mean then that any UDF-based controls like this are incompatible with the GUI Control update functions. Thanks for the education. 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