Jump to content

Search the Community

Showing results for tags 'guictrlcreatelistview'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 12 results

  1. FIrst of all, I apologize for the state of how it all looks as I had to remove thousands of lines to make a workable demo. It works, but it's not pretty. So if you see any inconsistencies just handwave it and they'll go away. 1. First issue is with Global $idPic = GUICtrlCreatePic('', 10, 45, 720, 405) on line 15. It works well however I want to center the image in the control by using $SS_CENTERIMAGE. The moment I add that style and click on a different image the new one simply repaints on top of the old one. Refer to function Func1 for repainting. I could always resize the picture control and place it in the middle based on the bitmap passed but seems like the $SS_CENTERIMAGE is (should be) the perfect solution. 2. Next is the fact that I couldn't find a way to make images scrollable with a horizontal bar only in the list view. Basically one row and infinite columns is what I'd like. I tried formatting the list with with just 1 item and all the rest are subitems however the images are not displayed. Seems like the isssue is with the _GUICtrlListView_SetView($idListview, 0). Specifically the fact that 0 value refers to large icons and the list is then treated differently. I'm wondering if there are any workarounds or similar solutions. 3. It seems there's a memory leak in function Func1. RAM increases each time a new thumbnail is loaded without releasing the old one when next one is drawn. Any help is much appreciated. Been stuck on couple of these for a few days now.
  2. I made a iconLVw.au3showing the the Icon for DLL's. Each LV-Item has 8 SubItems and only the SubItems should have a Icon. The Item himself should only be used for the checking State. This is used to save the selected Items to Disk for future use. But in my script each Item shows the same (first Index in ImageList) Icon, At the moment i use _GUICtrlListView_SetColumnWidth($listview, 0, 20) Is their a better way? mfg (auto)Bert
  3. I have a LV with different coloured Cols: ;https://autoit.de/index.php/Thread/84279-Unterschiedliche-Textfarben-innerhalb-einer-ListView/?postID=674195#post674195 #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <array.au3> #include <ListViewConstants.au3> #include <StructureConstants.au3> #include <WindowsConstants.au3> $aColBK = IniReadSection(@ScriptDir & "\lv_format.ini", "ColBKColor") _ArrayDelete($aColBK, 0) ;_ArrayDisplay($aColBK) $aRowBK = IniReadSection(@ScriptDir & "\lv_format.ini", "RowBKColor") _ArrayDelete($aRowBK, 0) ;_ArrayDisplay($aColBK) $aColText = IniReadSection(@ScriptDir & "\lv_format.ini", "ColTextColor") _ArrayDelete($aColText, 0) ;_ArrayDisplay($aColBK) $aRowText = IniReadSection(@ScriptDir & "\lv_format.ini", "RowTextColor") _ArrayDelete($aRowText, 0) ;_ArrayDisplay($aRowText) $GUI = GUICreate("Listview Farbig", 1024, 300, 0, 0) ;<==== Breite geändert $cListView = GUICtrlCreateListView("", 2, 2, 1020, 294, -1, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT)) ;<==== Breite geändert $hListView = GUICtrlGetHandle($cListView) For $i = 1 To 31 _GUICtrlListView_InsertColumn($hListView, $i - 1, $i, 25) _GUICtrlListView_SetColumnWidth($hListView, $i - 1, 32) ;<==== eingefügt für Spaltenbreite Next For $i = 0 To 21 ; alle Item/SubItem erstellen _GUICtrlListView_AddItem($hListView, "Item: " &$i, $i) For $j = 1 To 30 _GUICtrlListView_AddSubItem($hListView, $i, "Sub: "&$j, $j) Next Next GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUISetState() While True $msg = GUIGetMsg() Switch $msg Case -3 ExitLoop EndSwitch WEnd Func WM_NOTIFY($hWnd, $msg, $wParam, $lParam) Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hListView Switch $iCode Case $NM_CUSTOMDRAW Local $tCustDraw = DllStructCreate($tagNMLVCUSTOMDRAW, $lParam) Local $iDrawStage, $iItem, $iSubitem, $hDC, $tRect $iDrawStage = DllStructGetData($tCustDraw, 'dwDrawStage') Switch $iDrawStage Case $CDDS_ITEMPREPAINT Return $CDRF_NOTIFYSUBITEMDRAW Case BitOR($CDDS_ITEMPREPAINT, $CDDS_SUBITEM) ; Item/SubItem das aktuell gezeichnet werden soll ermitteln $iItem = DllStructGetData($tCustDraw, 'dwItemSpec') $iSubitem = DllStructGetData($tCustDraw, 'iSubItem') Switch $iItem ; Zeilenwahl Case -1 ;kommt nicht vor ist aber notwendig, damit case else verwendet werden kann Case Else $iIndex = _ArraySearch($aRowBK, $iItem, 0, 0, 0, 0, 1, 0) If $iIndex = -1 Then ;nicht im Array für spezielle Zeilen also weiß DllStructSetData($tCustDraw, 'clrTextBk', RGB2BGR(0xFFFFFF)) Else DllStructSetData($tCustDraw, 'clrTextBk', RGB2BGR($aRowBK[$iIndex][1])) ;ConsoleWrite('Item '&$iItem&' BK: '&$aRowBK[$iIndex][1] & @CRLF) EndIf $iIndex = _ArraySearch($aRowText, $iItem, 0, 0, 0, 0, 1, 0) If $iIndex = -1 Then ;nicht im Array für spezielle Zeilen also schwarz DllStructSetData($tCustDraw, 'clrText', RGB2BGR(0x000000)) Else DllStructSetData($tCustDraw, 'clrText', RGB2BGR($aRowText[$iIndex][1])) ;ConsoleWrite('Item '&$iItem&' Text: '&$aRowText[$iIndex][1] & @CRLF) EndIf EndSwitch Switch $iSubitem Case -1 ;kommt nicht vor ist aber notwendig, damit case else verwendet werden kann Case Else $iIndex = _ArraySearch($aColBK, $iSubitem, 0, 0, 0, 0, 1, 0) If $iIndex <> -1 Then DllStructSetData($tCustDraw, 'clrTextBk', RGB2BGR($aColBK[$iIndex][1])) ;ConsoleWrite('SubItem '&$iSubitem&' BK: '&$aColBK[$iIndex][1] & @CRLF) EndIf $iIndex = _ArraySearch($aColText, $iSubitem, 0, 0, 0, 0, 1, 0) If $iIndex <> -1 Then DllStructSetData($tCustDraw, 'clrText', RGB2BGR($aColText[$iIndex][1])) ;ConsoleWrite('SubItem '&$iSubitem&' Text: '&$aColText[$iIndex][1] & @CRLF) EndIf EndSwitch Return $CDRF_NEWFONT EndSwitch EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func RGB2BGR($iColor) Local $sH = Hex($iColor, 6) Return '0x' & StringRight($sH, 2) & StringMid($sH, 3, 2) & StringLeft($sH, 2) EndFunc ;==>RGB2BGR i use lv_format.ini for defining the cols Background- and Textcolour. Now i want to colour the cols in the LV-Header also, but i can't figure it out.
  4. I thought I remembered this from somewhere, then I searched, but cannot find which I am looking for... How to display additional, hidden ListViewItem text in a popup? I thought I saw a Style element that does that, but I cannot find it Just point me in the right direction please?
  5. Hello guys, I'm working with a simple script, complementing a GUICtrlCreateListView which has 5 columns. I would order the first column so that the numbers are decreasing. #include <GuiListView.au3> #include <ListViewConstants.au3> #include <WindowsConstants.au3> #include <GuiConstantsEx.au3> #include <StructureConstants.au3> Opt('MustDeclareVars', 1) Global $search_LV, $B_DESCENDING GUICreate("ListView Sort by Column Click", 400, 300) $search_LV = GUICtrlCreateListView("String|Number|String", 2, 2, 394, 268) GUICtrlSendMsg($search_LV, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES) GUICtrlSendMsg($search_LV, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT) GUICtrlCreateListViewItem("line4|5|1A", $search_LV) GUICtrlCreateListViewItem("line5|4.50 |1B", $search_LV) GUICtrlCreateListViewItem("line10|4.0 |2C", $search_LV) GUICtrlCreateListViewItem("line3|23|01", $search_LV) GUICtrlCreateListViewItem("line2|0.34560 |09", $search_LV) GUICtrlCreateListViewItem("line1|1.0 |7A", $search_LV) GUICtrlCreateListViewItem("line1|0.1 |8C", $search_LV) GUICtrlCreateListViewItem("line1|97|5B", $search_LV) GUICtrlCreateListViewItem("line1|910|9B", $search_LV) GUICtrlCreateListViewItem("line1|99|11", $search_LV) GUICtrlCreateListViewItem("line1|990.99|06", $search_LV) _GUICtrlListView_SetColumnWidth($search_LV, 0, 75) _GUICtrlListView_SetColumnWidth($search_LV, 1, 75) _GUICtrlListView_SetColumnWidth($search_LV, 2, 75) GUISetState() GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") ;~ _GUICtrlListView_RegisterSortCallBack($search_LV, False) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $search_LV ; Kick off the sort callback ;~ _GUICtrlListView_SortItems($search_LV, GUICtrlGetState($search_LV)) ;~ _GUICtrlListView_UnRegisterSortCallBack($search_LV) EndSwitch WEnd Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg, $iwParam Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo $hWndListView = $search_LV ;~ If Not IsHWnd($search_LV) Then $hWndListView = GUICtrlGetHandle($search_LV) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom ;~ Case $search_LV Case GUICtrlGetHandle($search_LV) Switch $iCode Case $LVN_COLUMNCLICK ; A column was clicked ConsoleWrite("Header geklickt" & @CRLF) Local $tInfo = DllStructCreate($tagNMLISTVIEW, $iLparam) _GUICtrlListView_UnRegisterSortCallBack($search_LV) Local $ColumnSorted = DllStructGetData($tInfo, 'SubItem') If $ColumnSorted = 1 Then ConsoleWrite('Numeric: ' & _GUICtrlListView_RegisterSortCallBack($search_LV, True) & @CRLF) Else ConsoleWrite('Literal: ' & _GUICtrlListView_RegisterSortCallBack($search_LV, False) & @CRLF) EndIf _GUICtrlListView_SortItems($search_LV, DllStructGetData($tInfo, 'SubItem')) EndSwitch EndSwitch EndFunc ;==>WM_NOTIFY Ordering the "String" column, you notice that the line "line10" is not ordered last. And 'possible to order the "String" column in descending order? thank you very much
  6. Hey guys Quick question: In this GUI the listview is created from items in test.txt I would like my "Get Info" button to show the actual text of the item that is selected. So far I have been able to make it show the number of the item. What is the last missing puzzle here? #include <GUIConstantsEx.au3> #include <GUIListViewEx.au3> Global $MainGUI_ManageItemList Global $File = "test.txt" Global $FileToArray = FileReadToArray("test.txt") Call ("MainGUI_ManageItemList") Func MainGUI_ManageItemList() Local $Button1 $MainGUI_ManageItemList = GUICreate("Manage Item List", 800, 400, -1, -1) $cLV = GUICtrlCreateListView("[items]", 10, 10, 400, 775, $LVS_NOCOLUMNHEADER) GUICtrlSetFont(-1, 12, 800, 0, "@Arial Unicode MS") _GUICtrlListView_SetColumnWidth($cLV, 0, 378) $Button1 = GUICtrlCreateButton("Button 1", 425, 10, 80, 30) $RemoveItem = GUICtrlCreateButton("Remove Item", 425, 50, 80, 30) $GetInfo = GUICtrlCreateButton("GetInfo", 425, 120, 80, 30) GUISetState(@SW_SHOW, $MainGUI_ManageItemList) ; Intialise ListView Global $iLV_Index = _GUIListViewEx_Init($cLV) ; Insert lines _GUIListViewEx_Insert($FileToArray, True) ; Register required messages _GUIListViewEx_MsgRegister(True, False, False, False) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $Button1 MsgBox(0,"","Button 1 is pressed") Case $RemoveItem _GUIListViewEx_Delete() Case $GetInfo $iIndex = _GUICtrlListView_GetSelectedIndices($cLV) msgbox (0, "Selected item", $iIndex) EndSwitch WEnd EndFunc ;==>Main
  7. Hi Guys, I'm working on this project: $Import = GUICtrlCreateButton("Import", 15, 175, 90, 40, $WS_GROUP) $List = GUICtrlCreateListView("Name|Address|E-mail", 15, 220, 400, 363, $LVS_SORTDESCENDING) $Item1 = GUICtrlCreateListViewItem("test|test|test", $List) GUISetState(@SW_SHOW, $GUI) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE, $Exit Exit Case $Import $Table_Import = FileOpenDialog("Import list '*.txt'", @DesktopDir & "\", "Text (*.txt)") If @error Then ContinueLoop GUICtrlSetData($Item1, $Table_Import) In the text file the fields are delimited with "|" and the values are not in the same row but one below the other. However in the txt file the sum of the values may change. Can you help me? Thank's
  8. Hello guys, I built a gui where a GUICtrlCreateListView with two columns is present. Through an "Import" button I would be able to import the contents of an .xls or .txt. Can you help me? Thank's
  9. I am trying to adjust my top column so the column topics are centered and using a bigger font. However, whenever I use a bigger font the columns stay the same size and I just get a ",,," Does anyone know how to stretch the columns to use the entire box, center it, and increase the font size? Thanks for any help. #include <Misc.au3> #include <Excel.au3> #include <GUIConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> GUICreate("Indications", 410, 280, 590, 85, -1, $WS_EX_ACCEPTFILES) ; Size of box GUISetBkColor(0x00E0FFFF) ; will change background color Local $idListview = GUICtrlCreateListView(" Column | Item | PCI | IDE ", 5, 5, 395, 210) ;,$LVS_SORTDESCENDING) GUICtrlSetFont($idListview, 12) ;GUICtrlSetFont($idListview, 18) ; Font size I would like to use Local $idButton = GUICtrlCreateButton("Close", 150, 220, 90, 55) ; CLOSE BUTTON Local $idItem1 = GUICtrlCreateListViewItem("item211|col22|col23|col34", $idListview) Local $idItem2 = GUICtrlCreateListViewItem("test111|test31|test5|test6", $idListview) GUICtrlSetState(-1, $GUI_DROPACCEPTED) ; to allow drag and dropping GUISetState(@SW_SHOW) ;GUICtrlDelete($idItem1) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idButton ExitLoop Case $idListview EndSwitch WEnd
  10. Happy New year to all. when I run the program without using $LVS_EX_GRIDLINES I get the Index and the subitem values correctly. when I run the program using $LVS_EX_GRIDLINES I get the Index always = -1 and the subitem values are correct. What do I need to do to get the correct index and subitem using the gridlines? right click a sub item to view in Console. REB #Region - Includes #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <WindowsConstants.au3> #include <ListViewConstants.au3> #EndRegion - Includes #Region - Variables Local $width = @DesktopWidth, $wheight = @DesktopHeight - 30, $COLOR_GUI = 0xFFFFFF, $lvtop = 100, $index, $subitem #Region -Create GUI GUICreate("Test WM_NOTIFY()", $width, $wheight - 150, 0, 0) ;@DesktopWidth, @DesktopHeight, 0, 0) ; GUISetBkColor(0xF0F4F9) ; $COLOR_GUI) GUISetState() #EndRegion -Create GUI GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") #Region - Create Listview $g_idListView = GUICtrlCreateListView("", 0, $lvtop, $width, $wheight - $lvtop - 150, $LVS_REPORT, $LVS_EX_GRIDLINES) ;~ $g_idListView = GUICtrlCreateListView("", 0, $lvtop, $width, $wheight - $lvtop - 50, $LVS_REPORT) #Region - Add Columns ; Add columns _GUICtrlListView_InsertColumn($g_idListView, 0, 0, 30) For $i = 1 To 15 Step 3 _GUICtrlListView_InsertColumn($g_idListView, $i, "TOTAL = 100", 105 + 31) _GUICtrlListView_InsertColumn($g_idListView, $i + 2, "PHASE", 65) _GUICtrlListView_InsertColumn($g_idListView, $i + 3, "", 22) Next _GUICtrlListView_InsertColumn($g_idListView, $i, "TOTAL =", 105 + 31) _GUICtrlListView_InsertColumn($g_idListView, $i + 2, "PHASE", 65) GUICtrlSetFont($g_idListView, 13, 700, Default, "Courier New", 4) ;~ GUICtrlSetState($g_idListView, $GUI_SHOW) For $i = 1 To 50 _GUICtrlListView_AddItem($g_idListView, $i, 0) Next Local $jump = -2 For $i = 1 To 6 $jump = $jump + 3 _GUICtrlListView_SetItem($g_idListView, " 100", 0, $jump) _GUICtrlListView_SetItem($g_idListView, 1, 0, $jump + 1) Next #EndRegion - Add Columns #EndRegion - Create Listview #Region - Loop Do $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE, $idOK ExitLoop EndSwitch Until $msg = $GUI_EVENT_CLOSE #EndRegion - Loop GUIDelete() Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam, $index, $subitem Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo $hWndListView = $g_idListView If Not IsHWnd($g_idListView) Then $hWndListView = GUICtrlGetHandle($g_idListView) $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode Case $NM_RCLICK ; Sent by a list-view control when the user clicks an item with the right mouse button $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam) $index = DllStructGetData($tInfo, "Index") ;& @CRLF & _ $subitem = DllStructGetData($tInfo, "SubItem") ;& @CRLF & _ EndSwitch ConsoleWrite("Index = " & $index & @CRLF) ConsoleWrite("subitem = " & $subitem & @CRLF) EndSwitch EndFunc ;==>WM_NOTIFY
  11. Having problems with GUICtrlCreateListView() and _GUICtrlListView_Create(). But if I use either of them, sorting (by clicking the header to arrange the list) using GUICtrlCreateListView() it works. But for _GUICtrlListView_Create() it won't. Same thing happens for editing the list using GUICtrlCreateListView(). ;GUICtrlCreateListView() sorting works. Editing fails. #include <GuiEdit.au3> #include <GUIListViewEx_Mod.au3> #include <GuiImageList.au3> #include <String.au3> #include <Misc.au3> #include <File.au3> #include <Timers.au3> #include <WinAPI.au3> #include <GUIConstants.au3> #include <WindowsConstants.au3> #include <Array.au3> #include <EditConstants.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <GUIListBox.au3> #include <ListviewConstants.au3> Global $hEdit, $hDC, $hBrush, $Item = -1, $SubItem = 0 Global $Style = BitOR($WS_CHILD, $WS_VISIBLE, $ES_AUTOHSCROLL, $ES_LEFT) Global $aIcons[3] = [0, 3, 6], $font = "Gill Sans" Global $hGUI = GUICreate("TEST CLIENT", 1600, 900) $hListView = GUICtrlCreateListView("TEST1|TEST2|TEST3", 5, 100, 938, 500) ;$hListView = _GUICtrlListView_Create($hGUI, "TEST1|TEST2|TEST3", 5, 100, 938, 500, $LVS_REPORT, $WS_EX_CLIENTEDGE) _GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_HEADERDRAGDROP, $LVS_EX_BORDERSELECT, $LVS_EX_ONECLICKACTIVATE, $LVS_EDITLABELS,$WS_EX_DLGMODALFRAME, $WS_EX_CLIENTEDGE)) $hNM_DBCLK = GUICtrlCreateDummy() $hEN_KILLFOCUS = GUICtrlCreateDummy() _AddRow($hListView, "1|A|NAME1", $aIcons, 1) _AddRow($hListView, "2|B|NAME2", $aIcons, 2) _AddRow($hListView, "3|C|NAME3", $aIcons, 3) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") GUISetState(@SW_SHOW, $hGUI) _GUICtrlListView_RegisterSortCallBack($hListView) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit case $hNM_DBCLK Start_EditingLV() Case $hEN_KILLFOCUS End_EditingLV() Case $hListView _GUICtrlListView_SortItems($hListView, GUICtrlGetState($hListView)) EndSwitch WEnd _GUICtrlListView_UnRegisterSortCallBack($hListView) GUIDelete() ;=============================================================== Func _AddRow($hWnd, $sItem, $aIcons, $iPlus = 0) Local $aItem = StringSplit($sItem, "|") Local $iIndex = _GUICtrlListView_AddItem($hWnd, $aItem[1], $aIcons[0] + $iPlus, _GUICtrlListView_GetItemCount($hWnd) + 99999) _GUICtrlListView_SetColumnWidth($hWnd, 0, $LVSCW_AUTOSIZE_USEHEADER) For $x = 2 To $aItem[0] _GUICtrlListView_AddSubItem($hWnd, $iIndex, $aItem[$x], $x - 1, $aIcons[$x - 1] + $iPlus) _GUICtrlListView_SetColumnWidth($hWnd, $x - 1, $LVSCW_AUTOSIZE) Next EndFunc ;==>_AddRow Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) Local $tNMHDR, $hWndFrom, $iCode $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = DllStructGetData($tNMHDR, "hWndFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hListView Switch $iCode Case $NM_DBLCLK GUICtrlSendToDummy($hNM_DBCLK) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc Func FrameRect($hDC, $nLeft, $nTop, $nRight, $nBottom, $hBrush) Local $stRect = DllStructCreate("int;int;int;int") DllStructSetData($stRect, 1, $nLeft) DllStructSetData($stRect, 2, $nTop) DllStructSetData($stRect, 3, $nRight) DllStructSetData($stRect, 4, $nBottom) DllCall("user32.dll", "int", "FrameRect", "hwnd", $hDC, "ptr", DllStructGetPtr($stRect), "hwnd", $hBrush) EndFunc Func WM_COMMAND($hWnd, $Msg, $wParam, $lParam) Local $iCode = BitShift($wParam, 16) Switch $lParam Case $hEdit Switch $iCode Case $EN_KILLFOCUS GUICtrlSendToDummy($hEN_KILLFOCUS) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc Func Start_EditingLV() ControlDisable($hGUI, "", HWnd(_GUICtrlListView_GetHeader($hListView))) Local $aHit = _GUICtrlListView_SubItemHitTest($hListView) Local $hRect = ControlGetPos($hGUI, "", $hListView) If ($aHit[0] <> -1) And ($aHit[1] = 0) Then $Item = $aHit[0] $SubItem = 0 Local $aRect = _GUICtrlListView_GetItemRect($hListView, $Item) ElseIf ($aHit[0] <> -1) And ($aHit[1] > 0) Then $Item = $aHit[0] $SubItem = $aHit[1] Local $aRect = _GUICtrlListView_GetSubItemRect($hListView, $Item, $SubItem) ;dldl Else Return $GUI_RUNDEFMSG EndIf Local $iItemText = _GUICtrlListView_GetItemText($hListView, $Item, $SubItem) Local $iLen = _GUICtrlListView_GetStringWidth($hListView, $iItemText) $hEdit = _GUICtrlEdit_Create($hGUI, $iItemText, $aRect[0] + ($hRect[0] + 3), $aRect[1] + $hRect[1], $iLen + 10, 17, $Style) _GUICtrlEdit_SetSel($hEdit, 0, -1) _WinAPI_SetFocus($hEdit) $hDC = _WinAPI_GetWindowDC($hEdit) $hBrush = _WinAPI_CreateSolidBrush(0x0000FF) FrameRect($hDC, 0,0, $iLen + 10 , 17, $hBrush) HotKeySet("{ENTER}", "End_EditingLV") EndFunc Func End_EditingLV() Local $iText = _GUICtrlEdit_GetText($hEdit) _GUICtrlListView_SetItemText($hListView, $Item, $iText, $SubItem) _WinAPI_DeleteObject($hBrush) _WinAPI_ReleaseDC($hEdit, $hDC) _WinAPI_DestroyWindow($hEdit) ControlEnable($hGUI, "", HWnd(_GUICtrlListView_GetHeader($hListView))) $Item = -1 $SubItem = 0 HotKeySet("{ENTER}") EndFunc
  12. I'm have a working program that displays the users in Active Directory. When a user's name is clicked on it displays their details (profile folder, work folder, etc). However, what I'd really like to do is be able to eliminate using the mouse as much as possible, so instead of having to click on each user's name, you can use the UP and DOWN arrows and it will act as though their name has been clicked on (if that makes any sense?). Here's some of the code so far: $ADListView = GUICtrlCreateListView("Login Name|Display Name", 140, 60, 220, 280);A ListView to display the users ; Adjust the ADListView column headers _GUICtrlListView_SetColumnWidth($ADListView, 0, 100) _GUICtrlListView_SetColumnWidth($ADListView, 1, 116) Func UpdateUserList() _AD_Open() $SelectedUserType = GUICtrlRead($UserTypeCombo) ;Get the base OU for the user type $SelectedUserTypeBaseOU = IniRead("iniUsers.ini", $SelectedUserType, "BaseOU", "NotFound") ;Get the filtered results from the AD using base OU $ADData = _AD_GetObjectsInOU($SelectedUserTypeBaseOU, "(&(objectclass=user)(name=*))", 2, "sAMAccountName,distinguishedName,displayname", "displayname") GUICtrlSetData($ADListView, $ADData) _GUICtrlListView_DeleteAllItems($ADListView) GUICtrlSetData($UserPropertiesEditBox, "Properties of Selected User") $SelectedUser = "" ;For each AD user, add an item in in the ListView For $i = 1 To UBound($ADData) - 1 GUICtrlCreateListViewItem($ADData[$i][0] & "|" & $ADData[$i][2], $ADListView) GUICtrlSetOnEvent(-1, "ListClicked") ; For each item, add the required event Next _AD_Close() EndFunc ;==>UpdateUserList Func ListClicked() $ItemString = GUICtrlRead(@GUI_CtrlId) $ItemArray = StringSplit($ItemString, "|") $SelectedUser = $ItemArray[1] _AD_Open() $givenName = _AD_GetObjectAttribute($SelectedUser, "givenName") $SN = _AD_GetObjectAttribute($SelectedUser, "SN") $displayName = _AD_GetObjectAttribute($SelectedUser, "displayName") $profilePath = _AD_GetObjectAttribute($SelectedUser, "profilePath") $homeDirectory = _AD_GetObjectAttribute($SelectedUser, "homeDirectory") $homeDrive = _AD_GetObjectAttribute($SelectedUser, "homeDrive") $GroupArray = _AD_GetUserGroups($SelectedUser) GUICtrlSetData($UserPropertiesEditBox, "") _GUICtrlEdit_AppendText($UserPropertiesEditBox, "Properties of Selected User") _GUICtrlEdit_AppendText($UserPropertiesEditBox, @CRLF & @CRLF & "First Name: " & $givenName) _GUICtrlEdit_AppendText($UserPropertiesEditBox, @CRLF & @CRLF & "Last Name: " & $SN) _GUICtrlEdit_AppendText($UserPropertiesEditBox, @CRLF & @CRLF & "Login Name: " & $SelectedUser) _GUICtrlEdit_AppendText($UserPropertiesEditBox, @CRLF & @CRLF & "Profile Directory: " & $profilePath) _GUICtrlEdit_AppendText($UserPropertiesEditBox, @CRLF & @CRLF & "Home Directory: " & $homeDirectory & " (" & $homeDrive & ")") _GUICtrlEdit_AppendText($UserPropertiesEditBox, @CRLF & @CRLF & "Group Membership:") For $i = 1 To UBound($GroupArray) - 1 _GUICtrlEdit_AppendText($UserPropertiesEditBox, @CRLF & _AD_FQDNToDisplayname($GroupArray[$i])) Next _AD_Close() EndFunc ;==>ListClicked Any help would be great, thank you!
×
×
  • Create New...