Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 03/28/2021 in all areas

  1. Performance testsThe examples in first post have been used for performance tests on the basis of a common source file, 10100.txt, with 10,100 treeview items of which 100 are root items. In addition, the source file 10000.txt with 1 root item and 9,999 direct child items is used to test the creation of direct child items in a true virtual treeview. The tests are run as 64 bit code on Windows 7 and 10. Results on Windows 7 with AutoIt 3.3.14.2: 1) Conventional TreeView.au3 CreateTreeView(): 1084.16993786727 2) Optimized TreeView.au3 CreateTreeView(): 121.195523739788 3) Semi-Virtual TreeView.au3 CreateTreeView(): 100.011054067689 4) Virtual TreeView.au3 CreateTreeView(): 4.07172012097971 5) Virtual TreeView 9999 Child Items.au3 Create 9999 Child Items: 254.070404160541 The true virtual tree view in test 4 is created very fast because there are only 100 root items. On the other hand, the creation of 9,999 direct child items in test 5 is relatively slow. Results on Windows 10 with AutoIt 3.3.15.3 Beta: 1) Conventional TreeView.au3 CreateTreeView(): 1519.9362 2) Optimized TreeView.au3 CreateTreeView(): 212.4225 3) Semi-Virtual TreeView.au3 CreateTreeView(): 183.8063 4) Virtual TreeView.au3 CreateTreeView(): 18.1912 5) Virtual TreeView 9999 Child Items.au3 Create 9999 Child Items: 455.3943 Note that the tests here without exception are all a lot slower than the tests on Windows 7. Probably because Windows 10 is a more advanced, complex and sophisticated operating system than Windows 7 and therefore runs a lot more code to perform the same task. Structure of a semi-virtual treeviewIn 6) Semi-Virtual TreeView Structure.au3, the code line GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") is commented out. This means that only the tree structure is created based on information in the TVITEM structures. The tree structure itself is drawn by default code, but the texts depend on TVN_GETDISPINFO notifications in WM_NOTIFY messages, and are not drawn. In the image below, the first root item is expanded: New 7z-file at bottom of first post.
    3 points
  2. @Musashi has provided you my preferred link. I refer to it from time to time. DOS gets further and further far away in my memory
    1 point
  3. Start with e.g. https://ss64.com/nt/cmd.html
    1 point
  4. What maybe would work too is to $nPing = ping() the server right before TCPConnect and setting this $nPing, if not unusally high, as the current tcptimeout. Then connect. And after success reseting the tcptimeout. maybe thats enough to fix any lag in the hope that tcpsend is not influenced by the timeout. if so then it maybe helps to have the ping for each socket stored. I will do some research and probably implement something into the framework to combat this.
    1 point
  5. Hi to both of you @CYCho: I guess your initial message changed I remember it asked for an example showing what would happen if _GUICtrlListView_AddArray was used just before $LVM_DELETEALLITEMS Here is one example, using _GUICtrlListView_AddArray, it shows that the recreated label control keeps its value of 5 (no leaks) #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <MsgBoxConstants.au3> #include <SendMessage.au3> #include <WindowsConstants.au3> Global $idListview, $idLabel, $iInc = 1 Global $aArray[3][3] = _ [["item1", "c_12", "c_13"], _ ["item2", "c_22", "c_23"], _ ["item3", "c_32", "c_33"]] Example() Func Example() GUICreate("listview items", 220, 200) $idListview = GUICtrlCreateListView("col1 |col2|col3 ", 10, 10, 200, 150) Local $idButton = GUICtrlCreateButton("Click me", 25, 170, 70, 20) Create_Both() GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idButton MsgBox($MB_SYSTEMMODAL, "id Label #" & $iInc & " = " & $idLabel, _ "Now deleting label & LV content, then recreating both") _SendMessage(GUICtrlGetHandle($idListview), $LVM_DELETEALLITEMS) Sleep(1000) ; just to show LV is empty on screen GUICtrlDelete($idLabel) $iInc += 1 Create_Both() EndSwitch WEnd EndFunc ;==>Example Func Create_Both() _GUICtrlListView_AddArray($idListview, $aArray) $idLabel = GUICtrlCreateLabel("Label #" & $iInc, 130, 173, 70, 20) EndFunc ;==>Create_Both And as already discussed and found in Nine's example yesterday, this is the "bad" way with plenty of leaks : #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <MsgBoxConstants.au3> #include <SendMessage.au3> #include <WindowsConstants.au3> Global $idListview, $idItem1, $idItem2, $idItem3, $idLabel, $iInc = 1 Example() Func Example() GUICreate("listview items", 220, 200) $idListview = GUICtrlCreateListView("col1 |col2|col3 ", 10, 10, 200, 150) Local $idButton = GUICtrlCreateButton("Click me", 25, 170, 70, 20) Create_Both() GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idButton MsgBox($MB_SYSTEMMODAL, "id Label #" & $iInc & " = " & $idLabel, _ "Now deleting label & LV content, then recreating both") _SendMessage(GUICtrlGetHandle($idListview), $LVM_DELETEALLITEMS) Sleep(1000) ; just to show LV is empty on screen GUICtrlDelete($idLabel) $iInc += 1 Create_Both() EndSwitch WEnd EndFunc ;==>Example Func Create_Both() $idItem1 = GUICtrlCreateListViewItem("item1|col_12|col_13", $idListview) $idItem2 = GUICtrlCreateListViewItem("item2|col_22|col_23", $idListview) $idItem3 = GUICtrlCreateListViewItem("item3|col_32|col_33", $idListview) $idLabel = GUICtrlCreateLabel("Label #" & $iInc, 130, 173, 70, 20) EndFunc ;==>Create_Both Have a great day/night !
    1 point
  6. I see. Non-native controls do not generate control ID like native ones. They are totally different. Native controls are managed internally within the AutoIt GUI system. While non-native are managed by Windows. This is why you can use ListView UDF (for example) on controls coming from other application (not only AutoIt) while you can't with native functions. So you don't have to worry about those leaks and holes when using non-native. Hope this clarifies.
    1 point
  7. That's great news, thanks for reporting it. I may (at some point) look into creating a CodeCrypter set-up that does not rely on AES.au3 inclusion.
    1 point
  8. After little searching on the forum, i finally made a workable example for AutoIt v3.2.8.1: #include <GUIConstants.au3> #include <ListViewConstants.au3> Global Const $LVM_GETITEM = $LVM_FIRST + 5 Global Const $HDF_LEFT = 0x00000000 Global Const $HDF_RIGHT = 0x00000001 Global Const $HDF_CENTER = 0x00000002 Global Const $HDF_BITMAP = 0x00002000 Global Const $HDF_STRING = 0x00004000 Global Const $HDF_SORTDOWN = 0x00000200 Global Const $HDF_SORTUP = 0x00000400 Global Const $HDI_FORMAT = 0x00000004 Global Const $HDM_FIRST = 0x1200 Global Const $HDM_SETITEM = $HDM_FIRST + 4 Global Const $HDM_SETITEMW = $HDM_FIRST + 12 Global Const $tagHDITEM = "int Mask;int XY;ptr Text;hwnd hBMP;int TextMax;int Fmt;int Param;" & _ "int Image;int Order;int Type;ptr pFilter;int State" Global $iShowArrows = 1 Global $iShowSelectedCol = 0 Global $nCurrentColumn = -1 Global $nSortDirection = -1 Global $nSortSet = 0 Global $nColumnSet = 0 $hGUI = GUICreate("ListView Sort!") $ListView = GUICtrlCreateListView("Column 1|Column 2|Column3", 0, 50, 500, 400, $WS_VSCROLL, $LVS_EX_CHECKBOXES + $LVS_EX_GRIDLINES) GUICtrlRegisterListViewSort(-1, "ListView_Sort_Proc") ; Register the function "ListView_Sort_Proc" for the sorting callback GUICtrlCreateListViewItem("444|444|444", $ListView) GUICtrlSetImage(-1, "shell32.dll", 10) GUICtrlCreateListViewItem("333|333|333", $ListView) GUICtrlSetImage(-1, "shell32.dll", 7) GUICtrlCreateListViewItem("222|222|222", $ListView) GUICtrlSetImage(-1, "shell32.dll", 4) GUICtrlCreateListViewItem("111|111|111", $ListView) GUICtrlSetImage(-1, "shell32.dll", 8) GUISetState(@SW_SHOW, $hGUI) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $ListView $nSortSet = 0 $nCurrentColumn = $nColumnSet If $iShowSelectedCol Then GUICtrlSendMsg($ListView, $LVM_SETSELECTEDCOLUMN, GUICtrlGetState($ListView), 0) If $iShowArrows Then SetHeaderColumnArrow_Proc() DllCall("user32.dll", "int", "InvalidateRect", "hwnd", GUICtrlGetHandle($ListView), "int", 0, "int", 1) EndSwitch WEnd ; Our sorting callback funtion Func ListView_Sort_Proc($hWnd, $nItem1, $nItem2, $nColumn) Local $nSort, $iVal1, $iVal2 ; Switch the sorting direction If $nColumn = $nCurrentColumn Then If Not $nSortSet Then $nSortDirection *= -1 $nSortSet = 1 EndIf Else Local $hHeader = GUICtrlSendMsg($ListView, $LVM_GETHEADER, 0, 0) _GUICtrlHeader_SetItemFormat($hHeader, $nCurrentColumn, BitOR($HDF_LEFT, $HDF_STRING)) $nSortDirection = 1 EndIf $nColumnSet = $nColumn $iVal1 = _GUICtrlListView_GetSubItemText($ListView, $nItem1, $nColumn) $iVal2 = _GUICtrlListView_GetSubItemText($ListView, $nItem2, $nColumn) $nResult = 0 ; No change of item1 and item2 positions If $iVal1 < $iVal2 Then $nResult = -1 ; Put item2 before item1 ElseIf $iVal1 > $iVal2 Then $nResult = 1 ; Put item2 behind item1 EndIf Return $nResult * $nSortDirection EndFunc ; Retrieve the text of a listview item in a specified column Func _GUICtrlListView_GetSubItemText($nCtrlID, $nItemID, $nColumn) Local $stLvfi = DllStructCreate("uint;ptr;int;int[2];int") DllStructSetData($stLvfi, 1, $LVFI_PARAM) DllStructSetData($stLvfi, 3, $nItemID) Local $stBuffer = DllStructCreate("char[260]") Local $nIndex = GUICtrlSendMsg($nCtrlID, $LVM_FINDITEM, -1, DllStructGetPtr($stLvfi)); Local $stLvi = DllStructCreate("uint;int;int;uint;uint;ptr;int;int;int;int") DllStructSetData($stLvi, 1, $LVIF_TEXT) DllStructSetData($stLvi, 2, $nIndex) DllStructSetData($stLvi, 3, $nColumn) DllStructSetData($stLvi, 6, DllStructGetPtr($stBuffer)) DllStructSetData($stLvi, 7, 260) GUICtrlSendMsg($nCtrlID, $LVM_GETITEM, 0, DllStructGetPtr($stLvi)); Return DllStructGetData($stBuffer, 1) EndFunc Func SetHeaderColumnArrow_Proc() Local $hHeader = GUICtrlSendMsg($ListView, $LVM_GETHEADER, 0, 0) Local $iHeaderItemFormat = BitOR($HDF_LEFT, $HDF_STRING, $HDF_SORTUP) If $nSortDirection > 0 Then $iHeaderItemFormat = BitOR($HDF_LEFT, $HDF_STRING, $HDF_SORTDOWN) _GUICtrlHeader_SetItemFormat($hHeader, $nCurrentColumn, $iHeaderItemFormat) EndFunc Func _GUICtrlHeader_SetItemFormat($hWnd, $iIndex, $iFormat) Local $tItem, $pItem, $iResult $tItem = DllStructCreate($tagHDITEM) DllStructSetData($tItem, "Mask", $HDI_FORMAT) DllStructSetData($tItem, "Fmt", $iFormat) ;_GUICtrlHeader_SetItem() $pItem = DllStructGetPtr($tItem) If @Unicode Then $iResult = DllCall("User32.dll", "long", _ "SendMessage", "hwnd", $hWnd, "int", $HDM_SETITEMW, "int", $iIndex, "ptr", $pItem) Else $iResult = DllCall("User32.dll", "long", _ "SendMessage", "hwnd", $hWnd, "int", $HDM_SETITEM, "int", $iIndex, "ptr", $pItem) EndIf Return $iResult[0] <> 0 EndFunc
    1 point
×
×
  • Create New...