123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508 |
- #include-once
- #include "GuiImageList.au3"
- #include "Memory.au3"
- #include "SendMessage.au3"
- #include "StructureConstants.au3"
- #include "TreeViewConstants.au3"
- #include "UDFGlobalID.au3"
- #include "WinAPIConv.au3"
- #include "WinAPIGdi.au3"
- #include "WinAPIRes.au3"
- #include "WinAPISysInternals.au3"
- ; #INDEX# =======================================================================================================================
- ; Title .........: TreeView
- ; AutoIt Version : 3.3.14.5
- ; Language ......: English
- ; Description ...: Functions that assist with TreeView control management.
- ; A TreeView control is a window that displays a hierarchical list of items, such as the headings in a document,
- ; the entries in an index, or the files and directories on a disk. Each item consists of a label and an optional
- ; bitmapped image, and each item can have a list of subitems associated with it. By clicking an item, the user
- ; can expand or collapse the associated list of subitems.
- ; Author(s) .....: Paul Campbell (PaulIA), Gary Frost (gafrost), Holger Kotsch
- ; ===============================================================================================================================
- ; Default treeview item extended structure
- ; http://msdn.microsoft.com/en-us/library/bb773459.aspx
- ; Min.OS: 2K, NT4 with IE 4.0, 98, 95 with IE 4.0
- ; #VARIABLES# ===================================================================================================================
- Global $__g_hTVLastWnd
- ; ===============================================================================================================================
- ; #CONSTANTS# ===================================================================================================================
- Global Const $__TREEVIEWCONSTANT_ClassName = "SysTreeView32"
- Global Const $__TREEVIEWCONSTANT_WM_SETREDRAW = 0x000B
- Global Const $__TREEVIEWCONSTANT_DEFAULT_GUI_FONT = 17
- ; ===============================================================================================================================
- ; #NO_DOC_FUNCTION# =============================================================================================================
- ; Not working/documented/implemented at this time
- ;
- ; _GUICtrlTreeView_GetOverlayImageIndex
- ; _GUICtrlTreeView_MapAccIDToItem
- ; _GUICtrlTreeView_MapItemToAccID
- ; _GUICtrlTreeView_SetOverlayImageIndex
- ; ===============================================================================================================================
- ; #CURRENT# =====================================================================================================================
- ; _GUICtrlTreeView_Add
- ; _GUICtrlTreeView_AddChild
- ; _GUICtrlTreeView_AddChildFirst
- ; _GUICtrlTreeView_AddFirst
- ; _GUICtrlTreeView_BeginUpdate
- ; _GUICtrlTreeView_ClickItem
- ; _GUICtrlTreeView_Create
- ; _GUICtrlTreeView_CreateDragImage
- ; _GUICtrlTreeView_CreateSolidBitMap
- ; _GUICtrlTreeView_Delete
- ; _GUICtrlTreeView_DeleteAll
- ; _GUICtrlTreeView_DeleteChildren
- ; _GUICtrlTreeView_Destroy
- ; _GUICtrlTreeView_DisplayRect
- ; _GUICtrlTreeView_DisplayRectEx
- ; _GUICtrlTreeView_EditText
- ; _GUICtrlTreeView_EndEdit
- ; _GUICtrlTreeView_EndUpdate
- ; _GUICtrlTreeView_EnsureVisible
- ; _GUICtrlTreeView_Expand
- ; _GUICtrlTreeView_ExpandedOnce
- ; _GUICtrlTreeView_FindItem
- ; _GUICtrlTreeView_FindItemEx
- ; _GUICtrlTreeView_GetBkColor
- ; _GUICtrlTreeView_GetBold
- ; _GUICtrlTreeView_GetChecked
- ; _GUICtrlTreeView_GetChildCount
- ; _GUICtrlTreeView_GetChildren
- ; _GUICtrlTreeView_GetCount
- ; _GUICtrlTreeView_GetCut
- ; _GUICtrlTreeView_GetDropTarget
- ; _GUICtrlTreeView_GetEditControl
- ; _GUICtrlTreeView_GetExpanded
- ; _GUICtrlTreeView_GetFirstChild
- ; _GUICtrlTreeView_GetFirstItem
- ; _GUICtrlTreeView_GetFirstVisible
- ; _GUICtrlTreeView_GetFocused
- ; _GUICtrlTreeView_GetHeight
- ; _GUICtrlTreeView_GetImageIndex
- ; _GUICtrlTreeView_GetImageListIconHandle
- ; _GUICtrlTreeView_GetIndent
- ; _GUICtrlTreeView_GetInsertMarkColor
- ; _GUICtrlTreeView_GetISearchString
- ; _GUICtrlTreeView_GetItemByIndex
- ; _GUICtrlTreeView_GetItemHandle
- ; _GUICtrlTreeView_GetItemParam
- ; _GUICtrlTreeView_GetLastChild
- ; _GUICtrlTreeView_GetLineColor
- ; _GUICtrlTreeView_GetNext
- ; _GUICtrlTreeView_GetNextChild
- ; _GUICtrlTreeView_GetNextSibling
- ; _GUICtrlTreeView_GetNextVisible
- ; _GUICtrlTreeView_GetNormalImageList
- ; _GUICtrlTreeView_GetParentHandle
- ; _GUICtrlTreeView_GetParentParam
- ; _GUICtrlTreeView_GetPrev
- ; _GUICtrlTreeView_GetPrevChild
- ; _GUICtrlTreeView_GetPrevSibling
- ; _GUICtrlTreeView_GetPrevVisible
- ; _GUICtrlTreeView_GetScrollTime
- ; _GUICtrlTreeView_GetSelected
- ; _GUICtrlTreeView_GetSelectedImageIndex
- ; _GUICtrlTreeView_GetSelection
- ; _GUICtrlTreeView_GetSiblingCount
- ; _GUICtrlTreeView_GetState
- ; _GUICtrlTreeView_GetStateImageIndex
- ; _GUICtrlTreeView_GetStateImageList
- ; _GUICtrlTreeView_GetText
- ; _GUICtrlTreeView_GetTextColor
- ; _GUICtrlTreeView_GetToolTips
- ; _GUICtrlTreeView_GetTree
- ; _GUICtrlTreeView_GetUnicodeFormat
- ; _GUICtrlTreeView_GetVisible
- ; _GUICtrlTreeView_GetVisibleCount
- ; _GUICtrlTreeView_HitTest
- ; _GUICtrlTreeView_HitTestEx
- ; _GUICtrlTreeView_HitTestItem
- ; _GUICtrlTreeView_Index
- ; _GUICtrlTreeView_InsertItem
- ; _GUICtrlTreeView_IsFirstItem
- ; _GUICtrlTreeView_IsParent
- ; _GUICtrlTreeView_Level
- ; _GUICtrlTreeView_SelectItem
- ; _GUICtrlTreeView_SelectItemByIndex
- ; _GUICtrlTreeView_SetBkColor
- ; _GUICtrlTreeView_SetBold
- ; _GUICtrlTreeView_SetChecked
- ; _GUICtrlTreeView_SetCheckedByIndex
- ; _GUICtrlTreeView_SetChildren
- ; _GUICtrlTreeView_SetCut
- ; _GUICtrlTreeView_SetDropTarget
- ; _GUICtrlTreeView_SetFocused
- ; _GUICtrlTreeView_SetHeight
- ; _GUICtrlTreeView_SetIcon
- ; _GUICtrlTreeView_SetImageIndex
- ; _GUICtrlTreeView_SetIndent
- ; _GUICtrlTreeView_SetInsertMark
- ; _GUICtrlTreeView_SetInsertMarkColor
- ; _GUICtrlTreeView_SetItemHeight
- ; _GUICtrlTreeView_SetItemParam
- ; _GUICtrlTreeView_SetLineColor
- ; _GUICtrlTreeView_SetNormalImageList
- ; _GUICtrlTreeView_SetScrollTime
- ; _GUICtrlTreeView_SetSelected
- ; _GUICtrlTreeView_SetSelectedImageIndex
- ; _GUICtrlTreeView_SetState
- ; _GUICtrlTreeView_SetStateImageIndex
- ; _GUICtrlTreeView_SetStateImageList
- ; _GUICtrlTreeView_SetText
- ; _GUICtrlTreeView_SetTextColor
- ; _GUICtrlTreeView_SetToolTips
- ; _GUICtrlTreeView_SetUnicodeFormat
- ; _GUICtrlTreeView_Sort
- ; ===============================================================================================================================
- ; #INTERNAL_USE_ONLY# ===========================================================================================================
- ; $tagTVINSERTSTRUCT
- ; __GUICtrlTreeView_AddItem
- ; __GUICtrlTreeView_ExpandItem
- ; __GUICtrlTreeView_GetItem
- ; __GUICtrlTreeView_ReverseColorOrder
- ; __GUICtrlTreeView_SetItem
- ; __GUICtrlTreeView_SortGetFirstChild
- ; ===============================================================================================================================
- ; #INTERNAL_USE_ONLY# ===========================================================================================================
- ; Name...........: $tagTVINSERTSTRUCT
- ; Description ...: Contains information used to add a new item to a tree-view control
- ; Fields ........: Parent - Handle to the parent item. If this member is $TVI_ROOT, the item is inserted at the root
- ; InsertAfter - Handle to the item after which the new item is to be inserted, or one of the following values:
- ; |$TVI_FIRST - Inserts the item at the beginning of the list
- ; |$TVI_LAST - Inserts the item at the end of the list
- ; |$TVI_ROOT - Add the item as a root item
- ; |$TVI_SORT - Inserts the item into the list in alphabetical order
- ; Mask - Flags that indicate which of the other structure members contain valid data:
- ; |$TVIF_CHILDREN - The Children member is valid
- ; |$TVIF_DI_SETITEM - The will retain the supplied information and will not request it again
- ; |$TVIF_HANDLE - The hItem member is valid
- ; |$TVIF_IMAGE - The Image member is valid
- ; |$TVIF_INTEGRAL - The Integral member is valid
- ; |$TVIF_PARAM - The Param member is valid
- ; |$TVIF_SELECTEDIMAGE - The SelectedImage member is valid
- ; |$TVIF_STATE - The State and StateMask members are valid
- ; |$TVIF_TEXT - The Text and TextMax members are valid
- ; hItem - Item to which this structure refers
- ; State - Set of bit flags and image list indexes that indicate the item's state. When setting the state
- ; +of an item, the StateMask member indicates the bits of this member that are valid. When retrieving the state
- ; +of an item, this member returns the current state for the bits indicated in the StateMask member. Bits 0
- ; +through 7 of this member contain the item state flags. Bits 8 through 11 of this member specify the one based
- ; +overlay image index.
- ; StateMask - Bits of the state member that are valid. If you are retrieving an item's state, set the bits
- ; +of the stateMask member to indicate the bits to be returned in the state member. If you are setting an item's
- ; +state, set the bits of the stateMask member to indicate the bits of the state member that you want to set.
- ; Text - Pointer to a null-terminated string that contains the item text.
- ; TextMax - Size of the buffer pointed to by the Text member, in characters
- ; Image - Index in the image list of the icon image to use when the item is in the nonselected state
- ; SelectedImage - Index in the image list of the icon image to use when the item is in the selected state
- ; Children - Flag that indicates whether the item has associated child items. This member can be one of the
- ; +following values:
- ; |0 - The item has no child items
- ; |1 - The item has one or more child items
- ; Param - A value to associate with the item
- ; Integral - Height of the item
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified ......: jpm
- ; Remarks .......:
- ; ===============================================================================================================================
- Global Const $tagTVINSERTSTRUCT = "handle Parent;handle InsertAfter;" & $tagTVITEMEX
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......: Gary Frost (gafrost)
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_Add($hWnd, $hSibling, $sText, $iImage = -1, $iSelImage = -1)
- Return __GUICtrlTreeView_AddItem($hWnd, $hSibling, $sText, $TVNA_ADD, $iImage, $iSelImage)
- EndFunc ;==>_GUICtrlTreeView_Add
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......: Gary Frost (gafrost)
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_AddChild($hWnd, $hParent, $sText, $iImage = -1, $iSelImage = -1)
- Return __GUICtrlTreeView_AddItem($hWnd, $hParent, $sText, $TVNA_ADDCHILD, $iImage, $iSelImage)
- EndFunc ;==>_GUICtrlTreeView_AddChild
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......: Gary Frost (gafrost)
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_AddChildFirst($hWnd, $hParent, $sText, $iImage = -1, $iSelImage = -1)
- Return __GUICtrlTreeView_AddItem($hWnd, $hParent, $sText, $TVNA_ADDCHILDFIRST, $iImage, $iSelImage)
- EndFunc ;==>_GUICtrlTreeView_AddChildFirst
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......: Gary Frost (gafrost)
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_AddFirst($hWnd, $hSibling, $sText, $iImage = -1, $iSelImage = -1)
- Return __GUICtrlTreeView_AddItem($hWnd, $hSibling, $sText, $TVNA_ADDFIRST, $iImage, $iSelImage)
- EndFunc ;==>_GUICtrlTreeView_AddFirst
- ; #INTERNAL_USE_ONLY# ===========================================================================================================
- ; Name...........: __GUICtrlTreeView_AddItem
- ; Description ...: Add a new item
- ; Syntax.........: __GUICtrlTreeView_AddItem ( $hWnd, $hRelative, $sText, $iMethod [, $iImage = -1 [, $iSelImage = -1]] )
- ; Parameters ....: $hWnd - Handle to the control
- ; $hRelative - Handle to an existing item that will be either parent or sibling to the new item
- ; $sText - The text for the new item
- ; $iMethod - The relationship between the new item and the $hRelative item
- ; |$TVNA_ADD - The item becomes the last sibling of the other item
- ; |$TVNA_ADDFIRST - The item becomes the first sibling of the other item
- ; |$TVNA_ADDCHILD - The item becomes the sibling before the other item
- ; |$TVNA_ADDCHILDFIRST - The item becomes the last child of the other item
- ; |$TVNA_INSERT - The item becomes the first child of the other item
- ; $iImage - Zero based index of the item's icon in the control's image list
- ; $iSelImage - Zero based index of the item's icon in the control's image list
- ; $iParam - Application Defined Data
- ; Return values .: Success - The handle to the new item
- ; Failure - 0
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......: Gary Frost (gafrost)
- ; Remarks .......: This function is for interall use only and should not normally be called by the end user
- ; Related .......:
- ; Link ..........:
- ; Example .......:
- ; ===============================================================================================================================
- Func __GUICtrlTreeView_AddItem($hWnd, $hRelative, $sText, $iMethod, $iImage = -1, $iSelImage = -1, $iParam = 0)
- Local $iAddMode
- Switch $iMethod
- Case $TVNA_ADD, $TVNA_ADDCHILD
- $iAddMode = $TVTA_ADD
- Case $TVNA_ADDFIRST, $TVNA_ADDCHILDFIRST
- $iAddMode = $TVTA_ADDFIRST
- Case Else
- $iAddMode = $TVTA_INSERT
- EndSwitch
- Local $hItem, $hItemID = 0
- If $hRelative <> 0x00000000 Then
- Switch $iMethod
- Case $TVNA_ADD, $TVNA_ADDFIRST
- $hItem = _GUICtrlTreeView_GetParentHandle($hWnd, $hRelative)
- Case $TVNA_ADDCHILD, $TVNA_ADDCHILDFIRST
- $hItem = $hRelative
- Case Else
- $hItem = _GUICtrlTreeView_GetParentHandle($hWnd, $hRelative)
- $hItemID = _GUICtrlTreeView_GetPrevSibling($hWnd, $hRelative)
- If $hItemID = 0x00000000 Then $iAddMode = $TVTA_ADDFIRST
- EndSwitch
- EndIf
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- Local $iBuffer = StringLen($sText) + 1
- Local $tBuffer
- Local $bUnicode = _GUICtrlTreeView_GetUnicodeFormat($hWnd)
- If $bUnicode Then
- $tBuffer = DllStructCreate("wchar Text[" & $iBuffer & "]")
- $iBuffer *= 2
- Else
- $tBuffer = DllStructCreate("char Text[" & $iBuffer & "]")
- EndIf
- Local $tInsert = DllStructCreate($tagTVINSERTSTRUCT)
- Switch $iAddMode
- Case $TVTA_ADDFIRST
- DllStructSetData($tInsert, "InsertAfter", $TVI_FIRST)
- Case $TVTA_ADD
- DllStructSetData($tInsert, "InsertAfter", $TVI_LAST)
- Case $TVTA_INSERT
- DllStructSetData($tInsert, "InsertAfter", $hItemID)
- EndSwitch
- Local $iMask = BitOR($TVIF_TEXT, $TVIF_PARAM)
- If $iImage >= 0 Then $iMask = BitOR($iMask, $TVIF_IMAGE)
- If $iSelImage >= 0 Then $iMask = BitOR($iMask, $TVIF_SELECTEDIMAGE)
- DllStructSetData($tBuffer, "Text", $sText)
- DllStructSetData($tInsert, "Parent", $hItem)
- DllStructSetData($tInsert, "Mask", $iMask)
- DllStructSetData($tInsert, "TextMax", $iBuffer)
- DllStructSetData($tInsert, "Image", $iImage)
- DllStructSetData($tInsert, "SelectedImage", $iSelImage)
- DllStructSetData($tInsert, "Param", $iParam)
- Local $hResult
- If _WinAPI_InProcess($hWnd, $__g_hTVLastWnd) Then
- DllStructSetData($tInsert, "Text", DllStructGetPtr($tBuffer))
- $hResult = _SendMessage($hWnd, $TVM_INSERTITEMW, 0, $tInsert, 0, "wparam", "struct*", "handle")
- Else
- Local $iInsert = DllStructGetSize($tInsert)
- Local $tMemMap
- Local $pMemory = _MemInit($hWnd, $iInsert + $iBuffer, $tMemMap)
- Local $pText = $pMemory + $iInsert
- _MemWrite($tMemMap, $tInsert, $pMemory, $iInsert)
- _MemWrite($tMemMap, $tBuffer, $pText, $iBuffer)
- DllStructSetData($tInsert, "Text", $pText)
- If $bUnicode Then
- $hResult = _SendMessage($hWnd, $TVM_INSERTITEMW, 0, $pMemory, 0, "wparam", "ptr", "handle")
- Else
- $hResult = _SendMessage($hWnd, $TVM_INSERTITEMA, 0, $pMemory, 0, "wparam", "ptr", "handle")
- EndIf
- _MemFree($tMemMap)
- EndIf
- Return $hResult
- EndFunc ;==>__GUICtrlTreeView_AddItem
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......: Gary Frost (gafrost)
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_BeginUpdate($hWnd)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- Return _SendMessage($hWnd, $__TREEVIEWCONSTANT_WM_SETREDRAW, False) = 0
- EndFunc ;==>_GUICtrlTreeView_BeginUpdate
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......: Gary Frost
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_ClickItem($hWnd, $hItem, $sButton = "left", $bMove = False, $iClicks = 1, $iSpeed = 0)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- Local $tRECT = _GUICtrlTreeView_DisplayRectEx($hWnd, $hItem, True)
- If @error Then Return SetError(@error, @error, 0)
- ; Always click on the left-most portion of the control, not the center. A
- ; very wide control may be off-screen which means clicking on it's center
- ; will click outside the window.
- Local $tPoint = _WinAPI_PointFromRect($tRECT, False)
- _WinAPI_ClientToScreen($hWnd, $tPoint)
- Local $iX, $iY
- _WinAPI_GetXYFromPoint($tPoint, $iX, $iY)
- Local $iMode = Opt("MouseCoordMode", 1)
- If Not $bMove Then
- Local $aPos = MouseGetPos()
- _WinAPI_ShowCursor(False)
- MouseClick($sButton, $iX, $iY, $iClicks, $iSpeed)
- MouseMove($aPos[0], $aPos[1], 0)
- _WinAPI_ShowCursor(True)
- Else
- MouseClick($sButton, $iX, $iY, $iClicks, $iSpeed)
- EndIf
- Opt("MouseCoordMode", $iMode)
- Return 1
- EndFunc ;==>_GUICtrlTreeView_ClickItem
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......: Gary Frost
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_Create($hWnd, $iX, $iY, $iWidth = 150, $iHeight = 150, $iStyle = 0x00000037, $iExStyle = 0x00000000)
- If Not IsHWnd($hWnd) Then
- ; Invalid Window handle for _GUICtrlTreeView_Create 1st parameter
- Return SetError(1, 0, 0)
- EndIf
- If $iWidth = -1 Then $iWidth = 150
- If $iHeight = -1 Then $iHeight = 150
- If $iStyle = -1 Then $iStyle = BitOR($TVS_SHOWSELALWAYS, $TVS_DISABLEDRAGDROP, $TVS_LINESATROOT, $TVS_HASLINES, $TVS_HASBUTTONS)
- If $iExStyle = -1 Then $iExStyle = 0x00000000
- $iStyle = BitOR($iStyle, $__UDFGUICONSTANT_WS_CHILD, $__UDFGUICONSTANT_WS_VISIBLE)
- Local $nCtrlID = __UDF_GetNextGlobalID($hWnd)
- If @error Then Return SetError(@error, @extended, 0)
- Local $hTree = _WinAPI_CreateWindowEx($iExStyle, $__TREEVIEWCONSTANT_ClassName, "", $iStyle, $iX, $iY, $iWidth, $iHeight, $hWnd, $nCtrlID)
- _WinAPI_SetFont($hTree, _WinAPI_GetStockObject($__TREEVIEWCONSTANT_DEFAULT_GUI_FONT))
- Return $hTree
- EndFunc ;==>_GUICtrlTreeView_Create
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......: Gary Frost (gafrost)
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_CreateDragImage($hWnd, $hItem)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- Return _SendMessage($hWnd, $TVM_CREATEDRAGIMAGE, 0, $hItem, 0, "wparam", "handle", "handle")
- EndFunc ;==>_GUICtrlTreeView_CreateDragImage
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Gary Frost (gafrost)
- ; Modified.......:
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_CreateSolidBitMap($hWnd, $iColor, $iWidth, $iHeight)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- Return _WinAPI_CreateSolidBitmap($hWnd, $iColor, $iWidth, $iHeight)
- EndFunc ;==>_GUICtrlTreeView_CreateSolidBitMap
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Gary Frost (gafrost)
- ; Modified.......: re-written by Holger Kotsch, re-written again by Gary Frost
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_Delete($hWnd, $hItem = 0)
- If $hItem = 0 Then $hItem = 0x00000000
- If IsHWnd($hWnd) Then
- If $hItem = 0x00000000 Then
- $hItem = _SendMessage($hWnd, $TVM_GETNEXTITEM, $TVGN_CARET, 0, 0, "wparam", "handle", "handle")
- If $hItem <> 0x00000000 Then Return _SendMessage($hWnd, $TVM_DELETEITEM, 0, $hItem, 0, "wparam", "handle", "hwnd") <> 0
- Return False
- Else
- If GUICtrlDelete($hItem) Then Return True
- Return _SendMessage($hWnd, $TVM_DELETEITEM, 0, $hItem, 0, "wparam", "handle", "hwnd") <> 0
- EndIf
- Else
- If $hItem = 0x00000000 Then
- $hItem = GUICtrlSendMsg($hWnd, $TVM_GETNEXTITEM, $TVGN_CARET, 0)
- If $hItem <> 0x00000000 Then Return GUICtrlSendMsg($hWnd, $TVM_DELETEITEM, 0, $hItem) <> 0
- Return False
- Else
- If GUICtrlDelete($hItem) Then Return True
- Return GUICtrlSendMsg($hWnd, $TVM_DELETEITEM, 0, $hItem) <> 0
- EndIf
- EndIf
- EndFunc ;==>_GUICtrlTreeView_Delete
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Gary Frost (gafrost)
- ; Modified.......:
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_DeleteAll($hWnd)
- Local $iCount = 0
- If IsHWnd($hWnd) Then
- _SendMessage($hWnd, $TVM_DELETEITEM, 0, $TVI_ROOT)
- $iCount = _GUICtrlTreeView_GetCount($hWnd) ; might be created with autoit create
- If $iCount Then Return GUICtrlSendMsg($hWnd, $TVM_DELETEITEM, 0, $TVI_ROOT) <> 0
- Return True
- Else
- GUICtrlSendMsg($hWnd, $TVM_DELETEITEM, 0, $TVI_ROOT)
- $iCount = _GUICtrlTreeView_GetCount($hWnd) ; might be created with udf
- If $iCount Then Return _SendMessage($hWnd, $TVM_DELETEITEM, 0, $TVI_ROOT) <> 0
- Return True
- EndIf
- Return False
- EndFunc ;==>_GUICtrlTreeView_DeleteAll
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......: Gary Frost (gafrost)
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_DeleteChildren($hWnd, $hItem)
- Local $bResult
- If IsHWnd($hWnd) Then
- $bResult = _SendMessage($hWnd, $TVM_EXPAND, BitOR($TVE_COLLAPSE, $TVE_COLLAPSERESET), $hItem, 0, "wparam", "handle")
- Else
- $bResult = GUICtrlSendMsg($hWnd, $TVM_EXPAND, BitOR($TVE_COLLAPSE, $TVE_COLLAPSERESET), $hItem)
- EndIf
- Return $bResult
- EndFunc ;==>_GUICtrlTreeView_DeleteChildren
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Gary Frost (gafrost)
- ; Modified.......:
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_Destroy(ByRef $hWnd)
- ;If Not _WinAPI_IsClassName($hWnd, $__TREEVIEWCONSTANT_ClassName) Then Return SetError(2, 2, False)
- Local $iDestroyed = 0
- If IsHWnd($hWnd) Then
- If _WinAPI_InProcess($hWnd, $__g_hTVLastWnd) Then
- Local $nCtrlID = _WinAPI_GetDlgCtrlID($hWnd)
- Local $hParent = _WinAPI_GetParent($hWnd)
- $iDestroyed = _WinAPI_DestroyWindow($hWnd)
- Local $iRet = __UDF_FreeGlobalID($hParent, $nCtrlID)
- If Not $iRet Then
- ; can check for errors here if needed, for debug
- EndIf
- Else
- ; Not Allowed to Destroy Other Applications Control(s)
- Return SetError(1, 1, False)
- EndIf
- Else
- $iDestroyed = GUICtrlDelete($hWnd)
- EndIf
- If $iDestroyed Then $hWnd = 0
- Return $iDestroyed <> 0
- EndFunc ;==>_GUICtrlTreeView_Destroy
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......:
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_DisplayRect($hWnd, $hItem, $bTextOnly = False)
- Local $tRECT = _GUICtrlTreeView_DisplayRectEx($hWnd, $hItem, $bTextOnly)
- If @error Then Return SetError(@error, @error, 0)
- Local $aRect[4]
- $aRect[0] = DllStructGetData($tRECT, "Left")
- $aRect[1] = DllStructGetData($tRECT, "Top")
- $aRect[2] = DllStructGetData($tRECT, "Right")
- $aRect[3] = DllStructGetData($tRECT, "Bottom")
- Return $aRect
- EndFunc ;==>_GUICtrlTreeView_DisplayRect
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......: Gary Frost (gafrost)
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_DisplayRectEx($hWnd, $hItem, $bTextOnly = False)
- Local $tRECT = DllStructCreate($tagRECT)
- Local $iRet
- If IsHWnd($hWnd) Then
- ; RECT is expected to point to the item in its first member.
- DllStructSetData($tRECT, "Left", $hItem)
- If _WinAPI_InProcess($hWnd, $__g_hTVLastWnd) Then
- $iRet = _SendMessage($hWnd, $TVM_GETITEMRECT, $bTextOnly, $tRECT, 0, "wparam", "struct*")
- Else
- Local $iRect = DllStructGetSize($tRECT)
- Local $tMemMap
- Local $pMemory = _MemInit($hWnd, $iRect, $tMemMap)
- _MemWrite($tMemMap, $tRECT)
- $iRet = _SendMessage($hWnd, $TVM_GETITEMRECT, $bTextOnly, $pMemory, 0, "wparam", "ptr")
- _MemRead($tMemMap, $pMemory, $tRECT, $iRect)
- _MemFree($tMemMap)
- EndIf
- Else
- If Not IsHWnd($hItem) Then $hItem = _GUICtrlTreeView_GetItemHandle($hWnd, $hItem)
- ; RECT is expected to point to the item in its first member.
- DllStructSetData($tRECT, "Left", $hItem)
- $iRet = GUICtrlSendMsg($hWnd, $TVM_GETITEMRECT, $bTextOnly, DllStructGetPtr($tRECT))
- EndIf
- ; On failure ensure Left is set to 0 and not the item handle.
- If Not $iRet Then DllStructSetData($tRECT, "Left", 0)
- Return SetError($iRet = 0, $iRet, $tRECT)
- EndFunc ;==>_GUICtrlTreeView_DisplayRectEx
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......: Gary Frost (gafrost)
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_EditText($hWnd, $hItem)
- If Not IsHWnd($hItem) Then $hItem = _GUICtrlTreeView_GetItemHandle($hWnd, $hItem)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- _WinAPI_SetFocus($hWnd)
- Local $bUnicode = _GUICtrlTreeView_GetUnicodeFormat($hWnd)
- If $bUnicode Then
- Return _SendMessage($hWnd, $TVM_EDITLABELW, 0, $hItem, 0, "wparam", "handle", "handle")
- Else
- Return _SendMessage($hWnd, $TVM_EDITLABELA, 0, $hItem, 0, "wparam", "handle", "handle")
- EndIf
- EndFunc ;==>_GUICtrlTreeView_EditText
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......: Gary Frost (gafrost)
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_EndEdit($hWnd, $bCancel = False)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- Return _SendMessage($hWnd, $TVM_ENDEDITLABELNOW, $bCancel) <> 0
- EndFunc ;==>_GUICtrlTreeView_EndEdit
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......: Gary Frost (gafrost)
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_EndUpdate($hWnd)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- Return _SendMessage($hWnd, $__TREEVIEWCONSTANT_WM_SETREDRAW, True) = 0
- EndFunc ;==>_GUICtrlTreeView_EndUpdate
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Gary Frost (gafrost)
- ; Modified.......:
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_EnsureVisible($hWnd, $hItem)
- If Not IsHWnd($hItem) Then $hItem = _GUICtrlTreeView_GetItemHandle($hWnd, $hItem)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- Return _SendMessage($hWnd, $TVM_ENSUREVISIBLE, 0, $hItem, 0, "wparam", "handle") <> 0
- EndFunc ;==>_GUICtrlTreeView_EnsureVisible
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Holger Kotsch
- ; Modified.......: Gary Frost
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_Expand($hWnd, $hItem = 0, $bExpand = True)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- If $hItem = 0 Then $hItem = 0x00000000
- If $hItem = 0x00000000 Then
- $hItem = $TVI_ROOT
- Else
- If Not IsHWnd($hItem) Then
- Local $hItem_tmp = GUICtrlGetHandle($hItem)
- If $hItem_tmp <> 0x00000000 Then $hItem = $hItem_tmp
- EndIf
- EndIf
- If $bExpand Then
- __GUICtrlTreeView_ExpandItem($hWnd, $TVE_EXPAND, $hItem)
- Else
- __GUICtrlTreeView_ExpandItem($hWnd, $TVE_COLLAPSE, $hItem)
- EndIf
- EndFunc ;==>_GUICtrlTreeView_Expand
- ; #INTERNAL_USE_ONLY# ===========================================================================================================
- ; Name...........: __GUICtrlTreeView_ExpandItem($hWnd, $iExpand, $hItem)
- ; Description ...: Expands/Collapes the item and child(ren), if any
- ; Syntax.........: __GUICtrlTreeView_ExpandItem ( $hWnd, $iExpand, $hItem )
- ; Parameters ....: $hWnd - Handle to the control
- ; Return values .:
- ; Author ........: Holger Kotsch
- ; Modified.......: Gary Frost (gafrost)
- ; Remarks .......:
- ; Related .......:
- ; Link ..........:
- ; Example .......:
- ; ===============================================================================================================================
- Func __GUICtrlTreeView_ExpandItem($hWnd, $iExpand, $hItem)
- If Not IsHWnd($hWnd) Then
- If $hItem = 0x00000000 Then
- $hItem = $TVI_ROOT
- Else
- $hItem = GUICtrlGetHandle($hItem)
- If $hItem = 0 Then Return
- EndIf
- $hWnd = GUICtrlGetHandle($hWnd)
- EndIf
- _SendMessage($hWnd, $TVM_EXPAND, $iExpand, $hItem, 0, "wparam", "handle")
- If $iExpand = $TVE_EXPAND And $hItem > 0 Then _SendMessage($hWnd, $TVM_ENSUREVISIBLE, 0, $hItem, 0, "wparam", "handle")
- $hItem = _SendMessage($hWnd, $TVM_GETNEXTITEM, $TVGN_CHILD, $hItem, 0, "wparam", "handle")
- While $hItem <> 0x00000000
- Local $hChild = _SendMessage($hWnd, $TVM_GETNEXTITEM, $TVGN_CHILD, $hItem, 0, "wparam", "handle")
- If $hChild <> 0x00000000 Then __GUICtrlTreeView_ExpandItem($hWnd, $iExpand, $hItem)
- $hItem = _SendMessage($hWnd, $TVM_GETNEXTITEM, $TVGN_NEXT, $hItem, 0, "wparam", "handle")
- WEnd
- EndFunc ;==>__GUICtrlTreeView_ExpandItem
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......:
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_ExpandedOnce($hWnd, $hItem)
- Return BitAND(_GUICtrlTreeView_GetState($hWnd, $hItem), $TVIS_EXPANDEDONCE) <> 0
- EndFunc ;==>_GUICtrlTreeView_ExpandedOnce
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......:
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_FindItem($hWnd, $sText, $bInStr = False, $hStart = 0)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- If $hStart = 0 Then $hStart = _GUICtrlTreeView_GetFirstItem($hWnd)
- While $hStart <> 0x00000000
- Local $sItem = _GUICtrlTreeView_GetText($hWnd, $hStart)
- Switch $bInStr
- Case False
- If $sItem = $sText Then Return $hStart
- Case True
- If StringInStr($sItem, $sText) Then Return $hStart
- EndSwitch
- $hStart = _GUICtrlTreeView_GetNext($hWnd, $hStart)
- WEnd
- EndFunc ;==>_GUICtrlTreeView_FindItem
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Miguel Pilar (luckyb), Paul Campbell (PaulIA)
- ; Modified.......:
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_FindItemEx($hWnd, $sTreePath, $hStart = 0)
- Local $sDelimiter = Opt("GUIDataSeparatorChar")
- Local $iIndex = 1
- Local $aParts = StringSplit($sTreePath, $sDelimiter)
- If $hStart = 0 Then $hStart = _GUICtrlTreeView_GetFirstItem($hWnd)
- While ($iIndex <= $aParts[0]) And ($hStart <> 0x00000000)
- If StringStripWS(_GUICtrlTreeView_GetText($hWnd, $hStart), $STR_STRIPLEADING + $STR_STRIPTRAILING) = StringStripWS($aParts[$iIndex], $STR_STRIPLEADING + $STR_STRIPTRAILING) Then
- If $iIndex = $aParts[0] Then Return $hStart
- $iIndex += 1
- __GUICtrlTreeView_ExpandItem($hWnd, $TVE_EXPAND, $hStart)
- $hStart = _GUICtrlTreeView_GetFirstChild($hWnd, $hStart)
- Else
- $hStart = _GUICtrlTreeView_GetNextSibling($hWnd, $hStart)
- __GUICtrlTreeView_ExpandItem($hWnd, $TVE_COLLAPSE, $hStart)
- EndIf
- WEnd
- Return $hStart
- EndFunc ;==>_GUICtrlTreeView_FindItemEx
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Gary Frost (gafrost)
- ; Modified.......:
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_GetBkColor($hWnd)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- Local $sHex = Hex(String(_SendMessage($hWnd, $TVM_GETBKCOLOR)), 6)
- Return '0x' & StringMid($sHex, 5, 2) & StringMid($sHex, 3, 2) & StringMid($sHex, 1, 2)
- EndFunc ;==>_GUICtrlTreeView_GetBkColor
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......:
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_GetBold($hWnd, $hItem)
- Return BitAND(_GUICtrlTreeView_GetState($hWnd, $hItem), $TVIS_BOLD) <> 0
- EndFunc ;==>_GUICtrlTreeView_GetBold
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Gary Frost (gafrost)
- ; Modified.......:
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_GetChecked($hWnd, $hItem)
- If Not IsHWnd($hItem) Then $hItem = _GUICtrlTreeView_GetItemHandle($hWnd, $hItem)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- Local $tItem = DllStructCreate($tagTVITEMEX)
- DllStructSetData($tItem, "Mask", $TVIF_STATE)
- DllStructSetData($tItem, "hItem", $hItem)
- __GUICtrlTreeView_GetItem($hWnd, $tItem)
- Return BitAND(DllStructGetData($tItem, "State"), $TVIS_CHECKED) = $TVIS_CHECKED
- EndFunc ;==>_GUICtrlTreeView_GetChecked
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Gary Frost (gafrost)
- ; Modified.......:
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_GetChildCount($hWnd, $hItem)
- If Not IsHWnd($hItem) Then $hItem = _GUICtrlTreeView_GetItemHandle($hWnd, $hItem)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- Local $iRet = 0
- Local $hNext = _GUICtrlTreeView_GetFirstChild($hWnd, $hItem)
- If $hNext = 0x00000000 Then Return -1
- Do
- $iRet += 1
- $hNext = _GUICtrlTreeView_GetNextSibling($hWnd, $hNext)
- Until $hNext = 0x00000000
- Return $iRet
- EndFunc ;==>_GUICtrlTreeView_GetChildCount
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......: Gary Frost (gafrost)
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_GetChildren($hWnd, $hItem)
- If Not IsHWnd($hItem) Then $hItem = _GUICtrlTreeView_GetItemHandle($hWnd, $hItem)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- Local $tItem = DllStructCreate($tagTVITEMEX)
- DllStructSetData($tItem, "Mask", $TVIF_CHILDREN)
- DllStructSetData($tItem, "hItem", $hItem)
- __GUICtrlTreeView_GetItem($hWnd, $tItem)
- Return DllStructGetData($tItem, "Children") <> 0
- EndFunc ;==>_GUICtrlTreeView_GetChildren
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Gary Frost (gafrost)
- ; Modified.......:
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_GetCount($hWnd)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- Return _SendMessage($hWnd, $TVM_GETCOUNT)
- EndFunc ;==>_GUICtrlTreeView_GetCount
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......:
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_GetCut($hWnd, $hItem)
- Return BitAND(_GUICtrlTreeView_GetState($hWnd, $hItem), $TVIS_CUT) <> 0
- EndFunc ;==>_GUICtrlTreeView_GetCut
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......:
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_GetDropTarget($hWnd, $hItem)
- Return BitAND(_GUICtrlTreeView_GetState($hWnd, $hItem), $TVIS_DROPHILITED) <> 0
- EndFunc ;==>_GUICtrlTreeView_GetDropTarget
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......: Gary Frost (gafrost)
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_GetEditControl($hWnd)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- Return _SendMessage($hWnd, $TVM_GETEDITCONTROL, 0, 0, 0, "wparam", "lparam", "handle")
- EndFunc ;==>_GUICtrlTreeView_GetEditControl
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......:
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_GetExpanded($hWnd, $hItem)
- Return BitAND(_GUICtrlTreeView_GetState($hWnd, $hItem), $TVIS_EXPANDED) <> 0
- EndFunc ;==>_GUICtrlTreeView_GetExpanded
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......: Gary Frost (gafrost)
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_GetFirstChild($hWnd, $hItem)
- If Not IsHWnd($hItem) Then $hItem = _GUICtrlTreeView_GetItemHandle($hWnd, $hItem)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- Return _SendMessage($hWnd, $TVM_GETNEXTITEM, $TVGN_CHILD, $hItem, 0, "wparam", "handle", "handle")
- EndFunc ;==>_GUICtrlTreeView_GetFirstChild
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......: Gary Frost (gafrost)
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_GetFirstItem($hWnd)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- Return _SendMessage($hWnd, $TVM_GETNEXTITEM, $TVGN_ROOT, 0, 0, "wparam", "lparam", "handle")
- EndFunc ;==>_GUICtrlTreeView_GetFirstItem
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......: Gary Frost (gafrost)
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_GetFirstVisible($hWnd)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- Return _SendMessage($hWnd, $TVM_GETNEXTITEM, $TVGN_FIRSTVISIBLE, 0, 0, "wparam", "lparam", "handle")
- EndFunc ;==>_GUICtrlTreeView_GetFirstVisible
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......:
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_GetFocused($hWnd, $hItem)
- Return BitAND(_GUICtrlTreeView_GetState($hWnd, $hItem), $TVIS_FOCUSED) <> 0
- EndFunc ;==>_GUICtrlTreeView_GetFocused
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......: Gary Frost (gafrost)
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_GetHeight($hWnd)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- Return _SendMessage($hWnd, $TVM_GETITEMHEIGHT)
- EndFunc ;==>_GUICtrlTreeView_GetHeight
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......:
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_GetImageIndex($hWnd, $hItem)
- If Not IsHWnd($hItem) Then $hItem = _GUICtrlTreeView_GetItemHandle($hWnd, $hItem)
- Local $tItem = DllStructCreate($tagTVITEMEX)
- DllStructSetData($tItem, "Mask", $TVIF_IMAGE)
- DllStructSetData($tItem, "hItem", $hItem)
- __GUICtrlTreeView_GetItem($hWnd, $tItem)
- Return DllStructGetData($tItem, "Image")
- EndFunc ;==>_GUICtrlTreeView_GetImageIndex
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Gary Frost (gafrost)
- ; Modified.......:
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_GetImageListIconHandle($hWnd, $iIndex)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- Local $hImageList = _SendMessage($hWnd, $TVM_GETIMAGELIST, 0, 0, 0, "wparam", "lparam", "handle")
- Local $hIcon = DllCall("comctl32.dll", "handle", "ImageList_GetIcon", "handle", $hImageList, "int", $iIndex, "uint", 0)
- If @error Then Return SetError(@error, @extended, 0)
- Return $hIcon[0]
- EndFunc ;==>_GUICtrlTreeView_GetImageListIconHandle
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Gary Frost (gafrost)
- ; Modified.......:
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_GetIndent($hWnd)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- Return _SendMessage($hWnd, $TVM_GETINDENT)
- EndFunc ;==>_GUICtrlTreeView_GetIndent
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......: Gary Frost (gafrost)
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_GetInsertMarkColor($hWnd)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- Return _SendMessage($hWnd, $TVM_GETINSERTMARKCOLOR)
- EndFunc ;==>_GUICtrlTreeView_GetInsertMarkColor
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......: Gary Frost (gafrost)
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_GetISearchString($hWnd)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- Local $bUnicode = _GUICtrlTreeView_GetUnicodeFormat($hWnd)
- Local $iBuffer
- If $bUnicode Then
- $iBuffer = _SendMessage($hWnd, $TVM_GETISEARCHSTRINGW) + 1
- Else
- $iBuffer = _SendMessage($hWnd, $TVM_GETISEARCHSTRINGA) + 1
- EndIf
- If $iBuffer = 1 Then Return ""
- Local $tBuffer
- If $bUnicode Then
- $tBuffer = DllStructCreate("wchar Text[" & $iBuffer & "]")
- $iBuffer *= 2
- Else
- $tBuffer = DllStructCreate("char Text[" & $iBuffer & "]")
- EndIf
- If _WinAPI_InProcess($hWnd, $__g_hTVLastWnd) Then
- _SendMessage($hWnd, $TVM_GETISEARCHSTRINGW, 0, $tBuffer, 0, "wparam", "struct*")
- Else
- Local $tMemMap
- Local $pMemory = _MemInit($hWnd, $iBuffer, $tMemMap)
- If $bUnicode Then
- _SendMessage($hWnd, $TVM_GETISEARCHSTRINGW, 0, $pMemory, 0, "wparam", "ptr")
- Else
- _SendMessage($hWnd, $TVM_GETISEARCHSTRINGA, 0, $pMemory, 0, "wparam", "ptr")
- EndIf
- _MemRead($tMemMap, $pMemory, $tBuffer, $iBuffer)
- _MemFree($tMemMap)
- EndIf
- Return DllStructGetData($tBuffer, "Text")
- EndFunc ;==>_GUICtrlTreeView_GetISearchString
- ; #INTERNAL_USE_ONLY# ===========================================================================================================
- ; Name...........: __GUICtrlTreeView_GetItem
- ; Description ...: Retrieves some or all of a item's attributes
- ; Syntax.........: __GUICtrlTreeView_GetItem ( $hWnd, ByRef $tItem )
- ; Parameters ....: $hWnd - Handle to the control
- ; $tItem - $tagTVITEMEX structure used to request/receive item information
- ; +the item
- ; Return values .: Success - True
- ; Failure - False
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......: Gary Frost (gafrost)
- ; Remarks .......: This function is used internally and should not normally be called by the end user
- ; Related .......: __GUICtrlTreeView_SetItem
- ; Link ..........:
- ; Example .......:
- ; ===============================================================================================================================
- Func __GUICtrlTreeView_GetItem($hWnd, ByRef $tItem)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- Local $bUnicode = _GUICtrlTreeView_GetUnicodeFormat($hWnd)
- Local $iRet
- If IsHWnd($hWnd) Then
- If _WinAPI_InProcess($hWnd, $__g_hTVLastWnd) Then
- $iRet = _SendMessage($hWnd, $TVM_GETITEMW, 0, $tItem, 0, "wparam", "struct*")
- Else
- Local $iItem = DllStructGetSize($tItem)
- Local $tMemMap
- Local $pMemory = _MemInit($hWnd, $iItem, $tMemMap)
- _MemWrite($tMemMap, $tItem)
- If $bUnicode Then
- $iRet = _SendMessage($hWnd, $TVM_GETITEMW, 0, $pMemory, 0, "wparam", "ptr")
- Else
- $iRet = _SendMessage($hWnd, $TVM_GETITEMA, 0, $pMemory, 0, "wparam", "ptr")
- EndIf
- _MemRead($tMemMap, $pMemory, $tItem, $iItem)
- _MemFree($tMemMap)
- EndIf
- Else
- Local $pItem = DllStructGetPtr($tItem)
- If $bUnicode Then
- $iRet = GUICtrlSendMsg($hWnd, $TVM_GETITEMW, 0, $pItem)
- Else
- $iRet = GUICtrlSendMsg($hWnd, $TVM_GETITEMA, 0, $pItem)
- EndIf
- EndIf
- Return $iRet <> 0
- EndFunc ;==>__GUICtrlTreeView_GetItem
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......:
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_GetItemByIndex($hWnd, $hItem, $iIndex)
- Local $hResult = _GUICtrlTreeView_GetFirstChild($hWnd, $hItem)
- While ($hResult <> 0x00000000) And ($iIndex > 0)
- $hResult = _GUICtrlTreeView_GetNextSibling($hWnd, $hResult)
- $iIndex -= 1
- WEnd
- Return $hResult
- EndFunc ;==>_GUICtrlTreeView_GetItemByIndex
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Holger Kotsch
- ; Modified.......: Gary Frost (gafrost)
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_GetItemHandle($hWnd, $hItem = 0)
- If $hItem = 0 Then $hItem = 0x00000000
- If IsHWnd($hWnd) Then
- If $hItem = 0x00000000 Then $hItem = _SendMessage($hWnd, $TVM_GETNEXTITEM, $TVGN_ROOT, 0, 0, "wparam", "lparam", "handle")
- Else
- If $hItem = 0x00000000 Then
- $hItem = Ptr(GUICtrlSendMsg($hWnd, $TVM_GETNEXTITEM, $TVGN_ROOT, 0))
- Else
- Local $hTempItem = GUICtrlGetHandle($hItem)
- If $hTempItem <> 0x00000000 Then $hItem = $hTempItem
- EndIf
- EndIf
- Return $hItem
- EndFunc ;==>_GUICtrlTreeView_GetItemHandle
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Gary Frost (gafrost)
- ; Modified.......:
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_GetItemParam($hWnd, $hItem = 0)
- Local $tItem = DllStructCreate($tagTVITEMEX)
- DllStructSetData($tItem, "Mask", $TVIF_PARAM)
- DllStructSetData($tItem, "Param", 0)
- Local $bUnicode = _GUICtrlTreeView_GetUnicodeFormat($hWnd)
- If IsHWnd($hWnd) Then
- ; get the handle to item selected
- If $hItem = 0x00000000 Then $hItem = _SendMessage($hWnd, $TVM_GETNEXTITEM, $TVGN_CARET, 0, 0, "wparam", "lparam", "handle")
- If $hItem = 0x00000000 Then Return 0
- DllStructSetData($tItem, "hItem", $hItem)
- ; get the item properties
- If $bUnicode Then
- If _SendMessage($hWnd, $TVM_GETITEMW, 0, $tItem, 0, "wparam", "struct*") = 0 Then Return 0
- Else
- If _SendMessage($hWnd, $TVM_GETITEMA, 0, $tItem, 0, "wparam", "struct*") = 0 Then Return 0
- EndIf
- Else
- ; get the handle to item selected
- If $hItem = 0x00000000 Then
- $hItem = Ptr(GUICtrlSendMsg($hWnd, $TVM_GETNEXTITEM, $TVGN_CARET, 0))
- If $hItem = 0x00000000 Then Return 0
- Else
- Local $hTempItem = GUICtrlGetHandle($hItem)
- If $hTempItem <> 0x00000000 Then
- $hItem = $hTempItem
- Else
- Return 0
- EndIf
- EndIf
- DllStructSetData($tItem, "hItem", $hItem)
- ; get the item properties
- If $bUnicode Then
- If GUICtrlSendMsg($hWnd, $TVM_GETITEMW, 0, DllStructGetPtr($tItem)) = 0 Then Return 0
- Else
- If GUICtrlSendMsg($hWnd, $TVM_GETITEMA, 0, DllStructGetPtr($tItem)) = 0 Then Return 0
- EndIf
- EndIf
- Return DllStructGetData($tItem, "Param")
- EndFunc ;==>_GUICtrlTreeView_GetItemParam
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......:
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_GetLastChild($hWnd, $hItem)
- Local $hResult = _GUICtrlTreeView_GetFirstChild($hWnd, $hItem)
- If $hResult <> 0x00000000 Then
- Local $hNext = $hResult
- Do
- $hResult = $hNext
- $hNext = _GUICtrlTreeView_GetNextSibling($hWnd, $hNext)
- Until $hNext = 0x00000000
- EndIf
- Return $hResult
- EndFunc ;==>_GUICtrlTreeView_GetLastChild
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Gary Frost (gafrost)
- ; Modified.......:
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_GetLineColor($hWnd)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- Local $sHex = Hex(String(_SendMessage($hWnd, $TVM_GETLINECOLOR)), 6)
- Return '0x' & StringMid($sHex, 5, 2) & StringMid($sHex, 3, 2) & StringMid($sHex, 1, 2)
- EndFunc ;==>_GUICtrlTreeView_GetLineColor
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......: Gary Frost
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_GetNext($hWnd, $hItem)
- If Not IsHWnd($hItem) Then $hItem = _GUICtrlTreeView_GetItemHandle($hWnd, $hItem)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- Local $hResult = 0
- If $hItem <> 0x00000000 And $hItem <> 0 Then
- Local $hNext = _GUICtrlTreeView_GetFirstChild($hWnd, $hItem)
- If $hNext = 0x00000000 Then
- $hNext = _GUICtrlTreeView_GetNextSibling($hWnd, $hItem)
- EndIf
- Local $hParent = $hItem
- While ($hNext = 0x00000000) And ($hParent <> 0x00000000)
- $hParent = _GUICtrlTreeView_GetParentHandle($hWnd, $hParent)
- If $hParent = 0x00000000 Then
- $hNext = 0x00000000
- ExitLoop
- EndIf
- $hNext = _GUICtrlTreeView_GetNextSibling($hWnd, $hParent)
- WEnd
- If $hNext = 0x00000000 Then $hNext = 0
- $hResult = $hNext
- EndIf
- Return $hResult
- EndFunc ;==>_GUICtrlTreeView_GetNext
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Gary Frost (gafrost)
- ; Modified.......:
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_GetNextChild($hWnd, $hItem)
- Return _GUICtrlTreeView_GetNextSibling($hWnd, $hItem)
- EndFunc ;==>_GUICtrlTreeView_GetNextChild
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......: Gary Frost (gafrost)
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_GetNextSibling($hWnd, $hItem)
- If Not IsHWnd($hItem) Then $hItem = _GUICtrlTreeView_GetItemHandle($hWnd, $hItem)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- Return _SendMessage($hWnd, $TVM_GETNEXTITEM, $TVGN_NEXT, $hItem, 0, "wparam", "handle", "handle")
- EndFunc ;==>_GUICtrlTreeView_GetNextSibling
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......: Gary Frost (gafrost)
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_GetNextVisible($hWnd, $hItem)
- If Not IsHWnd($hItem) Then $hItem = _GUICtrlTreeView_GetItemHandle($hWnd, $hItem)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- Return _SendMessage($hWnd, $TVM_GETNEXTITEM, $TVGN_NEXTVISIBLE, $hItem, 0, "wparam", "handle", "handle")
- EndFunc ;==>_GUICtrlTreeView_GetNextVisible
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......: Gary Frost (gafrost)
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_GetNormalImageList($hWnd)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- Return _SendMessage($hWnd, $TVM_GETIMAGELIST, $TVSIL_NORMAL, 0, 0, "wparam", "lparam", "handle")
- EndFunc ;==>_GUICtrlTreeView_GetNormalImageList
- ; #NO_DOC_FUNCTION# =============================================================================================================
- ; Name...........: _GUICtrlTreeView_GetOverlayImageIndex
- ; Description ...: Returns the index of the image from the image list that is used as an overlay mask
- ; Syntax.........: _GUICtrlTreeView_GetOverlayImageIndex ( $hWnd, $hItem )
- ; Parameters ....: $hWnd - Handle to the control
- ; $hItem - Handle to the item
- ; Return values .: Success - Overlay list index
- ; Failure - 0
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......:
- ; Remarks .......:
- ; Related .......: _GUICtrlTreeView_SetOverlayImageIndex
- ; Link ..........:
- ; Example .......:
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_GetOverlayImageIndex($hWnd, $hItem)
- Local $tItem = DllStructCreate($tagTVITEMEX)
- DllStructSetData($tItem, "Mask", $TVIF_STATE)
- DllStructSetData($tItem, "hItem", $hItem)
- DllStructSetData($tItem, "StateMask", $TVIS_OVERLAYMASK)
- __GUICtrlTreeView_GetItem($hWnd, $tItem)
- Return DllStructGetData($tItem, "Image")
- EndFunc ;==>_GUICtrlTreeView_GetOverlayImageIndex
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Gary Frost (gafrost), Holger Kotsch
- ; Modified.......: Gary Frost (gafrost)
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_GetParentHandle($hWnd, $hItem = 0)
- ;If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- If $hItem = 0 Then $hItem = 0x00000000
- ; get the handle to item selected
- If $hItem = 0x00000000 Then
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- $hItem = _SendMessage($hWnd, $TVM_GETNEXTITEM, $TVGN_CARET, 0, 0, "wparam", "handle", "handle")
- If $hItem = 0x00000000 Then Return 0
- Else
- If Not IsHWnd($hItem) Then $hItem = _GUICtrlTreeView_GetItemHandle($hWnd, $hItem)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- EndIf
- ; get the handle of the parent item
- Local $hParent = _SendMessage($hWnd, $TVM_GETNEXTITEM, $TVGN_PARENT, $hItem, 0, "wparam", "handle", "handle")
- Return $hParent
- EndFunc ;==>_GUICtrlTreeView_GetParentHandle
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Gary Frost (gafrost)
- ; Modified.......:
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_GetParentParam($hWnd, $hItem = 0)
- If $hItem = 0 Then $hItem = 0x00000000
- Local $tTVITEM = DllStructCreate($tagTVITEMEX)
- DllStructSetData($tTVITEM, "Mask", $TVIF_PARAM)
- DllStructSetData($tTVITEM, "Param", 0)
- Local $hParent
- If IsHWnd($hWnd) Then
- ; get the handle to item selected
- If $hItem = 0x00000000 Then $hItem = _SendMessage($hWnd, $TVM_GETNEXTITEM, $TVGN_CARET, 0, 0, "wparam", "handle", "handle")
- If $hItem = 0x00000000 Then Return 0
- ; get the handle of the parent item
- $hParent = _SendMessage($hWnd, $TVM_GETNEXTITEM, $TVGN_PARENT, $hItem, 0, "wparam", "handle", "handle")
- DllStructSetData($tTVITEM, "hItem", $hParent)
- ; get the item properties
- If _SendMessage($hWnd, $TVM_GETITEMA, 0, $tTVITEM, 0, "wparam", "struct*") = 0 Then Return False
- Else
- ; get the handle to item selected
- If $hItem = 0x00000000 Then
- $hItem = GUICtrlSendMsg($hWnd, $TVM_GETNEXTITEM, $TVGN_CARET, 0)
- If $hItem = 0x00000000 Then Return 0
- Else
- Local $hTempItem = GUICtrlGetHandle($hItem)
- If $hTempItem <> 0x00000000 Then
- $hItem = $hTempItem
- Else
- Return 0
- EndIf
- EndIf
- ; get the handle of the parent item
- $hParent = GUICtrlSendMsg($hWnd, $TVM_GETNEXTITEM, $TVGN_PARENT, $hItem)
- DllStructSetData($tTVITEM, "hItem", $hParent)
- ; get the item properties
- If GUICtrlSendMsg($hWnd, $TVM_GETITEMA, 0, DllStructGetPtr($tTVITEM)) = 0 Then Return 0
- EndIf
- Return DllStructGetData($tTVITEM, "Param")
- EndFunc ;==>_GUICtrlTreeView_GetParentParam
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......:
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_GetPrev($hWnd, $hItem)
- If Not IsHWnd($hItem) Then $hItem = _GUICtrlTreeView_GetItemHandle($hWnd, $hItem)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- Local $hResult = _GUICtrlTreeView_GetPrevChild($hWnd, $hItem)
- If $hResult <> 0x00000000 Then
- Local $hPrev = $hResult
- Do
- $hResult = $hPrev
- $hPrev = _GUICtrlTreeView_GetLastChild($hWnd, $hPrev)
- Until $hPrev = 0x00000000
- Else
- $hResult = _GUICtrlTreeView_GetParentHandle($hWnd, $hItem)
- EndIf
- Return $hResult
- EndFunc ;==>_GUICtrlTreeView_GetPrev
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......:
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_GetPrevChild($hWnd, $hItem)
- Return _GUICtrlTreeView_GetPrevSibling($hWnd, $hItem)
- EndFunc ;==>_GUICtrlTreeView_GetPrevChild
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......: Gary Frost (gafrost)
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_GetPrevSibling($hWnd, $hItem)
- If Not IsHWnd($hItem) Then $hItem = _GUICtrlTreeView_GetItemHandle($hWnd, $hItem)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- Return _SendMessage($hWnd, $TVM_GETNEXTITEM, $TVGN_PREVIOUS, $hItem, 0, "wparam", "handle", "handle")
- EndFunc ;==>_GUICtrlTreeView_GetPrevSibling
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......: Gary Frost (gafrost)
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_GetPrevVisible($hWnd, $hItem)
- If Not IsHWnd($hItem) Then $hItem = _GUICtrlTreeView_GetItemHandle($hWnd, $hItem)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- Return _SendMessage($hWnd, $TVM_GETNEXTITEM, $TVGN_PREVIOUSVISIBLE, $hItem, 0, "wparam", "handle", "handle")
- EndFunc ;==>_GUICtrlTreeView_GetPrevVisible
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......: Gary Frost (gafrost)
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_GetScrollTime($hWnd)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- Return _SendMessage($hWnd, $TVM_GETSCROLLTIME)
- EndFunc ;==>_GUICtrlTreeView_GetScrollTime
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......:
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_GetSelected($hWnd, $hItem)
- Return BitAND(_GUICtrlTreeView_GetState($hWnd, $hItem), $TVIS_SELECTED) <> 0
- EndFunc ;==>_GUICtrlTreeView_GetSelected
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......: Gary Frost (gafrost)
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_GetSelectedImageIndex($hWnd, $hItem)
- If Not IsHWnd($hItem) Then $hItem = _GUICtrlTreeView_GetItemHandle($hWnd, $hItem)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- Local $tItem = DllStructCreate($tagTVITEMEX)
- DllStructSetData($tItem, "Mask", $TVIF_SELECTEDIMAGE)
- DllStructSetData($tItem, "hItem", $hItem)
- __GUICtrlTreeView_GetItem($hWnd, $tItem)
- Return DllStructGetData($tItem, "SelectedImage")
- EndFunc ;==>_GUICtrlTreeView_GetSelectedImageIndex
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......: Gary Frost (gafrost)
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_GetSelection($hWnd)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- Return _SendMessage($hWnd, $TVM_GETNEXTITEM, $TVGN_CARET, 0, 0, "wparam", "handle", "handle")
- EndFunc ;==>_GUICtrlTreeView_GetSelection
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Gary Frost (gafrost)
- ; Modified.......:
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_GetSiblingCount($hWnd, $hItem)
- If Not IsHWnd($hItem) Then $hItem = _GUICtrlTreeView_GetItemHandle($hWnd, $hItem)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- Local $hNext, $iRet = 0
- Local $hParent = _GUICtrlTreeView_GetParentHandle($hWnd, $hItem)
- If $hParent <> 0x00000000 Then
- $hNext = _GUICtrlTreeView_GetFirstChild($hWnd, $hParent)
- If $hNext = 0x00000000 Then Return -1
- Do
- $iRet += 1
- $hNext = _GUICtrlTreeView_GetNextSibling($hWnd, $hNext)
- Until $hNext = 0x00000000
- Else
- $hNext = _GUICtrlTreeView_GetFirstItem($hWnd)
- If $hNext = 0x00000000 Then Return -1
- Do
- $iRet += 1
- $hNext = _GUICtrlTreeView_GetNextSibling($hWnd, $hNext)
- Until $hNext = 0x00000000
- EndIf
- Return $iRet
- EndFunc ;==>_GUICtrlTreeView_GetSiblingCount
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Holger Kotsch
- ; Modified.......: Gary Frost (gafrost)
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_GetState($hWnd, $hItem = 0)
- If $hItem = 0 Then $hItem = 0x00000000
- $hItem = _GUICtrlTreeView_GetItemHandle($hWnd, $hItem)
- If $hItem = 0x00000000 Then Return SetError(1, 1, 0)
- Local $tTVITEM = DllStructCreate($tagTVITEMEX)
- DllStructSetData($tTVITEM, "Mask", $TVIF_STATE)
- DllStructSetData($tTVITEM, "hItem", $hItem)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- If _WinAPI_InProcess($hWnd, $__g_hTVLastWnd) Then
- _SendMessage($hWnd, $TVM_GETITEMA, 0, $tTVITEM, 0, "wparam", "struct*")
- Else
- Local $iSize = DllStructGetSize($tTVITEM)
- Local $tMemMap
- Local $pMemory = _MemInit($hWnd, $iSize, $tMemMap)
- _MemWrite($tMemMap, $tTVITEM)
- _SendMessage($hWnd, $TVM_GETITEMA, 0, $pMemory)
- _MemRead($tMemMap, $pMemory, $tTVITEM, $iSize)
- _MemFree($tMemMap)
- EndIf
- Return DllStructGetData($tTVITEM, "State")
- EndFunc ;==>_GUICtrlTreeView_GetState
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......: Gary Frost (gafrost)
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_GetStateImageIndex($hWnd, $hItem)
- $hItem = _GUICtrlTreeView_GetItemHandle($hWnd, $hItem)
- Local $tItem = DllStructCreate($tagTVITEMEX)
- DllStructSetData($tItem, "Mask", $TVIF_STATE)
- DllStructSetData($tItem, "hItem", $hItem)
- __GUICtrlTreeView_GetItem($hWnd, $tItem)
- Return BitShift(BitAND(DllStructGetData($tItem, "State"), $TVIS_STATEIMAGEMASK), 12)
- EndFunc ;==>_GUICtrlTreeView_GetStateImageIndex
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......: Gary Frost (gafrost)
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_GetStateImageList($hWnd)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- Return _SendMessage($hWnd, $TVM_GETIMAGELIST, $TVSIL_STATE, 0, 0, "wparam", "handle", "handle")
- EndFunc ;==>_GUICtrlTreeView_GetStateImageList
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......: Gary Frost (gafrost)
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_GetText($hWnd, $hItem = 0)
- If Not IsHWnd($hItem) Then $hItem = _GUICtrlTreeView_GetItemHandle($hWnd, $hItem)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- If $hItem = 0x00000000 Then Return SetError(1, 1, "")
- Local $tTVITEM = DllStructCreate($tagTVITEMEX)
- Local $tText
- Local $bUnicode = _GUICtrlTreeView_GetUnicodeFormat($hWnd)
- If $bUnicode Then
- $tText = DllStructCreate("wchar Buffer[4096]") ; create a text 'area' for receiving the text
- Else
- $tText = DllStructCreate("char Buffer[4096]") ; create a text 'area' for receiving the text
- EndIf
- DllStructSetData($tTVITEM, "Mask", $TVIF_TEXT)
- DllStructSetData($tTVITEM, "hItem", $hItem)
- DllStructSetData($tTVITEM, "TextMax", 4096)
- If _WinAPI_InProcess($hWnd, $__g_hTVLastWnd) Then
- DllStructSetData($tTVITEM, "Text", DllStructGetPtr($tText))
- _SendMessage($hWnd, $TVM_GETITEMW, 0, $tTVITEM, 0, "wparam", "struct*")
- Else
- Local $iItem = DllStructGetSize($tTVITEM)
- Local $tMemMap
- Local $pMemory = _MemInit($hWnd, $iItem + 4096, $tMemMap)
- Local $pText = $pMemory + $iItem
- DllStructSetData($tTVITEM, "Text", $pText)
- _MemWrite($tMemMap, $tTVITEM, $pMemory, $iItem)
- If $bUnicode Then
- _SendMessage($hWnd, $TVM_GETITEMW, 0, $pMemory, 0, "wparam", "ptr")
- Else
- _SendMessage($hWnd, $TVM_GETITEMA, 0, $pMemory, 0, "wparam", "ptr")
- EndIf
- _MemRead($tMemMap, $pText, $tText, 4096)
- _MemFree($tMemMap)
- EndIf
- Return DllStructGetData($tText, "Buffer")
- EndFunc ;==>_GUICtrlTreeView_GetText
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Gary Frost (gafrost)
- ; Modified.......:
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_GetTextColor($hWnd)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- Local $sHex = Hex(String(_SendMessage($hWnd, $TVM_GETTEXTCOLOR)), 6)
- Return '0x' & StringMid($sHex, 5, 2) & StringMid($sHex, 3, 2) & StringMid($sHex, 1, 2)
- EndFunc ;==>_GUICtrlTreeView_GetTextColor
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......: Gary Frost (gafrost)
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_GetToolTips($hWnd)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- Return _SendMessage($hWnd, $TVM_GETTOOLTIPS, 0, 0, 0, "wparam", "lparam", "hwnd")
- EndFunc ;==>_GUICtrlTreeView_GetToolTips
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Gary Frost (gafrost), Holger Kotsch
- ; Modified.......: Gary Frost (gafrost)
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_GetTree($hWnd, $hItem = 0)
- If $hItem = 0 Then
- $hItem = 0x00000000
- Else
- If Not IsHWnd($hItem) Then $hItem = _GUICtrlTreeView_GetItemHandle($hWnd, $hItem)
- EndIf
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- Local $sPath = ""
- If $hItem = 0x00000000 Then $hItem = _SendMessage($hWnd, $TVM_GETNEXTITEM, $TVGN_CARET, 0, 0, "wparam", "handle", "handle")
- If $hItem <> 0x00000000 Then
- $sPath = _GUICtrlTreeView_GetText($hWnd, $hItem)
- Local $hParent, $sSeparator = Opt("GUIDataSeparatorChar")
- Do ; Get now the parent item handle if there is one
- $hParent = _SendMessage($hWnd, $TVM_GETNEXTITEM, $TVGN_PARENT, $hItem, 0, "wparam", "handle", "handle")
- If $hParent <> 0x00000000 Then $sPath = _GUICtrlTreeView_GetText($hWnd, $hParent) & $sSeparator & $sPath
- $hItem = $hParent
- Until $hItem = 0x00000000
- EndIf
- Return $sPath
- EndFunc ;==>_GUICtrlTreeView_GetTree
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......: Gary Frost (gafrost)
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_GetUnicodeFormat($hWnd)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- Return _SendMessage($hWnd, $TVM_GETUNICODEFORMAT) <> 0
- EndFunc ;==>_GUICtrlTreeView_GetUnicodeFormat
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......: Gary Frost (gafrost)
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_GetVisible($hWnd, $hItem)
- If Not IsHWnd($hItem) Then $hItem = _GUICtrlTreeView_GetItemHandle($hWnd, $hItem)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- Local $tRECT = DllStructCreate($tagRECT)
- DllStructSetData($tRECT, "Left", $hItem)
- Local $iRet
- If _WinAPI_InProcess($hWnd, $__g_hTVLastWnd) Then
- $iRet = _SendMessage($hWnd, $TVM_GETITEMRECT, True, $tRECT, 0, "wparam", "struct*")
- Else
- Local $iRect = DllStructGetSize($tRECT)
- Local $tMemMap
- Local $pMemory = _MemInit($hWnd, $iRect, $tMemMap)
- _MemWrite($tMemMap, $tRECT)
- $iRet = _SendMessage($hWnd, $TVM_GETITEMRECT, True, $pMemory, 0, "wparam", "ptr")
- _MemRead($tMemMap, $pMemory, $tRECT, $iRect)
- _MemFree($tMemMap)
- EndIf
- If $iRet = 0 Then Return False ; item is child item, collapsed and not visible
- ; item may not be collapsed or may be at the root level the above will give a rect even it isn't in the view
- ; check to see if it is visible to the eye
- Local $iControlHeight = _WinAPI_GetWindowHeight($hWnd)
- If DllStructGetData($tRECT, "Top") >= $iControlHeight Or _
- DllStructGetData($tRECT, "Bottom") <= 0 Then
- Return False
- Else
- Return True
- EndIf
- EndFunc ;==>_GUICtrlTreeView_GetVisible
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......: Gary Frost (gafrost)
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_GetVisibleCount($hWnd)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- Return _SendMessage($hWnd, $TVM_GETVISIBLECOUNT)
- EndFunc ;==>_GUICtrlTreeView_GetVisibleCount
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......:
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_HitTest($hWnd, $iX, $iY)
- Local $tHitTest = _GUICtrlTreeView_HitTestEx($hWnd, $iX, $iY)
- Local $iFlags = DllStructGetData($tHitTest, "Flags")
- Local $iRet = 0
- If BitAND($iFlags, $TVHT_NOWHERE) <> 0 Then $iRet = BitOR($iRet, 1)
- If BitAND($iFlags, $TVHT_ONITEMICON) <> 0 Then $iRet = BitOR($iRet, 2)
- If BitAND($iFlags, $TVHT_ONITEMLABEL) <> 0 Then $iRet = BitOR($iRet, 4)
- If BitAND($iFlags, $TVHT_ONITEMINDENT) <> 0 Then $iRet = BitOR($iRet, 8)
- If BitAND($iFlags, $TVHT_ONITEMBUTTON) <> 0 Then $iRet = BitOR($iRet, 16)
- If BitAND($iFlags, $TVHT_ONITEMRIGHT) <> 0 Then $iRet = BitOR($iRet, 32)
- If BitAND($iFlags, $TVHT_ONITEMSTATEICON) <> 0 Then $iRet = BitOR($iRet, 64)
- If BitAND($iFlags, $TVHT_ABOVE) <> 0 Then $iRet = BitOR($iRet, 128)
- If BitAND($iFlags, $TVHT_BELOW) <> 0 Then $iRet = BitOR($iRet, 256)
- If BitAND($iFlags, $TVHT_TORIGHT) <> 0 Then $iRet = BitOR($iRet, 512)
- If BitAND($iFlags, $TVHT_TOLEFT) <> 0 Then $iRet = BitOR($iRet, 1024)
- Return $iRet
- EndFunc ;==>_GUICtrlTreeView_HitTest
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......: Gary Frost (gafrost)
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_HitTestEx($hWnd, $iX, $iY)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- Local $tHitTest = DllStructCreate($tagTVHITTESTINFO)
- DllStructSetData($tHitTest, "X", $iX)
- DllStructSetData($tHitTest, "Y", $iY)
- If _WinAPI_InProcess($hWnd, $__g_hTVLastWnd) Then
- _SendMessage($hWnd, $TVM_HITTEST, 0, $tHitTest, 0, "wparam", "struct*")
- Else
- Local $iHitTest = DllStructGetSize($tHitTest)
- Local $tMemMap
- Local $pMemory = _MemInit($hWnd, $iHitTest, $tMemMap)
- _MemWrite($tMemMap, $tHitTest)
- _SendMessage($hWnd, $TVM_HITTEST, 0, $pMemory, 0, "wparam", "ptr")
- _MemRead($tMemMap, $pMemory, $tHitTest, $iHitTest)
- _MemFree($tMemMap)
- EndIf
- Return $tHitTest
- EndFunc ;==>_GUICtrlTreeView_HitTestEx
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......:
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_HitTestItem($hWnd, $iX, $iY)
- Local $tHitTest = _GUICtrlTreeView_HitTestEx($hWnd, $iX, $iY)
- Return DllStructGetData($tHitTest, "Item")
- EndFunc ;==>_GUICtrlTreeView_HitTestItem
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......: Gary Frost (gafrost)
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_Index($hWnd, $hItem)
- If Not IsHWnd($hItem) Then $hItem = _GUICtrlTreeView_GetItemHandle($hWnd, $hItem)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- Local $iRet = -1
- Local $hParent = _GUICtrlTreeView_GetParentHandle($hWnd, $hItem)
- Local $hNext
- If $hParent <> 0x00000000 Then
- $hNext = _GUICtrlTreeView_GetFirstChild($hWnd, $hParent)
- While $hNext <> 0x00000000
- $iRet += 1
- If $hNext = $hItem Then ExitLoop
- $hNext = _GUICtrlTreeView_GetNextSibling($hWnd, $hNext)
- WEnd
- Else
- $hNext = _GUICtrlTreeView_GetFirstItem($hWnd)
- While $hNext <> 0x00000000
- $iRet += 1
- If $hNext = $hItem Then ExitLoop
- $hNext = _GUICtrlTreeView_GetNextSibling($hWnd, $hNext)
- WEnd
- EndIf
- If $hNext = 0x00000000 Then $iRet = -1
- Return $iRet
- EndFunc ;==>_GUICtrlTreeView_Index
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Holger Kotsch
- ; Modified.......: Gary Frost (gafrost)
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_InsertItem($hWnd, $sItem_Text, $hItem_Parent = 0, $hItem_After = 0, $iImage = -1, $iSelImage = -1)
- Local $tTVI = DllStructCreate($tagTVINSERTSTRUCT)
- Local $iBuffer, $pBuffer
- If $sItem_Text <> -1 Then
- $iBuffer = StringLen($sItem_Text) + 1
- Local $tText
- Local $bUnicode = _GUICtrlTreeView_GetUnicodeFormat($hWnd)
- If $bUnicode Then
- $tText = DllStructCreate("wchar Buffer[" & $iBuffer & "]")
- $iBuffer *= 2
- Else
- $tText = DllStructCreate("char Buffer[" & $iBuffer & "]")
- EndIf
- DllStructSetData($tText, "Buffer", $sItem_Text)
- $pBuffer = DllStructGetPtr($tText)
- Else
- $iBuffer = 0
- $pBuffer = -1 ; LPSTR_TEXTCALLBACK
- EndIf
- Local $hItem_tmp
- If $hItem_Parent = 0 Then ; setting to root level
- $hItem_Parent = $TVI_ROOT
- ElseIf Not IsHWnd($hItem_Parent) Then ; control created by autoit create
- $hItem_tmp = _GUICtrlTreeView_GetItemHandle($hWnd, $hItem_Parent)
- If $hItem_tmp Then $hItem_Parent = $hItem_tmp
- EndIf
- If $hItem_After = 0 Then ; using default
- $hItem_After = $TVI_LAST
- ElseIf ($hItem_After <> $TVI_ROOT And _
- $hItem_After <> $TVI_FIRST And _
- $hItem_After <> $TVI_LAST And _
- $hItem_After <> $TVI_SORT) Then ; not using flag
- If Not IsHWnd($hItem_After) Then
- $hItem_tmp = _GUICtrlTreeView_GetItemHandle($hWnd, $hItem_After)
- If Not $hItem_tmp Then ; item not found or invalid flag used
- $hItem_After = $TVI_LAST
- Else ; setting handle
- $hItem_After = $hItem_tmp
- EndIf
- EndIf
- EndIf
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- Local $hIcon
- Local $iMask = $TVIF_TEXT
- If $iImage >= 0 Then
- $iMask = BitOR($iMask, $TVIF_IMAGE)
- $iMask = BitOR($iMask, $TVIF_IMAGE)
- DllStructSetData($tTVI, "Image", $iImage)
- Else
- $hIcon = _GUICtrlTreeView_GetImageListIconHandle($hWnd, 0)
- If $hIcon <> 0x00000000 Then
- $iMask = BitOR($iMask, $TVIF_IMAGE)
- DllStructSetData($tTVI, "Image", 0)
- DllCall("user32.dll", "int", "DestroyIcon", "handle", $hIcon)
- ; No @error test because results are unimportant.
- EndIf
- EndIf
- If $iSelImage >= 0 Then
- $iMask = BitOR($iMask, $TVIF_SELECTEDIMAGE)
- $iMask = BitOR($iMask, $TVIF_SELECTEDIMAGE)
- DllStructSetData($tTVI, "SelectedImage", $iSelImage)
- Else
- $hIcon = _GUICtrlTreeView_GetImageListIconHandle($hWnd, 1)
- If $hIcon <> 0x00000000 Then
- $iMask = BitOR($iMask, $TVIF_SELECTEDIMAGE)
- DllStructSetData($tTVI, "SelectedImage", 0)
- DllCall("user32.dll", "int", "DestroyIcon", "handle", $hIcon)
- ; No @error test because results are unimportant.
- EndIf
- EndIf
- DllStructSetData($tTVI, "Parent", $hItem_Parent)
- DllStructSetData($tTVI, "InsertAfter", $hItem_After)
- DllStructSetData($tTVI, "Mask", $iMask)
- DllStructSetData($tTVI, "TextMax", $iBuffer)
- $iMask = BitOR($iMask, $TVIF_PARAM)
- DllStructSetData($tTVI, "Param", 0)
- Local $hItem
- If _WinAPI_InProcess($hWnd, $__g_hTVLastWnd) Then
- DllStructSetData($tTVI, "Text", $pBuffer)
- $hItem = _SendMessage($hWnd, $TVM_INSERTITEMW, 0, $tTVI, 0, "wparam", "struct*", "handle")
- Else
- Local $iInsert = DllStructGetSize($tTVI)
- Local $tMemMap
- Local $pMemory = _MemInit($hWnd, $iInsert + $iBuffer, $tMemMap)
- If $sItem_Text <> -1 Then
- Local $pText = $pMemory + $iInsert
- DllStructSetData($tTVI, "Text", $pText)
- _MemWrite($tMemMap, $tText, $pText, $iBuffer)
- Else
- DllStructSetData($tTVI, "Text", -1) ; LPSTR_TEXTCALLBACK
- EndIf
- _MemWrite($tMemMap, $tTVI, $pMemory, $iInsert)
- If $bUnicode Then
- $hItem = _SendMessage($hWnd, $TVM_INSERTITEMW, 0, $pMemory, 0, "wparam", "ptr", "handle")
- Else
- $hItem = _SendMessage($hWnd, $TVM_INSERTITEMA, 0, $pMemory, 0, "wparam", "ptr", "handle")
- EndIf
- _MemFree($tMemMap)
- EndIf
- Return $hItem
- EndFunc ;==>_GUICtrlTreeView_InsertItem
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......: Gary Frost (gafrost)
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_IsFirstItem($hWnd, $hItem)
- If Not IsHWnd($hItem) Then $hItem = _GUICtrlTreeView_GetItemHandle($hWnd, $hItem)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- Return _GUICtrlTreeView_GetFirstItem($hWnd) = $hItem
- EndFunc ;==>_GUICtrlTreeView_IsFirstItem
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Gary Frost (gafrost)
- ; Modified.......:
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_IsParent($hWnd, $hParent, $hItem)
- If Not IsHWnd($hParent) Then $hParent = _GUICtrlTreeView_GetItemHandle($hWnd, $hParent)
- If Not IsHWnd($hItem) Then $hItem = _GUICtrlTreeView_GetItemHandle($hWnd, $hItem)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- Return _GUICtrlTreeView_GetParentHandle($hWnd, $hItem) = $hParent
- EndFunc ;==>_GUICtrlTreeView_IsParent
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......:
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_Level($hWnd, $hItem)
- Local $iRet = 0
- Local $hNext = _GUICtrlTreeView_GetParentHandle($hWnd, $hItem)
- While $hNext <> 0x00000000
- $iRet += 1
- $hNext = _GUICtrlTreeView_GetParentHandle($hWnd, $hNext)
- WEnd
- Return $iRet
- EndFunc ;==>_GUICtrlTreeView_Level
- ; #NO_DOC_FUNCTION# =============================================================================================================
- ; Name...........: _GUICtrlTreeView_MapAccIDToItem
- ; Description ...: Maps an accessibility ID to an HTREEITEM
- ; Syntax.........: _GUICtrlTreeView_MapAccIDToItem ( $hWnd, $iID )
- ; Parameters ....: $hWnd - Handle to the control
- ; $iID - Accessibility ID
- ; Return values .: Success - The HTREEITEM that the specified accessibility ID is mapped to
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......: Gary Frost (gafrost)
- ; Remarks .......: Minimum OS Windows XP.
- ; +
- ; When you add an item to a control an HTREEITEM returns, which uniquely identifies the item.
- ; Related .......: _GUICtrlTreeView_MapItemToAccID
- ; Link ..........:
- ; Example .......:
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_MapAccIDToItem($hWnd, $iID)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- Return _SendMessage($hWnd, $TVM_MAPACCIDTOHTREEITEM, $iID, 0, 0, "wparam", "lparam", "handle")
- EndFunc ;==>_GUICtrlTreeView_MapAccIDToItem
- ; #NO_DOC_FUNCTION# =============================================================================================================
- ; Name...........: _GUICtrlTreeView_MapItemToAccID
- ; Description ...: Maps an HTREEITEM to an accessibility ID
- ; Syntax.........: _GUICtrlTreeView_MapItemToAccID ( $hWnd, $hTreeItem )
- ; Parameters ....: $hWnd - Handle to the control
- ; $hTreeItem - HTREEITEM that is mapped to an accessibility ID
- ; Return values .: Success - Returns an accessibility ID
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......: Gary Frost (gafrost)
- ; Remarks .......: Minimum OS Windows XP.
- ; +
- ; When you add an item to a control an HTREEITEM returns, which uniquely identifies the item.
- ; Related .......:
- ; Link ..........:
- ; Example .......:
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_MapItemToAccID($hWnd, $hTreeItem)
- If Not IsHWnd($hTreeItem) Then $hTreeItem = _GUICtrlTreeView_GetItemHandle($hWnd, $hTreeItem)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- Return _SendMessage($hWnd, $TVM_MAPHTREEITEMTOACCID, $hTreeItem, 0, 0, "handle")
- EndFunc ;==>_GUICtrlTreeView_MapItemToAccID
- ; #INTERNAL_USE_ONLY# ===========================================================================================================
- ; Name...........: __GUICtrlTreeView_ReverseColorOrder
- ; Description ...: Convert Hex RGB or BGR Color to Hex RGB or BGR Color
- ; Syntax.........: __GUICtrlTreeView_ReverseColorOrder ( $vColor )
- ; Parameters ....: $vColor - Hex Color
- ; Return values .: Success - Hex RGB or BGR Color
- ; Author ........: Gary Frost (gafrost)
- ; Modified.......:
- ; Remarks .......:
- ; Related .......:
- ; Link ..........:
- ; Example .......:
- ; ===============================================================================================================================
- Func __GUICtrlTreeView_ReverseColorOrder($vColor)
- Local $sHex = Hex(String($vColor), 6)
- Return '0x' & StringMid($sHex, 5, 2) & StringMid($sHex, 3, 2) & StringMid($sHex, 1, 2)
- EndFunc ;==>__GUICtrlTreeView_ReverseColorOrder
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......: Gary Frost (gafrost)
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_SelectItem($hWnd, $hItem, $iFlag = 0)
- If Not IsHWnd($hItem) And $hItem <> 0 Then $hItem = _GUICtrlTreeView_GetItemHandle($hWnd, $hItem)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- If $iFlag = 0 Then $iFlag = $TVGN_CARET
- Return _SendMessage($hWnd, $TVM_SELECTITEM, $iFlag, $hItem, 0, "wparam", "handle") <> 0
- EndFunc ;==>_GUICtrlTreeView_SelectItem
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......:
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_SelectItemByIndex($hWnd, $hItem, $iIndex)
- Return _GUICtrlTreeView_SelectItem($hWnd, _GUICtrlTreeView_GetItemByIndex($hWnd, $hItem, $iIndex))
- EndFunc ;==>_GUICtrlTreeView_SelectItemByIndex
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Gary Frost (gafrost)
- ; Modified.......:
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_SetBkColor($hWnd, $vRGBColor)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- Return __GUICtrlTreeView_ReverseColorOrder(_SendMessage($hWnd, $TVM_SETBKCOLOR, 0, Int(__GUICtrlTreeView_ReverseColorOrder($vRGBColor))))
- EndFunc ;==>_GUICtrlTreeView_SetBkColor
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......:
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_SetBold($hWnd, $hItem, $bFlag = True)
- Return _GUICtrlTreeView_SetState($hWnd, $hItem, $TVIS_BOLD, $bFlag)
- EndFunc ;==>_GUICtrlTreeView_SetBold
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Gary Frost (gafrost
- ; Modified.......:
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_SetChecked($hWnd, $hItem, $bCheck = True)
- If Not IsHWnd($hItem) Then $hItem = _GUICtrlTreeView_GetItemHandle($hWnd, $hItem)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- Local $tItem = DllStructCreate($tagTVITEMEX)
- DllStructSetData($tItem, "Mask", $TVIF_STATE)
- DllStructSetData($tItem, "hItem", $hItem)
- If $bCheck Then
- DllStructSetData($tItem, "State", 0x2000)
- Else
- DllStructSetData($tItem, "State", 0x1000)
- EndIf
- DllStructSetData($tItem, "StateMask", 0xf000)
- Return __GUICtrlTreeView_SetItem($hWnd, $tItem)
- EndFunc ;==>_GUICtrlTreeView_SetChecked
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......: Gary Frost (gafrost)
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_SetCheckedByIndex($hWnd, $hItem, $iIndex, $bCheck = True)
- If Not IsHWnd($hItem) Then $hItem = _GUICtrlTreeView_GetItemHandle($hWnd, $hItem)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- Local $hChild = _GUICtrlTreeView_GetItemByIndex($hWnd, $hItem, $iIndex)
- Return _GUICtrlTreeView_SetChecked($hWnd, $hChild, $bCheck)
- EndFunc ;==>_GUICtrlTreeView_SetCheckedByIndex
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......: Gary Frost (gafrost)
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_SetChildren($hWnd, $hItem, $bFlag = True)
- If Not IsHWnd($hItem) Then $hItem = _GUICtrlTreeView_GetItemHandle($hWnd, $hItem)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- Local $tItem = DllStructCreate($tagTVITEMEX)
- DllStructSetData($tItem, "Mask", BitOR($TVIF_HANDLE, $TVIF_CHILDREN))
- DllStructSetData($tItem, "hItem", $hItem)
- DllStructSetData($tItem, "Children", $bFlag)
- Return __GUICtrlTreeView_SetItem($hWnd, $tItem)
- EndFunc ;==>_GUICtrlTreeView_SetChildren
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......: Gary Frost (gafrost)
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_SetCut($hWnd, $hItem, $bFlag = True)
- If Not IsHWnd($hItem) Then $hItem = _GUICtrlTreeView_GetItemHandle($hWnd, $hItem)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- Return _GUICtrlTreeView_SetState($hWnd, $hItem, $TVIS_CUT, $bFlag)
- EndFunc ;==>_GUICtrlTreeView_SetCut
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......:
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_SetDropTarget($hWnd, $hItem, $bFlag = True)
- If $bFlag Then
- Return _GUICtrlTreeView_SelectItem($hWnd, $hItem, $TVGN_DROPHILITE)
- ElseIf _GUICtrlTreeView_GetDropTarget($hWnd, $hItem) Then
- Return _GUICtrlTreeView_SelectItem($hWnd, 0)
- EndIf
- Return False
- EndFunc ;==>_GUICtrlTreeView_SetDropTarget
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......:
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_SetFocused($hWnd, $hItem, $bFlag = True)
- Return _GUICtrlTreeView_SetState($hWnd, $hItem, $TVIS_FOCUSED, $bFlag)
- EndFunc ;==>_GUICtrlTreeView_SetFocused
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......: Gary Frost (gafrost)
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_SetHeight($hWnd, $iHeight)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- Return _SendMessage($hWnd, $TVM_SETITEMHEIGHT, $iHeight)
- EndFunc ;==>_GUICtrlTreeView_SetHeight
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Holger Kotsch
- ; Modified.......: Gary Frost (gafrost)
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_SetIcon($hWnd, $hItem = 0, $sIconFile = "", $iIconID = 0, $iImageMode = 6)
- If $hItem = 0 Then $hItem = 0x00000000
- If $hItem <> 0x00000000 And Not IsHWnd($hItem) Then $hItem = _GUICtrlTreeView_GetItemHandle($hWnd, $hItem)
- If $hItem = 0x00000000 Or $sIconFile = "" Then Return SetError(1, 1, False)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- Local $tTVITEM = DllStructCreate($tagTVITEMEX)
- Local $tIcon = DllStructCreate("handle")
- Local $aCount = DllCall("shell32.dll", "uint", "ExtractIconExW", "wstr", $sIconFile, "int", $iIconID, _
- "handle", 0, "struct*", $tIcon, "uint", 1)
- If @error Then Return SetError(@error, @extended, 0)
- If $aCount[0] = 0 Then Return 0
- Local $hImageList = _SendMessage($hWnd, $TVM_GETIMAGELIST, 0, 0, 0, "wparam", "lparam", "handle")
- If $hImageList = 0x00000000 Then
- $hImageList = DllCall("comctl32.dll", "handle", "ImageList_Create", "int", 16, "int", 16, "uint", 0x0021, "int", 0, "int", 1)
- If @error Then Return SetError(@error, @extended, 0)
- $hImageList = $hImageList[0]
- If $hImageList = 0 Then Return SetError(1, 1, False)
- _SendMessage($hWnd, $TVM_SETIMAGELIST, 0, $hImageList, 0, "wparam", "handle")
- EndIf
- Local $hIcon = DllStructGetData($tIcon, 1)
- Local $vIcon = DllCall("comctl32.dll", "int", "ImageList_AddIcon", "handle", $hImageList, "handle", $hIcon)
- $vIcon = $vIcon[0]
- If @error Then
- Local $iError = @error, $iExtended = @extended
- DllCall("user32.dll", "int", "DestroyIcon", "handle", $hIcon)
- ; No @error test because results are unimportant.
- Return SetError($iError, $iExtended, 0)
- EndIf
- DllCall("user32.dll", "int", "DestroyIcon", "handle", $hIcon)
- ; No @error test because results are unimportant.
- Local $iMask = BitOR($TVIF_IMAGE, $TVIF_SELECTEDIMAGE)
- If BitAND($iImageMode, 2) Then
- DllStructSetData($tTVITEM, "Image", $vIcon)
- If Not BitAND($iImageMode, 4) Then $iMask = $TVIF_IMAGE
- EndIf
- If BitAND($iImageMode, 4) Then
- DllStructSetData($tTVITEM, "SelectedImage", $vIcon)
- If Not BitAND($iImageMode, 2) Then
- $iMask = $TVIF_SELECTEDIMAGE
- Else
- $iMask = BitOR($TVIF_IMAGE, $TVIF_SELECTEDIMAGE)
- EndIf
- EndIf
- DllStructSetData($tTVITEM, "Mask", $iMask)
- DllStructSetData($tTVITEM, "hItem", $hItem)
- Return __GUICtrlTreeView_SetItem($hWnd, $tTVITEM)
- EndFunc ;==>_GUICtrlTreeView_SetIcon
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......: Gary Frost (gafrost)
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_SetImageIndex($hWnd, $hItem, $iIndex)
- If Not IsHWnd($hItem) Then $hItem = _GUICtrlTreeView_GetItemHandle($hWnd, $hItem)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- Local $tItem = DllStructCreate($tagTVITEMEX)
- DllStructSetData($tItem, "Mask", BitOR($TVIF_HANDLE, $TVIF_IMAGE))
- DllStructSetData($tItem, "hItem", $hItem)
- DllStructSetData($tItem, "Image", $iIndex)
- Return __GUICtrlTreeView_SetItem($hWnd, $tItem)
- EndFunc ;==>_GUICtrlTreeView_SetImageIndex
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Gary Frost (gafrost)
- ; Modified.......:
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_SetIndent($hWnd, $iIndent)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- _SendMessage($hWnd, $TVM_SETINDENT, $iIndent)
- EndFunc ;==>_GUICtrlTreeView_SetIndent
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......: Gary Frost (gafrost)
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_SetInsertMark($hWnd, $hItem, $bAfter = True)
- If Not IsHWnd($hItem) And $hItem <> 0 Then $hItem = _GUICtrlTreeView_GetItemHandle($hWnd, $hItem)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- Return _SendMessage($hWnd, $TVM_SETINSERTMARK, $bAfter, $hItem, 0, "wparam", "handle") <> 0
- EndFunc ;==>_GUICtrlTreeView_SetInsertMark
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......: Gary Frost (gafrost)
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_SetInsertMarkColor($hWnd, $iColor)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- Return _SendMessage($hWnd, $TVM_SETINSERTMARKCOLOR, 0, $iColor)
- EndFunc ;==>_GUICtrlTreeView_SetInsertMarkColor
- ; #INTERNAL_USE_ONLY# ===========================================================================================================
- ; Name...........: __GUICtrlTreeView_SetItem
- ; Description ...: Sets some or all of a items attributes
- ; Syntax.........: __GUICtrlTreeView_SetItem ( $hWnd, ByRef $tItem )
- ; Parameters ....: $hWnd - Handle to the control
- ; $tItem - $tagTVITEMEX structure that contains the new item attributes
- ; Return values .: Success - True
- ; Failure - False
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......: Gary Frost (gafrost)
- ; Remarks .......: This function is used internally and should not normally be called by the end user
- ; Related .......: __GUICtrlTreeView_GetItem
- ; Link ..........:
- ; Example .......:
- ; ===============================================================================================================================
- Func __GUICtrlTreeView_SetItem($hWnd, ByRef $tItem)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- Local $bUnicode = _GUICtrlTreeView_GetUnicodeFormat($hWnd)
- Local $iRet
- If _WinAPI_InProcess($hWnd, $__g_hTVLastWnd) Then
- $iRet = _SendMessage($hWnd, $TVM_SETITEMW, 0, $tItem, 0, "wparam", "struct*")
- Else
- Local $iItem = DllStructGetSize($tItem)
- Local $tMemMap
- Local $pMemory = _MemInit($hWnd, $iItem, $tMemMap)
- _MemWrite($tMemMap, $tItem)
- If $bUnicode Then
- $iRet = _SendMessage($hWnd, $TVM_SETITEMW, 0, $pMemory, 0, "wparam", "ptr")
- Else
- $iRet = _SendMessage($hWnd, $TVM_SETITEMA, 0, $pMemory, 0, "wparam", "ptr")
- EndIf
- _MemFree($tMemMap)
- EndIf
- Return $iRet <> 0
- EndFunc ;==>__GUICtrlTreeView_SetItem
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......:
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_SetItemHeight($hWnd, $hItem, $iIntegral)
- If Not IsHWnd($hItem) Then $hItem = _GUICtrlTreeView_GetItemHandle($hWnd, $hItem)
- _GUICtrlTreeView_BeginUpdate($hWnd)
- Local $tItem = DllStructCreate($tagTVITEMEX)
- DllStructSetData($tItem, "Mask", BitOR($TVIF_HANDLE, $TVIF_INTEGRAL))
- DllStructSetData($tItem, "hItem", $hItem)
- DllStructSetData($tItem, "Integral", $iIntegral)
- Local $bResult = __GUICtrlTreeView_SetItem($hWnd, $tItem)
- _GUICtrlTreeView_EndUpdate($hWnd)
- Return $bResult
- EndFunc ;==>_GUICtrlTreeView_SetItemHeight
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Gary Frost (gafrost)
- ; Modified.......:
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_SetItemParam($hWnd, $hItem, $iParam)
- If Not IsHWnd($hItem) Then $hItem = _GUICtrlTreeView_GetItemHandle($hWnd, $hItem)
- Local $tItem = DllStructCreate($tagTVITEMEX)
- DllStructSetData($tItem, "Mask", BitOR($TVIF_HANDLE, $TVIF_PARAM))
- DllStructSetData($tItem, "hItem", $hItem)
- DllStructSetData($tItem, "Param", $iParam)
- Local $bResult = __GUICtrlTreeView_SetItem($hWnd, $tItem)
- Return $bResult
- EndFunc ;==>_GUICtrlTreeView_SetItemParam
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Gary Frost (gafrost)
- ; Modified.......:
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_SetLineColor($hWnd, $vRGBColor)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- Return __GUICtrlTreeView_ReverseColorOrder(_SendMessage($hWnd, $TVM_SETLINECOLOR, 0, Int(__GUICtrlTreeView_ReverseColorOrder($vRGBColor))))
- EndFunc ;==>_GUICtrlTreeView_SetLineColor
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......: Gary Frost (gafrost)
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_SetNormalImageList($hWnd, $hImageList)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- Return _SendMessage($hWnd, $TVM_SETIMAGELIST, $TVSIL_NORMAL, $hImageList, 0, "wparam", "handle", "handle")
- EndFunc ;==>_GUICtrlTreeView_SetNormalImageList
- ; #NO_DOC_FUNCTION# =============================================================================================================
- ; Name...........: _GUICtrlTreeView_SetOverlayImageIndex
- ; Description ...: Sets the index into image list for the state image
- ; Syntax.........: _GUICtrlTreeView_SetOverlayImageIndex ( $hWnd, $hItem, $iIndex )
- ; Parameters ....: $hWnd - Handle to the control
- ; $hItem - Handle to the item
- ; $iIndex - Image list index
- ; Return values .: Success - True
- ; Failure - False
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......: Gary Frost (gafrost)
- ; Remarks .......:
- ; Related .......: _GUICtrlTreeView_GetOverlayImageIndex
- ; Link ..........:
- ; Example .......:
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_SetOverlayImageIndex($hWnd, $hItem, $iIndex)
- If Not IsHWnd($hItem) Then $hItem = _GUICtrlTreeView_GetItemHandle($hWnd, $hItem)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- Local $tItem = DllStructCreate($tagTVITEMEX)
- DllStructSetData($tItem, "Mask", BitOR($TVIF_HANDLE, $TVIF_STATE))
- DllStructSetData($tItem, "hItem", $hItem)
- DllStructSetData($tItem, "State", BitShift($iIndex, -8))
- DllStructSetData($tItem, "StateMask", $TVIS_OVERLAYMASK)
- Return __GUICtrlTreeView_SetItem($hWnd, $tItem)
- EndFunc ;==>_GUICtrlTreeView_SetOverlayImageIndex
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......: Gary Frost (gafrost)
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_SetScrollTime($hWnd, $iTime)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- Return _SendMessage($hWnd, $TVM_SETSCROLLTIME, $iTime)
- EndFunc ;==>_GUICtrlTreeView_SetScrollTime
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......:
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_SetSelected($hWnd, $hItem, $bFlag = True)
- Return _GUICtrlTreeView_SetState($hWnd, $hItem, $TVIS_SELECTED, $bFlag)
- EndFunc ;==>_GUICtrlTreeView_SetSelected
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......: Gary Frost (gafrost)
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_SetSelectedImageIndex($hWnd, $hItem, $iIndex)
- If Not IsHWnd($hItem) Then $hItem = _GUICtrlTreeView_GetItemHandle($hWnd, $hItem)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- Local $tItem = DllStructCreate($tagTVITEMEX)
- DllStructSetData($tItem, "Mask", BitOR($TVIF_HANDLE, $TVIF_SELECTEDIMAGE))
- DllStructSetData($tItem, "hItem", $hItem)
- DllStructSetData($tItem, "SelectedImage", $iIndex)
- Return __GUICtrlTreeView_SetItem($hWnd, $tItem)
- EndFunc ;==>_GUICtrlTreeView_SetSelectedImageIndex
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Holger Kotsch
- ; Modified.......: Gary Frost (gafrost)
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_SetState($hWnd, $hItem, $iState = 0, $bSetState = True)
- If Not IsHWnd($hItem) Then $hItem = _GUICtrlTreeView_GetItemHandle($hWnd, $hItem)
- If $hItem = 0x00000000 Or ($iState = 0 And $bSetState = False) Then Return False
- Local $tTVITEM = DllStructCreate($tagTVITEMEX)
- If @error Then Return SetError(1, 1, 0)
- DllStructSetData($tTVITEM, "Mask", $TVIF_STATE)
- DllStructSetData($tTVITEM, "hItem", $hItem)
- If $bSetState Then
- DllStructSetData($tTVITEM, "State", $iState)
- Else
- DllStructSetData($tTVITEM, "State", BitAND($bSetState, $iState))
- EndIf
- DllStructSetData($tTVITEM, "StateMask", $iState)
- If $bSetState Then DllStructSetData($tTVITEM, "StateMask", BitOR($bSetState, $iState))
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- Return __GUICtrlTreeView_SetItem($hWnd, $tTVITEM)
- EndFunc ;==>_GUICtrlTreeView_SetState
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......: Gary Frost (gafrost)
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_SetStateImageIndex($hWnd, $hItem, $iIndex)
- If Not IsHWnd($hItem) Then $hItem = _GUICtrlTreeView_GetItemHandle($hWnd, $hItem)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- If $iIndex < 0 Then
- ; Invalid index for State Image" & @LF & "State Image List is One-based list
- Return SetError(1, 0, False)
- EndIf
- Local $tItem = DllStructCreate($tagTVITEMEX)
- DllStructSetData($tItem, "Mask", $TVIF_STATE)
- DllStructSetData($tItem, "hItem", $hItem)
- DllStructSetData($tItem, "State", BitShift($iIndex, -12))
- DllStructSetData($tItem, "StateMask", $TVIS_STATEIMAGEMASK)
- Return __GUICtrlTreeView_SetItem($hWnd, $tItem)
- EndFunc ;==>_GUICtrlTreeView_SetStateImageIndex
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Gary Frost (gafrost)
- ; Modified.......:
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_SetStateImageList($hWnd, $hImageList)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- ; haven't figured out why but the state image list appears to use a 1 based index
- ; add and icon
- _GUIImageList_AddIcon($hImageList, "shell32.dll", 0)
- Local $iCount = _GUIImageList_GetImageCount($hImageList)
- ; shift it to the zero index, won't be used
- For $x = $iCount - 1 To 1 Step -1
- _GUIImageList_Swap($hImageList, $x, $x - 1)
- Next
- Return _SendMessage($hWnd, $TVM_SETIMAGELIST, $TVSIL_STATE, $hImageList, 0, "wparam", "handle", "handle")
- EndFunc ;==>_GUICtrlTreeView_SetStateImageList
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Holger Kotsch
- ; Modified.......: Gary Frost (gafrost)
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_SetText($hWnd, $hItem = 0, $sText = "")
- If Not IsHWnd($hItem) Then $hItem = _GUICtrlTreeView_GetItemHandle($hWnd, $hItem)
- If $hItem = 0x00000000 Or $sText = "" Then Return SetError(1, 1, 0)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- Local $tTVITEM = DllStructCreate($tagTVITEMEX)
- Local $iBuffer = StringLen($sText) + 1
- Local $tBuffer
- Local $bUnicode = _GUICtrlTreeView_GetUnicodeFormat($hWnd)
- If $bUnicode Then
- $tBuffer = DllStructCreate("wchar Buffer[" & $iBuffer & "]")
- $iBuffer *= 2
- Else
- $tBuffer = DllStructCreate("char Buffer[" & $iBuffer & "]")
- EndIf
- DllStructSetData($tBuffer, "Buffer", $sText)
- DllStructSetData($tTVITEM, "Mask", BitOR($TVIF_HANDLE, $TVIF_TEXT))
- DllStructSetData($tTVITEM, "hItem", $hItem)
- DllStructSetData($tTVITEM, "TextMax", $iBuffer)
- Local $bResult
- If _WinAPI_InProcess($hWnd, $__g_hTVLastWnd) Then
- DllStructSetData($tTVITEM, "Text", DllStructGetPtr($tBuffer))
- $bResult = _SendMessage($hWnd, $TVM_SETITEMW, 0, $tTVITEM, 0, "wparam", "struct*")
- Else
- Local $iItem = DllStructGetSize($tTVITEM)
- Local $tMemMap
- Local $pMemory = _MemInit($hWnd, $iItem + $iBuffer, $tMemMap)
- Local $pText = $pMemory + $iItem
- DllStructSetData($tTVITEM, "Text", $pText)
- _MemWrite($tMemMap, $tTVITEM, $pMemory, $iItem)
- _MemWrite($tMemMap, $tBuffer, $pText, $iBuffer)
- If $bUnicode Then
- $bResult = _SendMessage($hWnd, $TVM_SETITEMW, 0, $pMemory, 0, "wparam", "ptr")
- Else
- $bResult = _SendMessage($hWnd, $TVM_SETITEMA, 0, $pMemory, 0, "wparam", "ptr")
- EndIf
- _MemFree($tMemMap)
- EndIf
- Return $bResult <> 0
- EndFunc ;==>_GUICtrlTreeView_SetText
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Gary Frost (gafrost)
- ; Modified.......:
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_SetTextColor($hWnd, $vRGBColor)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- Return __GUICtrlTreeView_ReverseColorOrder(_SendMessage($hWnd, $TVM_SETTEXTCOLOR, 0, Int(__GUICtrlTreeView_ReverseColorOrder($vRGBColor))))
- EndFunc ;==>_GUICtrlTreeView_SetTextColor
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......: Gary Frost (gafrost)
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_SetToolTips($hWnd, $hToolTip)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- Return _SendMessage($hWnd, $TVM_SETTOOLTIPS, $hToolTip, 0, 0, "wparam", "int", "hwnd")
- EndFunc ;==>_GUICtrlTreeView_SetToolTips
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Paul Campbell (PaulIA)
- ; Modified.......: Gary Frost (gafrost)
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_SetUnicodeFormat($hWnd, $bFormat = True)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- Return _SendMessage($hWnd, $TVM_SETUNICODEFORMAT, $bFormat)
- EndFunc ;==>_GUICtrlTreeView_SetUnicodeFormat
- ; #FUNCTION# ====================================================================================================================
- ; Author ........: Gary Frost (gafrost)
- ; Modified.......: mlipok, guinness, gillesg
- ; ===============================================================================================================================
- Func _GUICtrlTreeView_Sort($hWnd)
- If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
- Local $iItemCount = _GUICtrlTreeView_GetCount($hWnd)
- If $iItemCount Then
- Local $aTreeView[$iItemCount], $i = 0
- ; get only A child at each level
- Local $hHandle = _GUICtrlTreeView_GetFirstItem($hWnd)
- $aTreeView[1] = $hHandle
- $aTreeView[0] = 2
- __GUICtrlTreeView_SortGetFirstChild($hWnd, $hHandle, $aTreeView)
- ReDim $aTreeView[$aTreeView[0]]
- $aTreeView[0] = 0
- For $i = 0 To UBound($aTreeView) - 1
- _SendMessage($hWnd, $TVM_SORTCHILDREN, 0, $aTreeView[$i], 0, "wparam", "handle") ; Sort the items in root
- Next
- EndIf
- EndFunc ;==>_GUICtrlTreeView_Sort
- ; #INTERNAL_USE_ONLY# ===========================================================================================================
- ; Name...........: __GUICtrlTreeView_SortGetFirstChild
- ; Description ...: Sets some or all of a items attributes
- ; Syntax.........: __GUICtrlTreeView_SortGetFirstChild ( $hWnd, $hItem, ByRef $aTreeView )
- ; Parameters ....: $hWnd - Handle to the control
- ; $hItem - Handle to the item
- ; $aTreeView - Byref array to store first chidren handles
- ; Return values .: None
- ; Author ........: gillesg
- ; Modified.......:
- ; Remarks .......: This function is used internally and should not normally be called by the end user
- ; Related .......:
- ; Link ..........: https://www.autoitscript.com/trac/autoit/ticket/3585
- ; Example .......:
- ; ===============================================================================================================================
- Func __GUICtrlTreeView_SortGetFirstChild($hWnd, $hItem, ByRef $aTreeView)
- Local $hChild = _GUICtrlTreeView_GetFirstChild($hWnd, $hItem)
- If $hChild <> 0 Then
- $aTreeView[$aTreeView[0]] = $hChild
- $aTreeView[0] += 1
- __GUICtrlTreeView_SortGetFirstChild($hWnd, $hChild, $aTreeView)
- EndIf
- Local $hNext = _GUICtrlTreeView_GetNextSibling($hWnd, $hItem)
- If $hNext <> 0 Then __GUICtrlTreeView_SortGetFirstChild($hWnd, $hNext, $aTreeView)
- EndFunc ;==>__GUICtrlTreeView_SortGetFirstChild
|