HeXetic Posted January 23, 2009 Share Posted January 23, 2009 I have a GUI with a listview created with _GUICtrlListViewCreate, but I need to get it to resize when the window is resized or when the window is maximized. I have tried to use the GUICtrlSetResizing method but that only seems to work with the built in GUI Control Creation. Below is an example of what i'm trying to do: #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> $GUI = GUICreate("Resizing", 500, 200, -1, -1, $WS_OVERLAPPEDWINDOW) $TodoListView = _GUICtrlListView_Create($GUI, "", 10, 20, 480, 160) _GUICtrlListView_SetExtendedListViewStyle($TodoListView, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES)) _GUICtrlListView_InsertColumn($TodoListView, 0, "No", 70) _GUICtrlListView_InsertColumn($TodoListView, 1, "Ref", 70) _GUICtrlListView_InsertColumn($TodoListView, 2, "Item", 270) _GUICtrlListView_InsertColumn($TodoListView, 3, "Status", 70) GUICtrlSetResizing(-1, BitOR($GUI_DOCKHEIGHT, $GUI_DOCKTOP, $GUI_DOCKLEFT, $GUI_DOCKBOTTOM)) GUISetState(@SW_SHOW, $GUI) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Link to comment Share on other sites More sharing options...
KaFu Posted January 23, 2009 Share Posted January 23, 2009 Had the same problem with SMF, GUICtrlSetResizing doesn't work with handles but only with control ids. If you need the handle, determine it with GUICtrlGetHandle(). Otherwise as far as I know anything that can be done with _GUICtrlListView_Create() you can add to GUICtrlCreateListView() with _GUICtrlListView_SetExtendedListViewStyle(). #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> $GUI = GUICreate("Resizing", 500, 200, -1, -1, $WS_OVERLAPPEDWINDOW) $TodoListView = GUICtrlCreateListView("", 10, 20, 480, 160) _GUICtrlListView_SetExtendedListViewStyle($TodoListView, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES)) _GUICtrlListView_InsertColumn($TodoListView, 0, "No", 70) _GUICtrlListView_InsertColumn($TodoListView, 1, "Ref", 70) _GUICtrlListView_InsertColumn($TodoListView, 2, "Item", 270) _GUICtrlListView_InsertColumn($TodoListView, 3, "Status", 70) GUICtrlSetResizing($TodoListView, BitOR($GUI_DOCKHEIGHT, $GUI_DOCKTOP, $GUI_DOCKLEFT, $GUI_DOCKBOTTOM)) GUISetState(@SW_SHOW, $GUI) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Zedna Posted January 23, 2009 Share Posted January 23, 2009 Just note: If you still want to use _GUICtrlListView_Create() then you must use GUIRegisterMsg() and catch WM_SIZE event and do resizing of your ListView control yourself by WinMove(). Search forum for examples using WM_SIZE Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
HeXetic Posted January 23, 2009 Author Share Posted January 23, 2009 Had the same problem with SMF, GUICtrlSetResizing doesn't work with handles but only with control ids. If you need the handle, determine it with GUICtrlGetHandle(). Otherwise as far as I know anything that can be done with _GUICtrlListView_Create() you can add to GUICtrlCreateListView() with _GUICtrlListView_SetExtendedListViewStyle(). #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> $GUI = GUICreate("Resizing", 500, 200, -1, -1, $WS_OVERLAPPEDWINDOW) $TodoListView = GUICtrlCreateListView("", 10, 20, 480, 160) _GUICtrlListView_SetExtendedListViewStyle($TodoListView, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES)) _GUICtrlListView_InsertColumn($TodoListView, 0, "No", 70) _GUICtrlListView_InsertColumn($TodoListView, 1, "Ref", 70) _GUICtrlListView_InsertColumn($TodoListView, 2, "Item", 270) _GUICtrlListView_InsertColumn($TodoListView, 3, "Status", 70) GUICtrlSetResizing($TodoListView, BitOR($GUI_DOCKHEIGHT, $GUI_DOCKTOP, $GUI_DOCKLEFT, $GUI_DOCKBOTTOM)) GUISetState(@SW_SHOW, $GUI) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Well that works just fine. I didn't know you could combine GUICtrlCreateListView with the _GUICtrlListView UDF. I have incorporated this method into my program and the data retrieval and editing all still works. Just one last question though. When the window is resized or maximized I need the Item column to resize according. The rest of the columns always need to stay the same size, is this possible to do? Link to comment Share on other sites More sharing options...
Zedna Posted January 23, 2009 Share Posted January 23, 2009 Just one last question though. When the window is resized or maximized I need the Item column to resize according. The rest of the columns always need to stay the same size, is this possible to do?use GUIRegisterMsg() and catch WM_SIZE event Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
KaFu Posted January 23, 2009 Share Posted January 23, 2009 (edited) Like Zedna mentioned there might be a solution for that with WM_SIZE too. Another way might be to create an adlib polling the gui size with WinGetPos() and on change (save size to check string/array) you can use _GUICtrlListView_SetColumnWidth(). Edited January 23, 2009 by KaFu OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
HeXetic Posted January 23, 2009 Author Share Posted January 23, 2009 Hmm OK I will have a look into this as i'm not too familiar with GUIRegisterMsg(), but thats for the help, much appreciated. Link to comment Share on other sites More sharing options...
rasim Posted January 25, 2009 Share Posted January 25, 2009 Hmm OK I will have a look into this as i'm not too familiar with GUIRegisterMsg(), but thats for the help, much appreciated.Example Link to comment Share on other sites More sharing options...
HeXetic Posted January 27, 2009 Author Share Posted January 27, 2009 (edited) ExampleThat was just what I needed, I have it working perfectly now. All I did was add two lines in the WM_SIZE function to delete the existing Item column, and then recreate it with the $iWidth variable minus the size of the other two columns.I'm not sure if this is the most efficient way of doing it, but it definitely works. For anyone that's interested, here is an example.Edit: Found a better way, the old method ended up removing everything in the Item column, it now just resizes the column without deleting it. See below:#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> #include <WinAPI.au3> $Gui = GUICreate("Gui", 500, 500, 100, 100, BitOr($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX)) $List = _GUICtrlListView_Create($Gui, "", 10, 10, 480, 480) _GUICtrlListView_SetExtendedListViewStyle($List, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES)) _GUICtrlListView_InsertColumn($List, 0, "No", 70) _GUICtrlListView_InsertColumn($List, 1, "Item", 310) _GUICtrlListView_InsertColumn($List, 2, "Status", 100) GUIRegisterMsg($WM_SIZE, "WM_SIZE") GUISetState() While 1 $Msg = GUIGetMsg() If $Msg = $GUI_EVENT_CLOSE Then Exit WEnd Func WM_SIZE($hWnd, $Msg, $wParam, $lParam) Local $iWidth = BitAND($lParam, 0xFFFF) Local $iHeight = BitShift($lParam, 16) _WinAPI_MoveWindow($List, 10, 10, $iWidth - 20, $iHeight - 20, True) _GUICtrlListView_SetColumn($List, 2, "Item", $iWidth - 260) Return $GUI_RUNDEFMSG EndFunc Edited January 27, 2009 by HeXetic Link to comment Share on other sites More sharing options...
engjcowi Posted January 13, 2011 Share Posted January 13, 2011 That was just what I needed, I have it working perfectly now. All I did was add two lines in the WM_SIZE function to delete the existing Item column, and then recreate it with the $iWidth variable minus the size of the other two columns. I'm not sure if this is the most efficient way of doing it, but it definitely works. For anyone that's interested, here is an example. Edit: Found a better way, the old method ended up removing everything in the Item column, it now just resizes the column without deleting it. See below: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> #include <WinAPI.au3> $Gui = GUICreate("Gui", 500, 500, 100, 100, BitOr($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX)) $List = _GUICtrlListView_Create($Gui, "", 10, 10, 480, 480) _GUICtrlListView_SetExtendedListViewStyle($List, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES)) _GUICtrlListView_InsertColumn($List, 0, "No", 70) _GUICtrlListView_InsertColumn($List, 1, "Item", 310) _GUICtrlListView_InsertColumn($List, 2, "Status", 100) GUIRegisterMsg($WM_SIZE, "WM_SIZE") GUISetState() While 1 $Msg = GUIGetMsg() If $Msg = $GUI_EVENT_CLOSE Then Exit WEnd Func WM_SIZE($hWnd, $Msg, $wParam, $lParam) Local $iWidth = BitAND($lParam, 0xFFFF) Local $iHeight = BitShift($lParam, 16) _WinAPI_MoveWindow($List, 10, 10, $iWidth - 20, $iHeight - 20, True) _GUICtrlListView_SetColumn($List, 2, "Item", $iWidth - 260) Return $GUI_RUNDEFMSG EndFunc Thanks this just helped me out loads Drunken Frat-Boy Monkey Garbage 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