Sort When Click On DataWindow Column Title In PowerBuilder. Ex: In Event DataWindow Click Call Funct

Global Type f_dw_sort From function_object
End Type

Forward Prototypes
Global Subroutine f_dw_sort (datawindow adw)
End Prototypes

Global Subroutine f_dw_sort (datawindow adw);
//====================================================================
// Function: f_dw_sort()
//--------------------------------------------------------------------
// Description: Sort When Click On Title Column
//--------------------------------------------------------------------
// Arguments:
// 	value	datawindow	adw
//--------------------------------------------------------------------
// Returns:  (none)
//====================================================================


String ls_col, ls_sort, ls_old
Long   li_pos
Long ll_X1, ll_Y1, ll_X2, ll_Y2, ll_X3, ll_x4, ll_Y3, ll_Y4
String ls_Mod


If adw.RowCount() < 1 Then Return

adw.SetRedraw( False )

//get old sort
ls_old = adw.Object.datawindow.Table.Sort

//get column click on
ls_col = adw.GetObjectAtPointer()

li_pos = Pos(ls_col,'~t')
ls_col = Left(ls_col, li_pos - 1)

If Not Lower(Right(ls_col,2)) = "_t" Then
	adw.SetRedraw( True )
	Return
End If

ls_Mod = "Destroy sort_ln1 Destroy sort_ln2 Destroy sort_ln3"
adw.Modify( ls_Mod )

ls_col = Left(ls_col, Len(ls_col) - 2)

ll_X1 = Long( adw.Describe( ls_col + '_t.X' ) ) + 5
ll_Y1 = Long( adw.Describe( ls_col + '_t.Y' ) ) + 3

ll_X2 = PixelsToUnits( UnitsToPixels( ll_X1, XUnitsToPixels! ) + 4, XPixelsToUnits! )
ll_X3 = PixelsToUnits( UnitsToPixels( ll_X1, XUnitsToPixels! ) + 3, XPixelsToUnits! )
ll_x4 = PixelsToUnits( UnitsToPixels( ll_X1, XUnitsToPixels! ) + 8, XPixelsToUnits! )
ll_Y2 = PixelsToUnits( UnitsToPixels( ll_Y1, YUnitsToPixels! ) + 4, YPixelsToUnits! )
ll_Y3 = PixelsToUnits( UnitsToPixels( ll_Y1, YUnitsToPixels! ) + 5, YPixelsToUnits! )
ll_Y4 = PixelsToUnits( UnitsToPixels( ll_Y1, YUnitsToPixels! ) - 1, YPixelsToUnits! )

ls_sort = ls_col + " A"

If ls_sort = ls_old Then
	ls_sort = ls_col + " D"

	ls_Mod = 'create line(band=header x1="' + String( ll_X1 ) &
		+ '" y1="' + String( ll_Y2 ) &
		+ '" x2="' + String( ll_x4 ) + '" y2="' + String( ll_Y2 ) &
		+ '" pen.style="0" pen.width="5" ' &
		+ 'pen.color="1089522856"  background.mode="2" ' &
		+ 'background.color="16777215" name=sort_ln1 )'

	ls_Mod += ' create line(band=header x1="' + String( ll_X1 ) &
		+ '" y1="' + String( ll_Y2 ) &
		+ '" x2="' + String( ll_X2 ) + '" y2="' + String( ll_Y1 ) &
		+ '" pen.style="0" pen.width="5" ' &
		+ 'pen.color="33554432"  background.mode="2" ' &
		+ 'background.color="16777215" name=sort_ln2 )'

	ls_Mod += ' create line(band=header x1="' + String( ll_x4 ) &
		+ '" y1="' + String( ll_Y2 ) &
		+ '" x2="' + String( ll_X3 ) + '" y2="' &
		+ String( ll_Y4 ) + '" pen.style="0" pen.width="5" ' &
		+ 'pen.color="1089522856"  background.mode="2" ' &
		+ 'background.color="16777215" name=sort_ln3 )'

Else
	ls_sort = ls_col + " A"

	ls_Mod = 'create line(band=header x1="' + String( ll_X1 ) &
		+ '" y1="' + String( ll_Y1 ) &
		+ '" x2="' + String( ll_x4 ) + '" y2="' &
		+ String( ll_Y1 ) + '" pen.style="0" pen.width="5" ' &
		+ 'pen.color="33554432"  background.mode="2" ' &
		+ 'background.color="16777215" name=sort_ln1 )'

	ls_Mod += ' create line(band=header x1="' + String( ll_X1 ) &
		+ '" y1="' + String( ll_Y1 ) &
		+ '" x2="' + String( ll_X2 ) + '" y2="' &
		+ String( ll_Y2 ) + '" pen.style="0" pen.width="5" ' &
		+ 'pen.color="33554432"  background.mode="2" ' &
		+ 'background.color="16777215" name=sort_ln2 )'

	ls_Mod += ' create line(band=header x1="' + String( ll_x4 ) &
		+ '" y1="' + String( ll_Y1 ) &
		+ '" x2="' + String( ll_X3 ) + '" y2="' &
		+ String( ll_Y3 ) + '" pen.style="0" pen.width="5" ' &
		+ 'pen.color="1089522856"  background.mode="2" ' &
		+ 'background.color="16777215" name=sort_ln3 )'

End If

// Create the triangle
adw.Modify( ls_Mod )

adw.SetSort(ls_sort)
adw.Sort()

adw.SetRedraw( True )

Return

End Subroutine

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值