>#define Grid_WIDTH_Border 1 >#define Grid_WIDTH_RecordMark iif(this.Recordmark, 10, 0) >#define Grid_WIDTH_DeleteMark iif(this.DeleteMark, 8, 0) >#define Grid_WIDTH_Scrollbar iif(inlist(this.ScrollBars,SCROLLBARS_VERTICAL,SCROLLBARS_BOTH), ; > sysmetric(SYSMETRIC_VSCROLLBARWIDTH), ; > 0 ; > ) >#define Grid_WIDTH_Offset (Grid_WIDTH_RecordMark + Grid_WIDTH_DeleteMark + Grid_WIDTH_Border) > >#define Grid_WIDTH_SplitBar iif(this.SplitBar and this.Partition > 0, 1, 0) > >*-------------------------------------------- > >#define TRUE .T. >#define FALSE .F. > >** DisplayHeaders > >local LockScreen, i, obj > >if( ( this.ColumnCount <= 0 ) ; > or empty(this.Columns[1].ControlCount) ; > ) > *or ( this.Columns[1].Header1.Class <> '_header' ) ; > ) > return && moved, resize >endif > >LockScreen = thisform.LockScreen >thisform.LockScreen = TRUE > >&& columnOrders >local h[this.ColumnCount,3] > >for i = 1 to this.ColumnCount > obj = this.Columns[i] > > > obj.Visible = !empty(obj.Width) > > h[i,1] = obj.ColumnOrder > h[i,2] = obj && column > > h[i,3] = iif(obj.Header1.Class == '_header', obj._Header_node, Null) > *h[i,4] = obj.ControlSource >endfor > >=Asort(h) > > >&& Panels >local np, Panels[2,3] >np = iif(this.Partition = 0, 1, 2) > > && Left >Panels[1,1] = this.Left + Grid_WIDTH_Offset > && Width >Panels[1,2] = iif( np = 1, this.Width - Grid_WIDTH_Border, this.Partition + Grid_WIDTH_SplitBar) - Grid_WIDTH_Scrollbar - Grid_WIDTH_Offset > && LeftColumn >if( (np = 1) or empty(this.Panel) ) > Panels[1,3] = this.LeftColumn >else > this.Panel = 0 > Panels[1,3] = this.LeftColumn > this.Panel = 1 >endif > >if( np > 1 ) > Panels[2,1] = this.Left + this.Partition + Grid_WIDTH_Offset > Panels[2,2] = this.Width - Grid_WIDTH_Scrollbar - Grid_WIDTH_Offset - this.Partition - Grid_WIDTH_SplitBar > if( empty(this.Panel) ) > this.Panel = 1 > Panels[2,3] = this.LeftColumn > this.Panel = 0 > else > Panels[2,3] = this.LeftColumn > endif >else > Panels[2,1] = 0 > Panels[2,2] = 0 > Panels[2,3] = 999999 >endif > > >&& process panels > >local _Top, _Height, _Width, _left >_Top = this.Top + 1 >_height = this.HeaderHeight -1 - 1 > >local p, _Col, obj, _hdr, nObjects, AvailableWidth, ColWidth >local objWidth, objHeight, objTop, objLeft > > >for p = 1 to 2 > _left = Panels[p,1] > _width = Panels[p,2] > > for i = 1 to this.ColumnCount > > _col = h[i,2] > > > do case > case !_Col.Visible > ColWidth = 0 > case (i < Panels[p,3]) > colWidth = -1 > otherwise > ColWidth = _Col.Width > endcase > > > if( !isNull(h[i,3]) ) > _hdr = h[i,3] > > nObjects = _hdr.ControlCount > > AvailableWidth = min(_Width, _Col.Width) > > for j = 1 to nObjects > obj = _hdr.Controls[j].Child[p] > > if( (AvailableWidth > 0) and (ColWidth > 0) ) > if( isnull(obj) or (type('obj') <> T_OBJECT) ) && gone, Form destroy or release > thisform.LockScreen = LockScreen > return > endif > > objWidth = int(min(obj.Max_Width, min(AvailableWidth, ColWidth ) / nObjects)) > objHeight = min(_height, obj.Max_Height) > > && bottom Align > objTop = _Top + _height - objHeight > > && there are two options > && (1): squeeze > && (2): if outside available width, do not display > && take option (1) > objLeft = _left + (AvailableWidth - objWidth)* obj.Alignment > > obj.Move(objLeft, objTop, objWidth, objHeight ) > obj.VisibleRange = TRUE > else > obj.VisibleRange = FALSE > endif > endfor > endif > > _Left = _left + ColWidth + 1 > _Width = _Width - ColWidth - 1 > endfor >endfor > >thisform.LockScreen = LockScreen > >>