//***************************************************************************************** // Copyright (c) 2000 Michael Kurz // All rights reserved. // If you want to use this source in your applications conatct: // // $FileName : cTreeViewEx.pkg // $ProjectName : Shared Classes // $Author : Michael Kurz // $Created : 03-13-2001 @ 19:00 // // Contents: // An extended TreeView class which allows to add items with bitmaps direct by bmp name // and with an dynamic_update_state that is working. // Also is implemented setting and getting of the ScrollPosition. // // $Rev History // //***************************************************************************************** Use DFTreeVw.Pkg Use mVerifyVDFVersion.Pkg // Soll checken welche VDF Version. Define TVM_SETBKCOLOR For (TV_FIRST + 29) Define TVM_SETTEXTCOLOR For (TV_FIRST + 30) #IFDEF GET_GetScrollPos #ELSE external_function GetScrollPos "GetScrollPos" USER32.DLL Handle hwnd Integer iBar Returns Integer #ENDIF #IFDEF GET_SetScrollPos #ELSE external_function SetScrollPos "SetScrollPos" USER32.DLL Handle hwnd Integer iBar Integer iPos Integer iRedraw Returns Integer #ENDIF #IFDEF isVersionVDF7 TYPE TV_INSERTSTRUCT Field TV_INSERTSTRUCT.hParent as Handle Field TV_INSERTSTRUCT.hInsertAfter as Handle Field TV_INSERTSTRUCT.TV_ITEM.mask as Dword Field TV_INSERTSTRUCT.TV_ITEM.hItem as Handle Field TV_INSERTSTRUCT.TV_ITEM.state as Dword Field TV_INSERTSTRUCT.TV_ITEM.stateMask as Dword Field TV_INSERTSTRUCT.TV_ITEM.pszText as Pointer Field TV_INSERTSTRUCT.TV_ITEM.cchTextMax as Dword Field TV_INSERTSTRUCT.TV_ITEM.iImage as Dword Field TV_INSERTSTRUCT.TV_ITEM.iSelectedImage as Dword Field TV_INSERTSTRUCT.TV_ITEM.cChildren as Dword Field TV_INSERTSTRUCT.TV_ITEM.lParam as Dword END_TYPE #ENDIF Use cImageListEx.Pkg Class cTreeViewEx Is a TreeView Procedure Construct_Object Forward Send Construct_Object // Set External_Class_Name 'cTreeViewEx' To 'SysTreeView32' Property Integer piRedrawState Public True Property Integer Floating_Menu_Object Public 0 End_Procedure // Sorts the items of a treeview. Procedure SortItems Integer hBaseNode Integer iRecursive Integer iRet Move (SendMessage(Window_Handle(Self),TVM_SORTCHILDREN,iRecursive,hBaseNode)) To iRet End_Procedure // Set Current Item when mouse down. (Useful when Drag Items) Procedure Mouse_Down Integer iT Forward Send Mouse_Down iT Set CurrentTreeItem To (ItemHitTest(Self)) End_Procedure // Set Current Item when mouse down. // And Start PopupMenu when entered. Procedure Mouse_Down2 Integer iT Forward Send Mouse_Down2 iT Set CurrentTreeItem To (ItemHitTest(Self)) If (Floating_Menu_Object(Self)) Send Popup To (Floating_Menu_Object(Self)) End_Procedure // Iserts a TreeItem to this parent after hAfter. Function InsertTreeItem String sValue Handle hAfter Handle hParent Integer iItemData Integer iImage Integer iSelImage Returns Handle Pointer lpsStruct pszValue pVoid String sStruct ZeroType TV_INSERTSTRUCT To sStruct GetAddress Of sStruct To lpsStruct Move (sValue+Character(0)) To sValue GetAddress Of sValue To pszValue Move (OemToAnsi(pszValue,pszValue)) To pVoid Put (TVIF_TEXT + TVIF_PARAM +TVIF_IMAGE+TVIF_SELECTEDIMAGE) ; To sStruct At TV_INSERTSTRUCT.TV_ITEM.mask Put hAfter To sStruct At TV_INSERTSTRUCT.hInsertAfter Put pszValue To sStruct At TV_INSERTSTRUCT.TV_ITEM.pszText Put iItemData To sStruct At TV_INSERTSTRUCT.TV_ITEM.lParam Put iImage To sStruct At TV_INSERTSTRUCT.TV_ITEM.iImage Put iSelImage To sStruct At TV_INSERTSTRUCT.TV_ITEM.iSelectedImage Put hParent To sStruct At TV_INSERTSTRUCT.hParent Function_Return (WindowsMessage(TVM_INSERTITEM, 0, lpsStruct)) End_Function // Delivers the Item Nr of an Image. Function BmpToImageNr String sBmp Returns Integer Integer hoImgLst iRet Get ImageListObject To hoImgLst Get Msg_ImageListEx_Add Of hoImgLst sBmp To iRet Function_Return iRet End_Function // Sets the ItemImage via a Bitmap string. Procedure Set ItemBitmap Integer iItem String sBmp Integer iImg Get BmpToImageNr sBmp To iImg Set ItemImage iItem To iImg End_Procedure // Sets the ItemImage via a Bitmap string. Procedure Set ItemSelectedBitmap Integer iItem String sBmp Integer iImg Get BmpToImageNr sBmp To iImg Set ItemSelectedImage iItem To iImg End_Procedure // Adding Items with Images by Name. (Which are automatically inserted // into the ImageList (need to be a cImageListEx) Function InsertTreeItemEx String sLabel Integer hAfter Integer hParent Integer iUserInfo String sBmp String sBmpSel Returns Integer Integer hoImgLst iBmp iBmpSel Get ImageListObject To hoImgLst Move -1 To iBmp Move -1 To iBmpSel If hoImgLst Begin If sBmp Ne "" Get Msg_ImageListEx_Add Of hoImgLst sBmp To iBmp If sBmpSel Ne "" Get Msg_ImageListEx_Add Of hoImgLst sBmpSel To iBmpSel End Function_Return (InsertTreeItem(Self,sLabel,hAfter,hParent,iUserInfo,iBmp,iBmpSel)) End_Function // Adds a item with the ability to use the BMP as string. Function AddTreeItemEx String sLabel Integer hParent Integer iUserInfo String sBmp String sBmpSel Returns Integer Function_Return (InsertTreeItemEx(Self,sLabel,TVI_LAST,hParent,iUserInfo,sBmp,sBmpSel)) End_Function // Set and get the scrollposition. Function CurrScrollPos Integer iBar Returns Integer Function_Return (GetScrollPos(Window_Handle(Self),iBar)) End_Function Procedure Set CurrScrollPos Integer iPos Integer iBar Integer iRet Move (SetScrollPos(Window_Handle(Self),iBar,iPos,True)) To iRet End_Procedure // Implementing Dyn.Update.State with using WM_SETREDRAW Procedure Page Integer iFlag Set Window_Style TVS_DISABLEDRAGDROP To False Forward Send Page iFlag End_Procedure End_Class