zbatev Posted August 1, 2011 Posted August 1, 2011 Hi AutoIT GUI masters! I was wondering if you could help me out on a little challenge that I have... I want to use a ListView that has a possible listing(items) between 0 to 30. But I wanted the form and the control to auto-adjust it's height according to the number of items in the ListView control.
somdcomputerguy Posted August 1, 2011 Posted August 1, 2011 Maybe this UDF, by Melba23, can help - GUIListViewEx. I don't know if this UDF has the ability to do any 'autosizing', so it's up to you to read up on it! Good luck! - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change.
zbatev Posted August 1, 2011 Author Posted August 1, 2011 Maybe this UDF, by Melba23, can help - GUIListViewEx. I don't know if this UDF has the ability to do any 'autosizing', so it's up to you to read up on it! Good luck!That is a very good ListView UDF however it doesn't have what I was looking for...Hmmmmm...
BrewManNH Posted August 1, 2011 Posted August 1, 2011 Look at GuiCtrlSetPos in the help file, you can use it by adjusting the Height parameter to however many items are in your listview, while keeping the other parameters the same as when you created it. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
monoscout999 Posted August 1, 2011 Posted August 1, 2011 You can think many ways to do that, this is one of them. expandcollapse popup#include <GuiListView.au3> Opt("GUIResizeMode",545) ; $GUI_DOCKTOP + $GUI_DOCKHEIGHT global $n = 0 global $items[1] $hGui = GuiCreate("AutoSize my monoscout999",-1,199) $iButton1 = GuiCtrlCreateButton("Add Item", 260,20,120,50) $iButton2 = GuiCtrlCreateButton("Delete Item", 260,100,120,50) $iList = GuiCtrlCreateListView("Nª|Listview test|blabla",0,0,250,200) $hList = GuiCtrlGetHandle($iList) GuiSetState() While True $msg = GuiGetMsg() Switch $msg case -3 Exit case $iButton1 $n += 1 redim $items[$n] $items[$n-1] = GUICtrlCreateListViewItem($n&"|Some text|more text", $iList) $Height = _GUICtrlListView_ApproximateViewHeight($hList) $pos = wingetpos($hGui) If $pos[3]-27 < $Height Then winmove($hGui,"", $pos[0],$pos[1],$pos[2],$Height+30) GUICtrlSetPos($iList,0,0,250,$Height+30) EndIf case $iButton2 If $n > 0 then GuiCtrldelete($items[$n-1]) $n -= 1 $Height = _GUICtrlListView_ApproximateViewHeight($hList) $pos = wingetpos($hGui) If $pos[3]-27 > $Height and $pos[3]-27 > 200 Then winmove($hGui,"", $pos[0],$pos[1],$pos[2],$Height+30) GUICtrlSetPos($iList,0,0,250,$Height+30) EndIf EndIf EndSwitch WEnd
zbatev Posted August 1, 2011 Author Posted August 1, 2011 You can think many ways to do that, this is one of them. expandcollapse popup#include <GuiListView.au3> Opt("GUIResizeMode",545) ; $GUI_DOCKTOP + $GUI_DOCKHEIGHT global $n = 0 global $items[1] $hGui = GuiCreate("AutoSize my monoscout999",-1,199) $iButton1 = GuiCtrlCreateButton("Add Item", 260,20,120,50) $iButton2 = GuiCtrlCreateButton("Delete Item", 260,100,120,50) $iList = GuiCtrlCreateListView("Nª|Listview test|blabla",0,0,250,200) $hList = GuiCtrlGetHandle($iList) GuiSetState() While True $msg = GuiGetMsg() Switch $msg case -3 Exit case $iButton1 $n += 1 redim $items[$n] $items[$n-1] = GUICtrlCreateListViewItem($n&"|Some text|more text", $iList) $Height = _GUICtrlListView_ApproximateViewHeight($hList) $pos = wingetpos($hGui) If $pos[3]-27 < $Height Then winmove($hGui,"", $pos[0],$pos[1],$pos[2],$Height+30) GUICtrlSetPos($iList,0,0,250,$Height+30) EndIf case $iButton2 If $n > 0 then GuiCtrldelete($items[$n-1]) $n -= 1 $Height = _GUICtrlListView_ApproximateViewHeight($hList) $pos = wingetpos($hGui) If $pos[3]-27 > $Height and $pos[3]-27 > 200 Then winmove($hGui,"", $pos[0],$pos[1],$pos[2],$Height+30) GUICtrlSetPos($iList,0,0,250,$Height+30) EndIf EndIf EndSwitch WEnd As always monoscout999, nice and brilliant code! This is exactly what i need. Thank you!
Zedna Posted August 1, 2011 Posted August 1, 2011 GUICtrlSetPos() is not needed if you use GUICtrlSetResizing() for ListView control. In this case only WinMove() will do the job for you. Resources UDF ResourcesEx UDF AutoIt Forum Search
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