Sign in to follow this  
Followers 0

How come: Slow ListView when using tabs [SOLVED on page 2]

38 posts in this topic

Posted (edited)

http://www.youtube.com/watch?v=Hz8u6tyB95E

how come performance of the calculation is effected simply by putting all GUI components into a tab ?

Edited by dirty

Share this post


Link to post
Share on other sites



Posted

dirty,

Very interesting video - I would say that you are furgling the splungebucket in line #2348 or thereabouts. :oops:

The solution is to undergrunge the ListView - did you read the Help file carefully? :D

M23

P.S. If you seriously want help - how about posting the script! :rip:

Share this post


Link to post
Share on other sites

Posted (edited)

furgling the splungebucke ? Spellchecker does not correct those words and i have no idea what that means

line #2348 ? There are only 1587 lines

undergrunge the ListView ? what does that mean ? yes i did read it and i didnt find anything that would give me an answer about your undergrunge

as soon as i create the guictrlcreatetab, image is no longer dwarn

and when tabitem is created, searching takes way too long :D

Edited by dirty

Share this post


Link to post
Share on other sites

Posted

Sorry Melba, his reply was funnier than yours LOL :D:oops:

Share this post


Link to post
Share on other sites

Posted

yeah you can AIR guitar all you want, that doesnt solve the problem.

Listview item is created in recursive folder/file search function. If file = .ini then it reads the content and displays it in GUI.

There are paths in content if found INI. If path are correct or incorrect or missing etc, the appropriate icon is assigned to created listviewitem.

Are you saying its too much for autoit to take ?

Here is a function

Func _searchAll($dir)
Local $ArrTargetItems,$n,$TargetItem
If (StringRight($dir, 1) = "\") Then $dir = StringTrimRight($dir, 1)
$ArrTargetItems = _FileListToArray($dir, "*", 0)
If IsArray($ArrTargetItems) Then
  For $n = 1 To $ArrTargetItems[0]
   $TargetItem = $dir & '\' & $ArrTargetItems[$n]
   If StringInStr(FileGetAttrib($TargetItem), "D") Then ;This is a folder
    _searchAll($TargetItem) ;Call recursively
   Else ;This is a file
    If StringRight($TargetItem, 4) = ".ini" Then
	 Local $GetNameFromResult,$GetCountFromResult,$GetNumberFromResult,$GetMFGFromResult
	 Local $GetCategoryFromResult,$GetLocationFromResult,$GetImagePathFromResult,$GetMFDPathFromResult
	 Local $GetCountSheetFromResult,$GetNoteFromResult,$FixStringForNote,$CountTotalStrings,$FixedFileName
	 Local $CountNameCharacters,$CheckFileName,$CheckProjectName
	 $GetNameFromResult = IniRead($TargetItem, "Project", "Name", "")
	 $GetCountFromResult = IniRead($TargetItem, "Project", "Count", "")
	 $GetNumberFromResult = IniRead($TargetItem, "Project", "Number", "")
	 $GetMFGFromResult = IniRead($TargetItem, "Project", "MFG", "")
	 $GetCategoryFromResult = IniRead($TargetItem, "Project", "Category", "")
	 $GetLocationFromResult = IniRead($TargetItem, "Project", "Location", "")
	 $GetImagePathFromResult = IniRead($TargetItem, "Project", "ImagePath", "")
	 ;If $GetImagePathFromResult > "" And FileExists ($GetImagePathFromResult) = 0 Then
	 $GetMFDPathFromResult = IniRead($TargetItem, "Project", "MFDPath", "")
	 ;If $GetMFDPathFromResult > "" And FileExists ($GetMFDPathFromResult) = 0 Then
	 $GetCountSheetFromResult = IniRead($TargetItem, "Project", "CountSheet", "")
	 ;If $GetCountSheetFromResult > "" And FileExists ($GetCountSheetFromResult) = 0 Then
	 $GetNoteFromResult = IniRead($TargetItem, "Project", "Note", "")
	 $FixStringForNote = StringReplace($GetNoteFromResult, "|", @CRLF)
	 $CountTotalStrings = StringInStr($TargetItem, "\", "", -1) ;# of characters before filename
	 $FixedFileName = StringTrimLeft($TargetItem, $CountTotalStrings) ;Filename.ini
	 $CountNameCharacters = StringLen($FixedFileName) ;How many characters in above filename.ini
	 $CheckFileName = StringTrimRight($FixedFileName, 4) ;Filename
	 $CheckProjectName = IniRead($TargetItem, "Project", "Name", "") ;ProjectName
	 If $CheckFileName <> $CheckProjectName Then ; project file and project name no match
	  Local $ErroFound,$NameInFile,$DefaultName,$SaveChanges
	  $ErroFound = GUICreate("Fix Project Error", 220, 240, Default, Default, Default, Default, $MainGUI)
	  GUICtrlCreateLabel('"' & $CheckFileName & '"' & @CRLF & 'This Project Filename does not match to Name found in Project file. Please change Filename or Project name and click "Change Now"', 5, 5, 210, 100)
	  GUICtrlCreateGroup("This is File Name", 5, 105, 210, 40)
	  $NameInFile = GUICtrlCreateInput($CheckFileName, 10, 120, 200, 20) ;File Name Input
	  GUICtrlCreateGroup("This is project Name", 5, 150, 210, 40)
	  $DefaultName = GUICtrlCreateInput($CheckProjectName, 10, 165, 200, 20) ;Project Name Imput
	  $SaveChanges = GUICtrlCreateButton("Change Now", 10, 200, 200)
	  GUISetState(@SW_SHOW, $ErroFound)
	  While 1
	   Local $Getmsg
	   $Getmsg = GUIGetMsg()
	   If $Getmsg = $GUI_EVENT_CLOSE Then
	    GUIDelete($ErroFound) ;delete created GUI
	    ExitLoop
	   EndIf
	   If $Getmsg = $SaveChanges Then
	    Local $NewFileName,$NewName
	    $NewFileName = GUICtrlRead($NameInFile) ;FileName
	    $NewName = GUICtrlRead($DefaultName) ;ProjectName
	    ;MsgBox(0,'',StringReplace ($TargetItem,$FinalCategory,$NewCategory)) ;show where file wil be moved.
	    IniWrite($TargetItem, "Project", "Name", $NewName)
	    FileMove($TargetItem, StringReplace($TargetItem, $CheckFileName, $NewFileName), 1)
	    GUIDelete($ErroFound) ;delete created GUI
	    ExitLoop
	   EndIf
	  WEnd
	 EndIf
	 Local $Iconname,$PictureExist,$CountSheetExist
	 $Iconname = "Warning.ico"
	 $PictureExist = FileExists($GetImagePathFromResult)
	 $CountSheetExist = FileExists($GetCountSheetFromResult)
	 If $GetImagePathFromResult = "" And $GetCountSheetFromResult = "" Then Assign("Iconname", "BothWarning.ico") ;CC and Pic Empty
	 If $GetCountSheetFromResult > "" And $GetImagePathFromResult > "" And $PictureExist = 0 And $CountSheetExist = 0 Then Assign("Iconname", "BothWarning.ico") ;CC Error and Pic Error
	 If $GetCountSheetFromResult > "" And $GetImagePathFromResult > "" And $PictureExist = 1 And $CountSheetExist = 1 Then Assign("Iconname", "BothGood.ico") ;CC and Pic OK
	 If $GetCountSheetFromResult > "" And $GetImagePathFromResult > "" And $PictureExist = 0 And $CountSheetExist = 0 Then Assign("Iconname", "BothBad.ico") ;CC and Pic Error
	 If $GetCountSheetFromResult > "" And $GetImagePathFromResult > "" And $PictureExist = 0 And $CountSheetExist = 1 Then Assign("Iconname", "PictureError.ico") ;CC OK and Pic Error
	 If $GetCountSheetFromResult > "" And $GetImagePathFromResult > "" And $PictureExist = 1 And $CountSheetExist = 0 Then Assign("Iconname", "FileError.ico") ;CC Error and Pic OK
	 If $GetCountSheetFromResult = "" And $GetImagePathFromResult > "" And $PictureExist = 1 Then Assign("Iconname", "PictureOK.ico") ;CC empty Pic OK
	 If $GetCountSheetFromResult = "" And $GetImagePathFromResult > "" And $PictureExist = 0 Then Assign("Iconname", "PictureError.ico") ;CC empty Pic Error
	 If $GetCountSheetFromResult > "" And $GetImagePathFromResult = "" And $CountSheetExist = 1 Then Assign("Iconname", "NoPicture.ico") ;CC OK Pic empty
	 If $GetCountSheetFromResult > "" And $GetImagePathFromResult = "" And $CountSheetExist = 0 Then Assign("Iconname", "FileError.ico") ;CC Error Pic Empty
	 GUICtrlCreateListViewItem($GetNameFromResult & "|" & $GetCountFromResult & "|" & $GetNumberFromResult & "|" & $GetMFGFromResult & "|" & $GetCategoryFromResult & "|" & $GetLocationFromResult & "|" & $GetImagePathFromResult & "|" & $GetMFDPathFromResult & "|" & $GetCountSheetFromResult & "|" & $FixStringForNote, $Results)
	 GUICtrlSetImage(-1, @TempDir & "\" & $Iconname, '', 2) ;Because above has no variable, -1 means previously created control.
	 Assign("Number", $Number + 1)
    EndIf
   EndIf
  Next
  GUICtrlSetData($FoundCount, $Number)
EndIf
EndFunc   ;==>_searchAll

Am not sure what part of this code causes the issue

Share this post


Link to post
Share on other sites

Posted

wraithdu,

Ah, but mine was intentional! :rip:

dirty,

I have no idea why your function does different things within a tab - my earlier reply was an attempt to get you to post some code so we could attempt to solve your problem. Just looking at a video gives us no clues at all - as I hope you can appreciate. :oops:

Unfortunately I am still no wiser looking at your single function. Perhaps if you posted the whole script so we can see how it fits together? :D

M23

Share this post


Link to post
Share on other sites

Posted (edited)

this is all that gets involved

$Results = GUICtrlCreateListView("Name|Qty|#|MFG|Category|Loc|Pic|MFDPath|CountSheet|Note", 505, 20, 480, 325,$LVS_SINGLESEL,$LVS_EX_GRIDLINES)
ColumnSize() ;simply resize before search. Same function is used to resize when search is completed, not every time but when its completed all the way.
Func ColumnSize()
	_GUICtrlListView_SetColumnWidth($Results, 0, 200) ;Name column
	_GUICtrlListView_SetColumnWidth($Results, 1, 35) ;Quantity
	_GUICtrlListView_SetColumnWidth($Results, 2, 65) ;#
	_GUICtrlListView_SetColumnWidth($Results, 3, 80) ;MFG
	_GUICtrlListView_SetColumnWidth($Results, 4, 80) ;Category
	_GUICtrlListView_SetColumnWidth($Results, 5, 80) ;Loc
	_GUICtrlListView_SetColumnWidth($Results, 6, 40) ;Pic
	_GUICtrlListView_SetColumnWidth($Results, 7, 40) ;MFD
	_GUICtrlListView_SetColumnWidth($Results, 8, 40) ;Countsheet
	_GUICtrlListView_SetColumnWidth($Results, 9, 300) ;Note
EndFunc   ;==>ColumnSize
_GUICtrlListView_RegisterSortCallBack($Results)
GUISetState(@SW_SHOW, $MainGUI)
While 1 ;Main Loop
Local $GUIGetMsg
$GUIGetMsg = GUIGetMsg()
If $GUIGetMsg = $GUI_EVENT_CLOSE Then ExitLoop
If $GUIGetMsg = $SearchAll Then
  Local $ReadNameInput4Search,$dir,$Loading
  _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($Results)) ;Clear all data in $results
  $ReadNameInput4Search = GUICtrlRead($SearchByName)
  $dir = ($DefaultProjectsFolder) ;where to search at
  $Loading = GUICreate("Seaching", 500, 300, Default, Default, $WS_POPUP, $WS_EX_DLGMODALFRAME, $MainGUI)
  GUISetState(@SW_SHOW, $Loading)
  GUICtrlCreateLabel("S E A R C H I N G" & @CRLF & "P L E A S E  W A I T !", 10, 100, 490, 280, $SS_CENTER)
  GUICtrlSetFont(-1, 12, 800)
  GUISetState(@SW_DISABLE, $MainGUI)
  Assign("Number", "0") ;reset count of found projects to 0 by assigning variable that is changing when each ini is found
  GUICtrlSetData($FoundCount, $Number) ;Set found projects to 0
  _searchAll($dir)
  ColumnSize()
  GUISetState(@SW_ENABLE, $MainGUI)
  GUIDelete($Loading)
EndIf
Wend
Func _searchAll($dir)
Local $ArrTargetItems,$n,$TargetItem
If (StringRight($dir, 1) = "\") Then $dir = StringTrimRight($dir, 1)
$ArrTargetItems = _FileListToArray($dir, "*", 0)
If IsArray($ArrTargetItems) Then
  For $n = 1 To $ArrTargetItems[0]
   $TargetItem = $dir & '\' & $ArrTargetItems[$n]
   If StringInStr(FileGetAttrib($TargetItem), "D") Then ;This is a folder
	_searchAll($TargetItem) ;Call recursively
   Else ;This is a file
	If StringRight($TargetItem, 4) = ".ini" Then
	 Local $GetNameFromResult,$GetCountFromResult,$GetNumberFromResult,$GetMFGFromResult
	 Local $GetCategoryFromResult,$GetLocationFromResult,$GetImagePathFromResult,$GetMFDPathFromResult
	 Local $GetCountSheetFromResult,$GetNoteFromResult,$FixStringForNote,$CountTotalStrings,$FixedFileName
	 Local $CountNameCharacters,$CheckFileName,$CheckProjectName
	 $GetNameFromResult = IniRead($TargetItem, "Project", "Name", "")
	 $GetCountFromResult = IniRead($TargetItem, "Project", "Count", "")
	 $GetNumberFromResult = IniRead($TargetItem, "Project", "Number", "")
	 $GetMFGFromResult = IniRead($TargetItem, "Project", "MFG", "")
	 $GetCategoryFromResult = IniRead($TargetItem, "Project", "Category", "")
	 $GetLocationFromResult = IniRead($TargetItem, "Project", "Location", "")
	 $GetImagePathFromResult = IniRead($TargetItem, "Project", "ImagePath", "")
	 ;If $GetImagePathFromResult > "" And FileExists ($GetImagePathFromResult) = 0 Then
	 $GetMFDPathFromResult = IniRead($TargetItem, "Project", "MFDPath", "")
	 ;If $GetMFDPathFromResult > "" And FileExists ($GetMFDPathFromResult) = 0 Then
	 $GetCountSheetFromResult = IniRead($TargetItem, "Project", "CountSheet", "")
	 ;If $GetCountSheetFromResult > "" And FileExists ($GetCountSheetFromResult) = 0 Then
	 $GetNoteFromResult = IniRead($TargetItem, "Project", "Note", "")
	 $FixStringForNote = StringReplace($GetNoteFromResult, "|", @CRLF)
	 $CountTotalStrings = StringInStr($TargetItem, "\", "", -1) ;# of characters before filename
	 $FixedFileName = StringTrimLeft($TargetItem, $CountTotalStrings) ;Filename.ini
	 $CountNameCharacters = StringLen($FixedFileName) ;How many characters in above filename.ini
	 $CheckFileName = StringTrimRight($FixedFileName, 4) ;Filename
	 $CheckProjectName = IniRead($TargetItem, "Project", "Name", "") ;ProjectName
	 If $CheckFileName <> $CheckProjectName Then ; project file and project name no match
	  Local $ErroFound,$NameInFile,$DefaultName,$SaveChanges
	  $ErroFound = GUICreate("Fix Project Error", 220, 240, Default, Default, Default, Default, $MainGUI)
	  GUICtrlCreateLabel('"' & $CheckFileName & '"' & @CRLF & 'This Project Filename does not match to Name found in Project file. Please change Filename or Project name and click "Change Now"', 5, 5, 210, 100)
	  GUICtrlCreateGroup("This is File Name", 5, 105, 210, 40)
	  $NameInFile = GUICtrlCreateInput($CheckFileName, 10, 120, 200, 20) ;File Name Input
	  GUICtrlCreateGroup("This is project Name", 5, 150, 210, 40)
	  $DefaultName = GUICtrlCreateInput($CheckProjectName, 10, 165, 200, 20) ;Project Name Imput
	  $SaveChanges = GUICtrlCreateButton("Change Now", 10, 200, 200)
	  GUISetState(@SW_SHOW, $ErroFound)
	  While 1
	   Local $Getmsg
	   $Getmsg = GUIGetMsg()
	   If $Getmsg = $GUI_EVENT_CLOSE Then
		GUIDelete($ErroFound) ;delete created GUI
		ExitLoop
	   EndIf
	   If $Getmsg = $SaveChanges Then
		Local $NewFileName,$NewName
		$NewFileName = GUICtrlRead($NameInFile) ;FileName
		$NewName = GUICtrlRead($DefaultName) ;ProjectName
		;MsgBox(0,'',StringReplace ($TargetItem,$FinalCategory,$NewCategory)) ;show where file wil be moved.
		IniWrite($TargetItem, "Project", "Name", $NewName)
		FileMove($TargetItem, StringReplace($TargetItem, $CheckFileName, $NewFileName), 1)
		GUIDelete($ErroFound) ;delete created GUI
		ExitLoop
	   EndIf
	  WEnd
	 EndIf
	 Local $Iconname,$PictureExist,$CountSheetExist
	 $Iconname = "Warning.ico"
	 $PictureExist = FileExists($GetImagePathFromResult)
	 $CountSheetExist = FileExists($GetCountSheetFromResult)
	 If $GetImagePathFromResult = "" And $GetCountSheetFromResult = "" Then Assign("Iconname", "BothWarning.ico") ;CC and Pic Empty
	 If $GetCountSheetFromResult > "" And $GetImagePathFromResult > "" And $PictureExist = 0 And $CountSheetExist = 0 Then Assign("Iconname", "BothWarning.ico") ;CC Error and Pic Error
	 If $GetCountSheetFromResult > "" And $GetImagePathFromResult > "" And $PictureExist = 1 And $CountSheetExist = 1 Then Assign("Iconname", "BothGood.ico") ;CC and Pic OK
	 If $GetCountSheetFromResult > "" And $GetImagePathFromResult > "" And $PictureExist = 0 And $CountSheetExist = 0 Then Assign("Iconname", "BothBad.ico") ;CC and Pic Error
	 If $GetCountSheetFromResult > "" And $GetImagePathFromResult > "" And $PictureExist = 0 And $CountSheetExist = 1 Then Assign("Iconname", "PictureError.ico") ;CC OK and Pic Error
	 If $GetCountSheetFromResult > "" And $GetImagePathFromResult > "" And $PictureExist = 1 And $CountSheetExist = 0 Then Assign("Iconname", "FileError.ico") ;CC Error and Pic OK
	 If $GetCountSheetFromResult = "" And $GetImagePathFromResult > "" And $PictureExist = 1 Then Assign("Iconname", "PictureOK.ico") ;CC empty Pic OK
	 If $GetCountSheetFromResult = "" And $GetImagePathFromResult > "" And $PictureExist = 0 Then Assign("Iconname", "PictureError.ico") ;CC empty Pic Error
	 If $GetCountSheetFromResult > "" And $GetImagePathFromResult = "" And $CountSheetExist = 1 Then Assign("Iconname", "NoPicture.ico") ;CC OK Pic empty
	 If $GetCountSheetFromResult > "" And $GetImagePathFromResult = "" And $CountSheetExist = 0 Then Assign("Iconname", "FileError.ico") ;CC Error Pic Empty
	 GUICtrlCreateListViewItem($GetNameFromResult & "|" & $GetCountFromResult & "|" & $GetNumberFromResult & "|" & $GetMFGFromResult & "|" & $GetCategoryFromResult & "|" & $GetLocationFromResult & "|" & $GetImagePathFromResult & "|" & $GetMFDPathFromResult & "|" & $GetCountSheetFromResult & "|" & $FixStringForNote, $Results)
	 GUICtrlSetImage(-1, @TempDir & "\" & $Iconname, '', 2) ;Because above has no variable, -1 means previously created control.
	 Assign("Number", $Number + 1)
	EndIf
   EndIf
  Next
  GUICtrlSetData($FoundCount, $Number)
EndIf
EndFunc   ;==>_searchAll
Edited by dirty

Share this post


Link to post
Share on other sites

Posted

dirty,

Last chance saloon time! :D

Where is the GUICtrlCreateTabItem line that is causing you so much trouble? If you do not include a working script which might possibly give me a clue as to what is going on in your next post I am out of here. :oops:

M23

Share this post


Link to post
Share on other sites

Posted (edited)

If you don't want to post your script for whatever reason (and judging from the possible size, it's likely WE don't want to see it either), then YOU need to take the time to write the smallest script that exemplifies your problem so people can look at it. We don't read minds, we don't do your legwork. Now I haven't even bothered to look at what you have posted... but I know Melba23 enough that if he says what you have is insufficient, then you need to try harder.

Edited by wraithdu

Share this post


Link to post
Share on other sites

Posted

wraithdu,

it's likely WE don't want to see it either

Speak for yourself! I am sure it will be a fascinating experience and one which I am eagerly anticipating. :D

M23

Share this post


Link to post
Share on other sites

Posted (edited)

#include <GUIConstantsEx.au3>
$WinTitle = "whatever"
$MainGUI = GUICreate($WinTitle, 995, 765, Default, Default)
$TabControl = GUICtrlCreateTab (0,0,995,750)
$Tab = GUICtrlCreateTabItem ("Progect Managment")
$SearchAll = GUICtrlCreateButton("  Display all available projects", 10, 330, 480, 35)
$Results = GUICtrlCreateListView("1_________|2|3", 505, 20, 480, 325)
GUISetState(@SW_SHOW, $MainGUI)
While 1 ;Main Loop
	Local $GUIGetMsg
	$GUIGetMsg = GUIGetMsg()
	If $GUIGetMsg = $GUI_EVENT_CLOSE Then ExitLoop
	If $GUIGetMsg = $SearchAll Then
		for $i = 1 to 1000 Step 1
				GUICtrlCreateListViewItem ("test" & $i,$Results)
		Next
	EndIf
WEnd

This will reproduce the issue

Edited by dirty

Share this post


Link to post
Share on other sites

Posted (edited)

Try this?

#include <GUIConstantsEx.au3>
$WinTitle = "whatever"
$MainGUI = GUICreate($WinTitle, 995, 765, Default, Default)
$TabControl = GUICtrlCreateTab (0,0,995,750)
$Tab = GUICtrlCreateTabItem ("Progect Managment")
GUICtrlCreateTabItem("")
$SearchAll = GUICtrlCreateButton("  Display all available projects", 10, 330, 480, 35)
$Results = GUICtrlCreateListView("1_________|2|3", 505, 20, 480, 325)
GUISetState(@SW_SHOW, $MainGUI)
While 1 ;Main Loop
	Local $GUIGetMsg
	$GUIGetMsg = GUIGetMsg()
	If $GUIGetMsg = $GUI_EVENT_CLOSE Then ExitLoop
	If $GUIGetMsg = $SearchAll Then
		for $i = 1 to 1000 Step 1
				GUICtrlCreateListViewItem ("test" & $i,$Results)
		Next
	EndIf
WEnd

Remarks

For setting more information see GUICtrlUpdate....

To select a specific tabitem to be shown when the dialog box open just issue a GUICtrlSetState(-1,$GUI_SHOW) see example.

To terminate the tab control just create a last "tabitem" control with a null text "". The "tabitem" control cannot be painted (too much code ...).

When advanced mode is used, GUICtrlRead($tab,1) will return the controlID instead of index of the clicked tab item.

To create a new control on an existing tabitem use GUISwitch($hWin,$tabitem) to select it and just create your new control. Don't forget to close your tabitem creation with GUICtrlCreateTabItem("").

Edit - added quote Edited by nitekram

Share this post


Link to post
Share on other sites

Posted

dirty,

I imagine the problem is caused by the overhead that a Tab control causes - AutoIt has to decide whether the ListView control is visible or not as it adds each ListViewItem.

You can speed it up significantly by using $GUI_HIDE/SHOW like this:

#include <GUIConstantsEx.au3>

$WinTitle = "whatever"

$MainGUI = GUICreate($WinTitle, 995, 765, Default, Default)

$TabControl = GUICtrlCreateTab(0, 0, 995, 750)
$Tab = GUICtrlCreateTabItem("Progect Managment")
$SearchAll = GUICtrlCreateButton("  Display all available projects", 10, 330, 480, 35)
$Results = GUICtrlCreateListView("1_________|2|3", 505, 20, 480, 325)
GUICtrlCreateTabItem("") ; Do nto forget this line  <<<<<<<<<<<<<<<<<<<<<<<<<<<<

GUISetState(@SW_SHOW, $MainGUI)

While 1 ;Main Loop
	Local $GUIGetMsg
	$GUIGetMsg = GUIGetMsg()
	If $GUIGetMsg = $GUI_EVENT_CLOSE Then ExitLoop
	If $GUIGetMsg = $SearchAll Then
		GUICtrlSetState($Results, $GUI_HIDE)
		For $i = 1 To 1000 Step 1
			GUICtrlCreateListViewItem("test" & $i, $Results)
		Next
		GUICtrlSetState($Results, $GUI_SHOW)
	EndIf
WEnd

I will keep looking to see if I can reduce the flashing even more. :D

nitekram,

By putting the GUICtrlCreateTabItem("") where you have it, the other controls are no longer on the tab and are permanently visible - as you can see from this script with 2 tabs:

#include <GUIConstantsEx.au3>
$WinTitle = "whatever"
$MainGUI = GUICreate($WinTitle, 995, 765, Default, Default)
$TabControl = GUICtrlCreateTab (0,0,995,750)
$Tab = GUICtrlCreateTabItem ("Progect Managment")
$Tab = GUICtrlCreateTabItem ("Test") ; New tab <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
GUICtrlCreateTabItem("")
$SearchAll = GUICtrlCreateButton("  Display all available projects", 10, 330, 480, 35)
$Results = GUICtrlCreateListView("1_________|2|3", 505, 20, 480, 325)
GUISetState(@SW_SHOW, $MainGUI)
While 1 ;Main Loop
    Local $GUIGetMsg
    $GUIGetMsg = GUIGetMsg()
    If $GUIGetMsg = $GUI_EVENT_CLOSE Then ExitLoop
    If $GUIGetMsg = $SearchAll Then
        for $i = 1 to 1000 Step 1
                GUICtrlCreateListViewItem ("test" & $i,$Results)
        Next
    EndIf
WEnd

M23

Share this post


Link to post
Share on other sites

Posted

dirty,

This is a pretty good solution - creating a child GUI to cover the ListView while it updates: :oops:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>

$WinTitle = "whatever"

$MainGUI = GUICreate($WinTitle, 995, 765, Default, Default)

$TabControl = GUICtrlCreateTab(0, 0, 995, 750)
$Tab = GUICtrlCreateTabItem("Progect Managment")
$SearchAll = GUICtrlCreateButton("  Display all available projects", 10, 330, 480, 35)
$Results = GUICtrlCreateListView("1_________|2|3", 505, 30, 480, 325)
GUICtrlCreateTabItem("")

GUISetState(@SW_SHOW, $MainGUI)

While 1 ;Main Loop
    Local $GUIGetMsg
    $GUIGetMsg = GUIGetMsg()
    If $GUIGetMsg = $GUI_EVENT_CLOSE Then ExitLoop
    If $GUIGetMsg = $SearchAll Then
		; Create a child GUI
		$hChild = GUICreate("", 480, 325, 0, 0, $WS_POPUP, $WS_EX_MDICHILD, $MainGUI)
		; Create a label to show we are updating
		$hLabel = GUICtrlCreateLabel("Updating", 0, 0, 480, 325, BitOR($SS_CENTER, $SS_CENTERIMAGE))
		GUICtrlSetFont(-1, 36)
		; Move the child to cover the ListView
		$aPos = WinGetPos(GUICtrlGetHandle($Results))
		WinMove($hChild, "", $aPos[0], $aPos[1])
		; Show the child without stealing focus from the main GUI
		GUISetState(@SW_SHOWNOACTIVATE)
		; Update the ListView
		For $i = 1 To 1000 Step 1
            GUICtrlCreateListViewItem("test" & $i, $Results)
        Next
		; Delete the child and make sure we reset the main GUI for subsequent actions
        GUIDelete($hChild)
		GUISwitch($MainGUI)
    EndIf
WEnd

I hope you find it useful. :D

M23

Share this post


Link to post
Share on other sites

Posted

Won't the good old _GUICtrlListView_BeginUpdate() and _GUICtrlListView_EndUpdate() take care of the ListView redraw? It's what I always use.

Share this post


Link to post
Share on other sites

Posted (edited)

wraithdu,

That was my first thought too, but it still flickered. :D

Again I imagine it is the Tab structure causing the problem as the new GUICtrlListViewItems are added.

M23

Edit: I might at least get your name right! :oops:

Edited by Melba23

Share this post


Link to post
Share on other sites

Posted (edited)

I knew my fix was to easy to have worked - lol.

Not sure why then this would not work - other then your work around? Would this be a bug, or is it because it is writing each line and then does a refresh of the screen after each line is written?

#include <GUIConstantsEx.au3>
$WinTitle = "whatever"
$MainGUI = GUICreate($WinTitle, 995, 765, Default, Default)
$TabControl = GUICtrlCreateTab (0,0,995,750)
$Tab = GUICtrlCreateTabItem ("Progect Managment")
$SearchAll = GUICtrlCreateButton("  Display all available projects", 10, 330, 480, 35)
$Results = GUICtrlCreateListView("1_________|2|3", 505, 20, 480, 325)
$Tab2 = GUICtrlCreateTabItem ("Test") ; New tab <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
GUICtrlCreateTabItem("")
 
GUISetState(@SW_SHOW, $MainGUI)
While 1 ;Main Loop
	Local $GUIGetMsg
	$GUIGetMsg = GUIGetMsg()
	If $GUIGetMsg = $GUI_EVENT_CLOSE Then ExitLoop
	If $GUIGetMsg = $SearchAll Then
		for $i = 1 to 1000 Step 1
				GUICtrlCreateListViewItem ("test" & $i,$Results)
		Next
	EndIf
WEnd
Edited by nitekram

Share this post


Link to post
Share on other sites

Posted

This is the best I could do (played with a bunch of window styles). It still flickers, but it is much faster.

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <ListViewConstants.au3>

$WinTitle = "whatever"
$MainGUI = GUICreate($WinTitle, 995, 765)
$TabControl = GUICtrlCreateTab (0,0,995,750)
$Tab = GUICtrlCreateTabItem ("Progect Managment")
$SearchAll = GUICtrlCreateButton("  Display all available projects", 10, 330, 480, 35)
$Results = GUICtrlCreateListView("1_________|2|3", 505, 20, 480, 325)
_GUICtrlListView_SetExtendedListViewStyle(GUICtrlGetHandle($Results), $LVS_EX_DOUBLEBUFFER, $LVS_EX_DOUBLEBUFFER)
GUICtrlCreateTabItem("")

GUISetState(@SW_SHOW, $MainGUI)

While 1 ;Main Loop
    Local $GUIGetMsg
    $GUIGetMsg = GUIGetMsg()
    If $GUIGetMsg = $GUI_EVENT_CLOSE Then ExitLoop
    If $GUIGetMsg = $SearchAll Then
        _GUICtrlListView_BeginUpdate(GUICtrlGetHandle($Results))
	    for $i = 1 to 1000 Step 1
			    GUICtrlCreateListViewItem ("test" & $i,$Results)
	    Next
        _GUICtrlListView_EndUpdate(GUICtrlGetHandle($Results))
    EndIf
WEnd

Share this post


Link to post
Share on other sites

Posted

nitekram,

is it because it is writing each line and then does a refresh of the screen after each line is written?

That is my belief - exacerbated by the fact that the control being on a Tab seems to slow the whole thing down because AutoIt needs to do its internal checking on the visibility of the Tab. :D

Which is why I ended up just covering the whole ListView. :oops:

M23

Share this post


Link to post
Share on other sites

Posted

I think I got it this time though - after help from above

#include <GUIConstantsEx.au3>
#Include <GuiListView.au3>

$WinTitle = "whatever"
$MainGUI = GUICreate($WinTitle, 995, 765, Default, Default)
$TabControl = GUICtrlCreateTab(0, 0, 995, 750)
$Tab = GUICtrlCreateTabItem("Progect Managment")
$SearchAll = GUICtrlCreateButton("  Display all available projects", 10, 330, 480, 35)
$Results = GUICtrlCreateListView("1_________|2|3", 505, 20, 480, 325)
$Tab2 = GUICtrlCreateTabItem("tab2")
GUICtrlCreateTabItem("") ; Do nto forget this line  <<<<<<<<<<<<<<<<<<<<<<<<<<<<
GUISetState(@SW_SHOW, $MainGUI)
While 1 ;Main Loop
    Local $GUIGetMsg
    $GUIGetMsg = GUIGetMsg()
    If $GUIGetMsg = $GUI_EVENT_CLOSE Then ExitLoop
    If $GUIGetMsg = $SearchAll Then
	    ;GUICtrlSetState($Results, $GUI_HIDE)
  _GUICtrlListView_BeginUpdate($Results)
	    For $i = 1 To 1000 Step 1
		    _GUICtrlListView_AddItem($Results, "test" & $i, 0)
	    Next
  _GUICtrlListView_EndUpdate($Results)
	    ;GUICtrlSetState($Results, $GUI_SHOW)
    EndIf
WEnd

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