// **************************************************************************** // // ** ** // // ** Class : cListColumn ** // // ** ** // // ** Purpose : Creates cList columns, automatically adding columns to the ** // // ** ListBox and Header controls. ** // // ** ** // // ** Author : Ulbe Stellema ** // // ** Data Access Europe ** // // ** ** // // ** Date : januari 25, 2002 ** // // ** ** // // **************************************************************************** // Use cGrid.hdr Class cListColumn Is A Message // Procedure : Construct_Object // Purpose : Object constructor Procedure Construct_Object Forward Send Construct_Object // Column properties Property Integer peWrapStyle wsWrap Property Integer peAlignment alLeft Property Boolean pbResize True // This single integer property can be used to store // information about what is displayed in the column // for example a date, an agenda etc. Property Integer piData // Header properties Property String psHeaderLabel "" Property String psHeaderBitmap "" Property Integer peHeaderAlignment alLeft Property Integer peHeaderBitmapAlignment alLeft Property Integer piHeaderImage -1 Property Integer pfHeaderFormat 0 // Wrapped public properties Property Integer Private.piWidth 0 Set Focus_Mode To NonFocusable End_Procedure // Construct_Object // Procedure : End_Construct_Object // Purpose : End object constructor Procedure End_Construct_Object Handle hoObject Forward Send End_Construct_Object // Register item in collection (parent should be a cList) Move Self To hoObject Delegate Send Private.RegisterItem hoObject End_Procedure // End_Construct_Object // Procedure : Destroy_Object // Purpose : Object destructor Procedure Destroy_Object Handle hoObject Integer iIndex Move Self To hoObject If (hoObject <> 0) Begin // Delete header column //Get IndexFromObject hoObject To iIndex Send Private.DeleteHeaderColumn iIndex // Unregister object Delegate Send Private.UnregisterItem hoObject End // If (hoObject <> 0) Begin Forward Send Destroy_Object End_Procedure // Destroy_Object // Procedure : Set piWidth // Purpose : Sets the width of the list column Procedure Set piWidth Integer iWidth Integer iItems iCount iResult Set Private.piWidth To iWidth // Get ItemCount To iItems // For iCount From 0 To (iItems-1) // Move (SendMessage(Window_Handle(phoList(Self)),LB_SETITEMHEIGHT,iCount,ItemHeight(phoList(Self),iCount))) To iResult // Loop // For iCount From 0 To (iItems-1) End_Procedure // piWidth // Function : piWidth // Purpose : Returns the width of the list column Function piWidth Returns Integer Function_Return (Private.piWidth(Self)) End_Function // piWidth // Procedure : Private.InsertHeaderColumn // Purpose : Inserts a column in the Header control Procedure Private.InsertHeaderColumn Integer iPos String sItem sLabel sBitmap Integer iResult iMask iFormat Handle hWindow hBitmap // Get the window handle of the header control Move (Window_Handle(phoHeader(Self))) To hWindow ZeroType HDITEM To sItem // Handle label If (psHeaderLabel(Self) <> "") Move (psHeaderLabel(Self)) To sLabel // Handle bitmap If (psHeaderBitmap(Self) <> "") Begin Move (psHeaderBitmap(Self)) To sBitmap Move (LoadImage(0,sBitmap,IMAGE_BITMAP,0,0,LR_LOADFROMFILE)) To hBitmap End // If (psHeaderBitmap(Self) <> "") Begin // Format flags If (peHeaderAlignment(Self) = alLeft) Move (iFormat iOr HDF_LEFT) To iFormat If (peHeaderAlignment(Self) = alRight) Move (iFormat iOr HDF_RIGHT) To iFormat If (peHeaderAlignment(Self) = alCenter) Move (iFormat iOr HDF_CENTER) To iFormat If (sBitmap <> "") Move (iFormat iOr HDF_BITMAP) To iFormat If (sLabel <> "") Move (iFormat iOr HDF_STRING) To iFormat If (peHeaderBitmapAlignment(Self) = alRight) Move (iFormat iOr HDF_BITMAP_ON_RIGHT) To iFormat If (piHeaderImage(Self) <> -1) Move (iFormat iOr HDF_IMAGE) To iFormat // Windows XP //If (peHeaderSortBitmap(Self) = bmSortDown) Move (iFormat iOr HDF_SORTDOWN) To iFormat //If (peHeaderSortBitmap(Self) = bmSortUp) Move (iFormat iOr HDF_SORTUP) To iFormat // Mask flags Move (HDI_LPARAM iOr HDI_FORMAT) To iMask If (psHeaderBitmap(Self) <> "") Move (iMask Ior HDI_BITMAP) To iMask If (piHeaderImage(Self) <> -1) Move (iMask Ior HDI_IMAGE) To iMask If (psHeaderLabel(Self) <> "") Move (iMask Ior HDI_TEXT) To iMask If (piWidth(Self) <> 0) Move (iMask iOr HDI_WIDTH) To iMask Put iMask To sItem at HDITEM.mask Put (piWidth(Self)) To sItem at HDITEM.cxy Put (AddressOf(sLabel)) To sItem at HDITEM.pszText Put hBitmap To sItem at HDITEM.hbm Put (Length(sLabel)) To sItem at HDITEM.cchTextMax Put iFormat To sItem at HDITEM.fmt Put Self To sItem at HDITEM.lParam Put (piHeaderImage(Self)) To sItem at HDITEM.iImage Move (SendMessage(hWindow,HDM_INSERTITEMA,9999,AddressOf(sItem))) To iResult End_Procedure // Private.InsertHeaderColumn // Procedure : Private.InsertHeaderColumn // Purpose : Deletes a column in the Header control Procedure Private.DeleteHeaderColumn Integer iPos Integer iResult Handle hWindow If (Object_Id(phoHeader(Self))) ; Move (Window_Handle(phoHeader(Self))) To hWindow If hWindow Move (SendMessage(hWindow,HDM_DELETEITEM,iPos,0)) To iResult End_Procedure // Private.DeleteHeaderColumn // Procedure : Private.InsertListColumn // Purpose : Inserts a column in the ListBox control Procedure Private.InsertListColumn Integer iColumn Set ColumnWidth iColumn To (piWidth(Self)) End_Procedure // Private.InsertListColumn End_Class // cListColumn