Sign in to follow this  
Followers 0
Anas

ListView in a Tab

5 posts in this topic

Hi,

I've a problem and a few questions about list view.

When I expand/collapse a group that causes the list view to add/remove a scrolling bar, the list view contents disappears and minimizing/restoring the window fix it.

- How can I fix the list view content disappearing without removing $LVS_EX_FULLROWSELECT.

 

Also, How can I:
- expand a collapsed group without applying $LVGS_NORMAL and $LVGS_COLLAPSIBLE separately (without calling  _GUICtrlListView_SetGroupInfo twice)
- remove the empty space at the end of the list view when scrolled to the end.
- place the groups expand arrow on the left side.

 

Thanks.

#include <GuiListView.au3>
#include <GUIConstants.au3>

Example()

Func Example()
    GUICreate("ListView in a Tab", 400, 250)
    GUICtrlCreateTab(1, 1, 400, 200)
    GUICtrlCreateTabItem('Tab')
    $LV = GUICtrlCreateListView("Column", 15, 35, 370, 150)
    ;$LV = GUICtrlCreateListView("Column", 15, 35, 370, 150, Default, $WS_EX_CLIENTEDGE) ;Works, $LVS_EX_FULLROWSELECT removed.
    $BT1 = GUICtrlCreateButton("Expand 1", 50, 210, 100, 30)
    $BT2 = GUICtrlCreateButton("Expand 2", 250, 210, 100, 30)
    GUISetState()

    _GUICtrlListView_EnableGroupView($LV)
    _GUICtrlListView_InsertGroup($LV, -1, 1, "")
    _GUICtrlListView_SetGroupInfo($LV, 1, "Group", 1, BitOR($LVGS_COLLAPSED, $LVGS_COLLAPSIBLE))
    For $i = 1 To 10
        GUICtrlCreateListViewItem("Item " & $i, $LV)
        ;_GUICtrlListView_AddItem($LV, "Item " & $i) ;Same problem
        _GUICtrlListView_SetItemGroupID($LV, $i-1, 1)
    Next

    While 1
        $msg = GUIGetMsg()
        Switch $msg
            Case $BT1
                _GUICtrlListView_SetGroupInfo($LV, 1, "Group", 1, BitOR($LVGS_NORMAL, $LVGS_COLLAPSIBLE))
            Case $BT2
                _GUICtrlListView_SetGroupInfo($LV, 1, "Group", 1, $LVGS_NORMAL)
                _GUICtrlListView_SetGroupInfo($LV, 1, "Group", 1, $LVGS_COLLAPSIBLE)
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd
    GUIDelete()
EndFunc

 

Share this post


Link to post
Share on other sites



I can live without the rest, but this is a breaking problem

On 2/29/2016 at 1:13 PM, Anas said:

When I expand/collapse a group that causes the list view to add/remove a scrolling bar, the list view contents disappears and minimizing/restoring the window fix it.

- How can I fix the list view content disappearing without removing $LVS_EX_FULLROWSELECT.

Any idea how to overcome this?

Share this post


Link to post
Share on other sites

This is an issue with the tab control. Create a child window on top of the tab, and create the listview in the child window:

#include <GuiListView.au3>
#include <GUIConstants.au3>

Example()

Func Example()
  $hGui = GUICreate("ListView in a Tab", 500, 400)

  GUICtrlCreateTab(1, 1, 500, 300)
  GUICtrlCreateTabItem('Tab')
  GUICtrlCreateTabItem("") ; end tabitem definition
  GUISetState()

  $hChild = GUICreate( "", 400, 250, 20, 30, $WS_POPUP, $WS_EX_MDICHILD, $hGui )
  $LV = GUICtrlCreateListView("Column", 15, 35, 370, 150)
  $BT1 = GUICtrlCreateButton("Expand", 50, 210, 100, 30)
  $BT2 = GUICtrlCreateButton("Collapse", 250, 210, 100, 30)
  GUISetBkColor( 0xFFFFFF )
  GUISetState()

  _GUICtrlListView_EnableGroupView($LV)
  _GUICtrlListView_InsertGroup($LV, -1, 1, "")
  _GUICtrlListView_SetGroupInfo($LV, 1, "Group", 1, $LVGS_COLLAPSED)
  _GUICtrlListView_SetGroupInfo($LV, 1, "Group", 1, $LVGS_COLLAPSIBLE)

  For $i = 1 To 10
    ;GUICtrlCreateListViewItem("Item " & $i, $LV)
    _GUICtrlListView_AddItem($LV, "Item " & $i) ;Same problem
    _GUICtrlListView_SetItemGroupID($LV, $i-1, 1)
  Next

  While 1
    $msg = GUIGetMsg()
    Switch $msg
      Case $BT1
        _GUICtrlListView_SetGroupInfo($LV, 1, "Group", 1, $LVGS_NORMAL)
        _GUICtrlListView_SetGroupInfo($LV, 1, "Group", 1, $LVGS_COLLAPSIBLE)
      Case $BT2
        _GUICtrlListView_SetGroupInfo($LV, 1, "Group", 1, $LVGS_COLLAPSED)
        _GUICtrlListView_SetGroupInfo($LV, 1, "Group", 1, $LVGS_COLLAPSIBLE)
      Case $GUI_EVENT_CLOSE
        ExitLoop
    EndSwitch
  WEnd
  GUIDelete()
EndFunc

 

Both AutoIt and MicroSoft documentation states that the $LVGS-flags must be applied one by one.

Empty space. This seems more to be an issue related to the scrollbar, than to the listview. If you press the End key to go to last row there is no empty space. It seems as if the height of the group header is added to the max value of the scroll bar. But I don't think you can just decrease the max value of the scroll bar. If the listview contains 10 groups which are all collapsed, the scroll bar must still be able to scroll to the last group. Search the internet. If you can find a solution implemented in another language, we can also implement it in AutoIt.

Expand arrow on the left side. I don't think we have an AutoIt solution. If you can find information about the issue or maybe even an implementation, we can also implement it in AutoIt.

If you are interested, you can take a look at this thread to see how to catch expand/collapse events from the group.

Share this post


Link to post
Share on other sites

Well, I already have a child GUI ... 7 of them actually (for nesting Tabs), this is going to be a mess, but if it's going to fix it...

I'll search for the rest and see if I find anything.

 

Thanks LarsJ.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Similar Content

    • mLipok
      By mLipok
      I was not lucky to find the right function so I created it by my self:
      _GUICtrlListView_GetColumnID_ByName()
      Example:
       
      #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <MsgBoxConstants.au3> Example() Func Example() GUICreate("ListView Get Column ID", 400, 300) Local $idListview = GUICtrlCreateListView("Alfa|Beta|Gama", 2, 2, 394, 268) GUISetState(@SW_SHOW) _GUICtrlListView_SetColumnOrder($idListview, "2|0|1") MsgBox($MB_SYSTEMMODAL, "Information", "Column ID: " & _GUICtrlListView_GetColumnID_ByName($idListview, 'Gama')) ; Loop until the user exits. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>Example Func _GUICtrlListView_GetColumnID_ByName($hListView, $sColumnToFind) Local $iColumn_Count = _GUICtrlListView_GetColumnCount($hListView) Local $aColumns For $iColumn_idx = 0 To $iColumn_Count - 1 $aColumns = _GUICtrlListView_GetColumn($hListView, $iColumn_idx) If $aColumns[5] = $sColumnToFind Then Return $iColumn_idx EndIf Next Return SetError(1, 0, -1) EndFunc ;==>_GUICtrlListView_GetColumnID_ByName  
    • UEZ
      By UEZ
      Here a small tool I wrote to update my Sysinternal tools collection without the need to download always the whole package or visiting the site to check for updates. I know that there are several tools available (also some tools written in AutoIt) but here another one for the collection. It was good exercise for me to code it.
       
       
        
       
       
      Some files from cannot be downloaded although they are visible on the web site!
       
      Here the download link of the source code only: AutoIt Sysinternal Tools Synchronizer v0.99.1 build 2017-10-23 beta.7z  (1353 downloads previously)
      -=> Requires AutoIt version 3.3.13.20 or higher / tested on Win8.1 real machine and some VMs: Win7 / Vista / Win10
       
      Compiled exe only: @MediaFire
       
      Just select the Sysinternal Tools folder or create one and press the synchronize button to download the selected items. Click on AutoIt label (near to left upper corner) to open menu.
       
      Special thanks to LarsJ, Melba23 and mesale0077 for their help. 
       
      I've still some ideas to implement which are more gimmick related, so it is not finished yet...
      If you want to add your language please check out #Region Language. Thanks. 
       
      Please report any bug or if you have any suggestions.
       
      The language of the tool tip from each of the executable in the left list view were automatically created using Google translator and weren't checked for correctness.
       
      Br,
      UEZ
    • 0Ethan0
      By 0Ethan0
      Ahoy Autoit Community!
      After many trials and errors I am unable to solve a problem I am facing and would appreciate any kind of input or better yet a solution 
      The Premise: An embeded slideshow viewer that runs after double-clicking an item in a ListView (each item will generate a different slideshow images).
      The Setup: GUI with a ListView Control and a simple exit button.
      The Issue: Once double clicked the slide plays however the GUI "locks"/non responsive until the slide is over. Same thing if I click on the "Test" button.
      The Culprit: I believe since it's in the images loop it can't accept any other commands until that loop is over.
      The Wish: I want to be able to use the GUI functions (selecting other items, clicking on button etc.) while the slideshow plays.
      The Code (stripped and simplified as much as I could):
      #include <GuiListView.au3> #include <File.au3> #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt("GUIOnEventMode", 1) HotKeySet("{Esc}", "_Exit") Global $c=0 Global $ssGDI[3], $ssGraphic[2], $ssImage Global Const $bg_color = "000000" Global Const $ssW = 480, $ssH = 320 Global $aFiles = _FileListToArrayRec("d:\testStage\", "*.jpg;*.png;*.bmp;*.gif;*.JPG;*.PNG;*.BMP;*.GIF", $FLTAR_FILES, $FLTAR_NORECUR ,$FLTAR_SORT ,$FLTAR_FULLPATH ) $guiW = 1200 $guiH = 726 $mainWindow = GUICreate("Slideshow Viewer", $guiW, $guiH, -1, -1, $WS_POPUP) $Button1 = GUICtrlCreateButton("Exit", 0, 0, 50, 50) GUICtrlSetOnEvent($Button1, "_Exit") $Button1 = GUICtrlCreateButton("Test", 60, 0, 50, 50) GUICtrlSetOnEvent($Button1, "Test") Global $ListView = GUICtrlCreateListView("Entry Name|Category", 5, 75, 195, 280) _GUICtrlListView_SetColumnWidth ($ListView, 0, 100) _GUICtrlListView_SetColumnWidth ($ListView, 1, 100) GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES) GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT) GUICtrlCreateListViewItem("Name 1|Category 1", $ListView) GUICtrlCreateListViewItem("Name 2|Category 2", $ListView) screenshotWidgetInit($ssW,$ssH, 690, 100) GUISetState(@SW_SHOW, $mainWindow) GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE _Exit() EndSwitch WEnd Func Test() For $k = 1 To UBound($aFiles) - 1 screenshotWidgetTransition($aFiles[$k]) Next EndFunc Func ListView_Click() ConsoleWrite("Left Click") EndFunc Func ListView_DoubleClick() ConsoleWrite("Double Left Click") Test() EndFunc Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam) #forceref $hWndGUI, $MsgID, $wParam Local $tagNMHDR, $event, $hwndFrom, $code $tagNMHDR = DllStructCreate("int;int;int", $lParam) If @error Then Return $event = DllStructGetData($tagNMHDR, 3) Select Case $wParam = $ListView Select Case $event = $NM_CLICK ListView_Click () Case $event = $NM_DBLCLK ListView_DoubleClick () EndSelect EndSelect Return $GUI_RUNDEFMSG EndFunc Func screenshotWidgetTransition($image, $delay = 0, $speed = 1, $sleep = 2000) Local $a, $d = $c, $iX, $iY $ssImage = _GDIPlus_ImageLoadFromFile($image) $iX = _GDIPlus_ImageGetWidth($ssImage) $iY = _GDIPlus_ImageGetHeight($ssImage) $FDesktop=$ssH/$ssW $Fact =1 If $iX > $ssW And $FDesktop > ($iY/$iX) Then $Fact=$ssW/$iX ElseIf $iY > $ssH Then $Fact=$ssH/$iY EndIf $H1 = Round(($Fact * $iY),0) $W1 = Round(($Fact * $iX),0) _GDIPlus_GraphicsDrawImageRect($ssGraphic[$d], $ssImage,($ssW - $W1)/2, ($ssH - $H1) / 2,$W1,$H1) WinSetTrans($ssGDI[$d], "", 0) WinSetOnTop($ssGDI[$d], "", 1) For $a = 0 To 254 Step $speed WinSetTrans($ssGDI[$d], "", $a) Sleep($delay) Next WinSetTrans($ssGDI[$d], "", 254) WinSetOnTop($ssGDI[Not ($d)], "", 0) WinSetTrans($ssGDI[Not ($d)], "", 0) _GDIPlus_GraphicsClear($ssGraphic[Not ($d)]) $c = 1 - $d _GDIPlus_ImageDispose ($ssImage) ; very important to realease the pics Sleep($sleep) EndFunc ;==>screenshotWidgetTransition Func screenshotWidgetInit($ssW,$ssH,$ssX,$ssY) $ssGDI[2] = GUICreate("", $ssW, $ssH, $ssX, $ssY, $WS_POPUP, $WS_EX_MDICHILD, $mainWindow) $ssGDI[0] = GUICreate("", $ssW, $ssH, 3, 3, $WS_POPUP, $WS_EX_MDICHILD, $ssGDI[2]) $ssGDI[1] = GUICreate("", $ssW, $ssH, 3, 3, $WS_POPUP, $WS_EX_MDICHILD, $ssGDI[2]) ; GUISetBkColor("0x" & $bg_color, $ssGDI[2]) GUISetState(@SW_SHOW, $ssGDI[2]) GUISetState(@SW_SHOW, $ssGDI[0]) GUISetState(@SW_SHOW, $ssGDI[1]) WinSetTrans($ssGDI[0], "", 0) WinSetTrans($ssGDI[1], "", 0) _GDIPlus_Startup() $ssGraphic[0] = _GDIPlus_GraphicsCreateFromHWND($ssGDI[0]) $ssGraphic[1] = _GDIPlus_GraphicsCreateFromHWND($ssGDI[1]) _GDIPlus_GraphicsClear($ssGraphic[0], "0xFF" & $bg_color) _GDIPlus_GraphicsClear($ssGraphic[1], "0xFF" & $bg_color) EndFunc ;==>screenshotWidgetInit Func _Exit() _GDIPlus_ImageDispose($ssImage) _GDIPlus_GraphicsDispose($ssGraphic[0]) _GDIPlus_GraphicsDispose($ssGraphic[1]) GUIDelete($ssGDI[0]) GUIDelete($ssGDI[1]) GUIDelete($ssGDI[2]) _GDIPlus_Shutdown() Exit EndFunc ;==>_Exit I hope someone can shed light on this; perhaps a different approach is needed?
      Thank you in advance!
      P.S.
      The script is patched from different scripts of different users in the forum - thank you again users!
    • Skeletor
      By Skeletor
      MS Splash Screens
      The office 2016/17 office suite has made many people turn heads with its functions and especially their splash screen.
      I now present to you, the MS Style Splash Screen. For Rookies, Novices and anyone who wants a ready made splash screen for your gui application.

      You can now download it and also try it out yourself.
      You have three colors to choose from:
      Blue
      Red
      Green
      All three colours are from the famous programs.
      I also included the KODA form to you can have freedom with this splash screen.
      Note: the KODA form does not have the three colours as well as the correct blue. 

      Have fun and enjoy.
      Note:
      I will update the splash to add the automated 3 dots animation at a later stage.