$PBExportHeader$u_dw_rbtnfilter2.sru
forward
global type u_dw_rbtnfilter2 from datawindow
end type
type pointapi from structure within u_dw_rbtnfilter2
end type
end forward

type pointapi from structure
	long		x
	long		y
end type

global type u_dw_rbtnfilter2 from datawindow
integer width = 1010
integer height = 316
integer taborder = 10
boolean livescroll = true
borderstyle borderstyle = stylelowered!
event ue_after_filter ( )
event dwnkey pbm_dwnkey
event rbbutton ( string arg_type,  string arg_name,  string arg_data,  long arg_row )
end type
global u_dw_rbtnfilter2 u_dw_rbtnfilter2

type prototypes
FUNCTION long GetCursorPos(ref POINTAPI lpPoint) library 'user32.dll' alias for "GetCursorPos;Ansi" 
end prototypes

type variables
boolean  RBUTTON_FILTER_USE=false
boolean  RBUTTON_SETPOSITION_USE=false
boolean  titleclick_sort_USE=false
boolean  setcolumn_visible_USE= true //false

boolean  autosave_FILTER_USE= true //false
boolean  autosave_sort_USE= true //false
boolean  autosave_setlayout_USE= true //false
boolean  autosave_columnvisible_USE= true //false

string ins_INIfile_name=''
string ins_opemp=''
long cardw_empid

string cur_DataObject = ''
string curDW_filterstr=''
string curDW_sortstr='' 
string ins_mdfstr_column_visible=''
string ins_mdfstr_column_width=''
string ins_mdfstr_column_x=''

long arg_ins_xpos
long arg_ins_ypos
string arg_ins_dwtype
string arg_ins_dwname
string arg_ins_dwdata
long arg_ins_dwrow


boolean arg_SetPosition = false
string arg_Positionstr=''

end variables

forward prototypes
public function integer uf_string_deal (s_esq_tran arg_esq_tran, string column_name)
public function integer uf_decimal_deal (s_esq_tran arg_esq_tran, string column_name)
public function integer uf_datetime_deal (s_esq_tran arg_esq_tran, string column_name)
public function integer uf_string_deal_setp (s_esq_tran arg_esq_tran, string column_name)
end prototypes

event ue_after_filter();this.triggerevent(rowfocuschanged!)






end event

event rbbutton(string arg_type, string arg_name, string arg_data, long arg_row);String str_clickedobjecttype
String column_name,column_text_name
if arg_row<1 then return
IF rbutton_filter_use THEN
	String cur_data,ls_title
	
		str_clickedobjecttype = Lower(Left(arg_type,4))
	IF str_clickedobjecttype <> 'colu' THEN
		IF str_clickedobjecttype = 'data' THEN
			curdw_filterstr = ''
			THIS.SetFilter('')
			THIS.SetRedraw (FALSE)
			THIS.Filter()
			THIS.SetRedraw (TRUE)
		END IF
		GOTO csort
	END IF
	
	s_esq_tran ls_esq_tran
	pointapi lppoint1
	column_name = arg_name
	
	IF getcursorpos(lppoint1) <> 0  THEN
		ls_esq_tran.X = PixelsToUnits(lppoint1.X, xpixelstounits!)
		ls_esq_tran.Y = PixelsToUnits(lppoint1.Y, ypixelstounits!)
	ELSE
		environment   exerun_env
		GetEnvironment(exerun_env )
		ls_esq_tran.X = arg_ins_xpos +THIS.X + ( PixelsToUnits(exerun_env.ScreenWidth, xpixelstounits!) - THIS.Width ) / 2
		ls_esq_tran.Y = arg_ins_ypos +THIS.Y + ( PixelsToUnits(exerun_env.ScreenHeight, xpixelstounits!) - THIS.Height) / 2.5
	END IF
	
	ls_esq_tran.cur_filter_expr = curdw_filterstr
	ls_title = THIS.Describe(column_name+ "_t.text")
	
	IF ls_title = "!" THEN ls_title = ''
	column_name = arg_name
	ls_esq_tran.Title = ls_title
	
	IF arg_row > 0 THEN
		cur_data = String(arg_data)
	END IF	
	
	//分别处理不同类型
	CHOOSE CASE Left( THIS.Describe( arg_name+ ".coltype"),4)
		CASE "char"
			ls_esq_tran.cur_data = cur_data
			If (uf_string_deal(ls_esq_tran,column_name)) = 0 THEN RETURN
		CASE "date","time"
			ls_esq_tran.dt_data = DateTime(Date(Left(cur_data,10)),Time(Right(cur_data,8)))
			If (uf_datetime_deal(ls_esq_tran,column_name)) = 0 THEN RETURN
		CASE ELSE
			ls_esq_tran.num_data = dec(cur_data)
			If (uf_decimal_deal(ls_esq_tran,column_name)) = 0 THEN RETURN
	END CHOOSE
	
	THIS.SetFilter(curdw_filterstr)
	
	THIS.SetRedraw (FALSE)
	THIS.Filter()
	THIS.TriggerEvent("ue_after_filter")
	THIS.SetRedraw (TRUE)
END IF

csort:

IF titleclick_sort_use THEN
	str_clickedobjecttype = Left(arg_type,4)
	
	IF str_clickedobjecttype = 'text' THEN
		column_text_name = arg_name
		
		IF Len(column_text_name) >= 3 AND Right(column_text_name,2) = '_t' THEN
			column_name = Left(column_text_name,Len(column_text_name) - 2)
		ELSE
			GOTO cend
		END IF
		
		IF Left(Describe(column_name+'.type'),4) <> 'colu' AND &
			Left(Describe(column_name+'.type'),4) <> 'comp' THEN
			RETURN
		END IF
		IF curDW_sortstr = column_name+' A ' THEN
			curDW_sortstr = column_name+' D '
		ELSE
			curDW_sortstr = column_name+' A '
		END IF
		
	ELSE
		curDW_sortstr = ''
	END IF
	
	IF curDW_sortstr <> '' THEN
		THIS.SetSort(curDW_sortstr)
		THIS.SetRedraw (FALSE)
		THIS.Sort()
		THIS.SetRedraw (TRUE)
	END IF
END IF

cend:
//IF THIS.RowCount() > 0 THEN
//	THIS.SetRow(1)
//	THIS.ScrollToRow(1)
//	THIS.SelectRow(0,FALSE)
//	THIS.SelectRow(1,TRUE)
//END IF




end event

public function integer uf_string_deal (s_esq_tran arg_esq_tran, string column_name);//uf_string_deal
OpenWithParm(w_publ_inputexpr,arg_esq_tran)
arg_esq_tran = Message.PowerObjectParm

CHOOSE CASE arg_esq_tran.comp_op
	CASE '包含'
		arg_esq_tran.comp_op = ' LIKE '
	CASE '不包含'
		arg_esq_tran.comp_op = ' NOT LIKE '
	CASE '等于'
		arg_esq_tran.comp_op = ' = '
	CASE '不等于'
		arg_esq_tran.comp_op = ' <> '
	CASE '大于'
		arg_esq_tran.comp_op = ' > '
	CASE '小于'
		arg_esq_tran.comp_op = ' < '
	CASE '大于等于'
		arg_esq_tran.comp_op = ' >= '
	CASE '小于等于'
		arg_esq_tran.comp_op = ' <= '
END CHOOSE

IF arg_esq_tran.return_flag = 4 THEN
	IF NOT arg_esq_tran.DIST_BOOLEAN THEN
		arg_Positionstr = "pos(upper("+column_name+"), '"+Upper(arg_esq_tran.cur_data)+"') > 0 "
	ELSE
		arg_Positionstr = "pos("+column_name+", '"+arg_esq_tran.cur_data+"') > 0 "
	END IF
	arg_SetPosition = TRUE
ELSE
	
	IF arg_esq_tran.comp_op = ' LIKE ' OR arg_esq_tran.comp_op = ' NOT LIKE ' THEN
		IF Pos(arg_esq_tran.cur_data,'%') = 0 THEN
			IF Trim(arg_esq_tran.cur_data) = '' THEN
				arg_esq_tran.cur_data = '%'
			ELSE
				arg_esq_tran.cur_data = '%'+arg_esq_tran.cur_data+'%'
			END IF
		END IF
	END IF
	
	arg_SetPosition = FALSE
//	IF Pos(arg_esq_tran.cur_data,'%') = 0 THEN
//		IF Trim(arg_esq_tran.cur_data) = '' THEN
//			arg_esq_tran.cur_data = '%'
//		ELSE
//			arg_esq_tran.cur_data = '%'+arg_esq_tran.cur_data+'%'
//		END IF
//	END IF
	
	CHOOSE CASE arg_esq_tran.return_flag
		CASE 0
			RETURN 0
		CASE 1
//			IF arg_esq_tran.cur_data = '' THEN
//				IF Trim(curDW_filterstr) = '' THEN RETURN 1
//				IF NOT arg_esq_tran.DIST_BOOLEAN THEN
//					curDW_filterstr = "( UPPER("+column_name+" ) " + arg_esq_tran.comp_op +  " UPPER('"+arg_esq_tran.cur_data+"')) "
//				ELSE
//					curDW_filterstr = "( "+column_name + arg_esq_tran.comp_op + " '"+arg_esq_tran.cur_data+"') "
//				END IF
//				
//			ELSE
				IF Trim(curDW_filterstr) = '' THEN
					IF NOT arg_esq_tran.DIST_BOOLEAN THEN
						curDW_filterstr = "( UPPER("+column_name+" ) "  + arg_esq_tran.comp_op + " UPPER('"+arg_esq_tran.cur_data+"')) "
					ELSE
						curDW_filterstr = "( "+column_name + arg_esq_tran.comp_op + " '"+arg_esq_tran.cur_data+"' )"
					END IF
				ELSE
					
					IF NOT arg_esq_tran.DIST_BOOLEAN THEN
						curDW_filterstr = curDW_filterstr+" and ( UPPER("+column_name+" ) "  + arg_esq_tran.comp_op + " UPPER('"+arg_esq_tran.cur_data+"')) "
					ELSE
						curDW_filterstr = curDW_filterstr+" and ( "+column_name + arg_esq_tran.comp_op + " '"+arg_esq_tran.cur_data+"' )"
					END IF
					
				END IF
//			END IF
		CASE 2
//			IF arg_esq_tran.cur_data = '' THEN
//				IF Trim(curDW_filterstr) = '' THEN RETURN 1
//				curDW_filterstr = ''
//			ELSE
				IF NOT arg_esq_tran.DIST_BOOLEAN THEN
					curDW_filterstr = "( UPPER("+column_name+" ) "  + arg_esq_tran.comp_op + " UPPER('"+arg_esq_tran.cur_data+"')) "
				ELSE
					curDW_filterstr = "("+column_name + arg_esq_tran.comp_op + " '"+arg_esq_tran.cur_data+"') "
				END IF
//			END IF
			
		CASE ELSE
			RETURN 0
	END CHOOSE
END IF
RETURN 1







end function

public function integer uf_decimal_deal (s_esq_tran arg_esq_tran, string column_name);//uf_decimal_deal
OpenWithParm(w_publ_input_num,arg_esq_tran)
arg_esq_tran = Message.PowerObjectParm

Boolean lb_ifarea
lb_ifarea = arg_esq_tran.if_area //---是否按范围选择

IF lb_ifarea = FALSE THEN
	CHOOSE CASE arg_esq_tran.return_flag
		CASE 0
			RETURN 0
		CASE 1 //补充
			IF Trim(curDW_filterstr) = '' THEN
				curDW_filterstr = '('+column_name+arg_esq_tran.comp_op+String(arg_esq_tran.num_data)+")"
				IF arg_esq_tran.ELSE_BOOLEAN THEN curDW_filterstr = ' ( NOT '+curDW_filterstr +') '
			ELSE
				IF arg_esq_tran.ELSE_BOOLEAN THEN
					curDW_filterstr = curDW_filterstr+" and ( NOT "+column_name+arg_esq_tran.comp_op+String(arg_esq_tran.num_data)+") "
				ELSE
					curDW_filterstr = curDW_filterstr+" and ( "+column_name+arg_esq_tran.comp_op+String(arg_esq_tran.num_data)+") "
				END IF
				
			END IF
		CASE 2 //新查询
			curDW_filterstr = '('+column_name+arg_esq_tran.comp_op+String(arg_esq_tran.num_data)+")"
			IF arg_esq_tran.ELSE_BOOLEAN THEN curDW_filterstr = '( NOT '+curDW_filterstr +')'
			
		CASE ELSE
			
	END CHOOSE
ELSE
	CHOOSE CASE arg_esq_tran.return_flag
		CASE 0
			RETURN 0
		CASE 1 //补充
			IF Trim(curDW_filterstr) = '' THEN
				curDW_filterstr = '('+column_name+arg_esq_tran.comp_op+String(arg_esq_tran.num_data)+' and '+ column_name+arg_esq_tran.comp_opb+String(arg_esq_tran.num_datab)+")"
				IF arg_esq_tran.ELSE_BOOLEAN THEN curDW_filterstr = ' ( NOT '+curDW_filterstr +') '
			ELSE
				IF arg_esq_tran.ELSE_BOOLEAN THEN
					curDW_filterstr = curDW_filterstr+" and ( NOT "+column_name+arg_esq_tran.comp_op+String(arg_esq_tran.num_data)+' and '+ column_name+arg_esq_tran.comp_opb+String(arg_esq_tran.num_datab)+") "
				ELSE
					curDW_filterstr = curDW_filterstr+" and ( "+column_name+arg_esq_tran.comp_op+String(arg_esq_tran.num_data)+' and '+ column_name+arg_esq_tran.comp_opb+String(arg_esq_tran.num_datab)+") "
				END IF
				
			END IF
		CASE 2 //新查询
			curDW_filterstr = '('+column_name+arg_esq_tran.comp_op+String(arg_esq_tran.num_data)+' and '+ column_name+arg_esq_tran.comp_opb+String(arg_esq_tran.num_datab)+")"
			IF arg_esq_tran.ELSE_BOOLEAN THEN curDW_filterstr = '( NOT '+curDW_filterstr +')'
			
		CASE ELSE
			
	END CHOOSE	
END IF

RETURN 1
end function

public function integer uf_datetime_deal (s_esq_tran arg_esq_tran, string column_name);//////////////////////////////////////////////////////////////////////////// //
//uf_datetime_deal(arg_esq_tran,column_name)
//右键查询 - 时间
//修改人：谢莫锋
//时间：2003-06-11
//参数：arg_esq_tran：结构参数，column_name：列名
///////////////////////////////////////////////////////////////////////////////

String ls_enddate
String ls_firstdate
String ls_enddate_end
String ls_firstdate_end
String ls_firstdate_area
String ls_enddate_area
Long ls_timeinuse,ls_timeinuse_end
Boolean lb_ifarea = FALSE

OpenWithParm(w_publ_input_datetime,arg_esq_tran)
arg_esq_tran = Message.PowerObjectParm

ls_timeinuse = arg_esq_tran.b_timeinuse //---时间有效标记
ls_timeinuse_end = arg_esq_tran.b_timeinuse_end //---时间有效标记

lb_ifarea = arg_esq_tran.if_area //---是否按范围选择

IF lb_ifarea = FALSE THEN
	IF ls_timeinuse = 1 THEN //1.如果时间有效的时候
		CHOOSE CASE arg_esq_tran.return_flag
			CASE 0
				RETURN 0
			CASE 1 //补充
				IF Trim(curdw_filterstr) = '' THEN
					curdw_filterstr = '('+column_name+arg_esq_tran.comp_op+String(arg_esq_tran.dt_data,'yyyy-mm-dd hh:mm:ss')+")"
					IF arg_esq_tran.else_boolean THEN
						curdw_filterstr = ' ( not '+curdw_filterstr +') '
					END IF
				ELSE
					IF arg_esq_tran.else_boolean THEN
						curdw_filterstr = curdw_filterstr+" and ( not "+column_name+arg_esq_tran.comp_op+String(arg_esq_tran.dt_data,'yyyy-mm-dd hh:mm:ss')+") "
					ELSE
						curdw_filterstr = curdw_filterstr+" and ( "+column_name+arg_esq_tran.comp_op+String(arg_esq_tran.dt_data,'yyyy-mm-dd hh:mm:ss')+") "
					END IF
				END IF
			CASE 2 //新查询
				curdw_filterstr = '('+column_name+arg_esq_tran.comp_op+String(arg_esq_tran.dt_data,'yyyy-mm-dd hh:mm:ss')+")"
				IF arg_esq_tran.else_boolean THEN
					curdw_filterstr = '( not '+curdw_filterstr +')'
				END IF
			CASE ELSE
		END CHOOSE
	ELSE //--------2.如果时间无效的时候	
		ls_firstdate = String(arg_esq_tran.dt_data,'yyyy-mm-dd hh:mm:ss') //一天的开始时间
		ls_enddate = String(DateTime(Date(arg_esq_tran.dt_data),Time('23:59:59')),'yyyy-mm-dd hh:mm:ss') //一天的结束时间
		
		
		
		CHOOSE CASE arg_esq_tran.return_flag
			CASE 0
				RETURN 0
			CASE 1 //补充
				IF Trim(curdw_filterstr) = '' THEN
					IF arg_esq_tran.comp_op = '=' THEN
						curdw_filterstr = '('+column_name+'>='+ls_firstdate+' and '+column_name+'<='+ls_enddate+')'
					ELSEIF arg_esq_tran.comp_op = '>' THEN
						curdw_filterstr = '('+column_name+'>'+ls_enddate+')'
					ELSEIF arg_esq_tran.comp_op = '>=' THEN
						curdw_filterstr = '('+column_name+'>'+ls_firstdate+')'
					ELSEIF arg_esq_tran.comp_op = '<' THEN
						curdw_filterstr = '('+column_name+'<'+ls_firstdate+')'
					ELSEIF arg_esq_tran.comp_op = '<=' THEN
						curdw_filterstr = '('+column_name+'<='+ls_enddate+')'
					END IF
					IF arg_esq_tran.else_boolean THEN curdw_filterstr = '( not '+curdw_filterstr +')'
				ELSE //不为空的时候
					IF arg_esq_tran.comp_op = '=' THEN
						IF arg_esq_tran.else_boolean THEN
							curdw_filterstr = curdw_filterstr+' and not ('+column_name+'>='+ls_firstdate+' and '+column_name+'<='+ls_enddate+')'
						ELSE
							curdw_filterstr = curdw_filterstr+' and ('+column_name+'>='+ls_firstdate+' and '+column_name+'<='+ls_enddate+')'
						END IF
					ELSEIF arg_esq_tran.comp_op = '>' THEN
						IF arg_esq_tran.else_boolean THEN
							curdw_filterstr = curdw_filterstr+' and not ('+column_name+'>'+ls_enddate+')'
						ELSE
							curdw_filterstr = curdw_filterstr+' and ('+column_name+'>'+ls_enddate+')'
						END IF
					ELSEIF arg_esq_tran.comp_op = '>=' THEN
						IF arg_esq_tran.else_boolean THEN
							curdw_filterstr = curdw_filterstr+' and not ('+column_name+'>'+ls_firstdate+')'
						ELSE
							curdw_filterstr = curdw_filterstr+' and ('+column_name+'>'+ls_firstdate+')'
						END IF
					ELSEIF arg_esq_tran.comp_op = '<' THEN
						IF arg_esq_tran.else_boolean THEN
							curdw_filterstr = curdw_filterstr+' and not ('+column_name+'<'+ls_firstdate+')'
						ELSE
							curdw_filterstr = curdw_filterstr+' and ('+column_name+'<'+ls_firstdate+')'
						END IF
					ELSEIF arg_esq_tran.comp_op = '<=' THEN
						IF arg_esq_tran.else_boolean THEN
							curdw_filterstr = curdw_filterstr+' and not ('+column_name+'<='+ls_enddate+')'
						ELSE
							curdw_filterstr = curdw_filterstr+' and ('+column_name+'<='+ls_enddate+')'
						END IF
					END IF
				END IF
			CASE 2 //新查询
				IF arg_esq_tran.comp_op = '=' THEN
					curdw_filterstr = '('+column_name+'>='+ls_firstdate+' and '+column_name+'<='+ls_enddate+')'
				ELSEIF arg_esq_tran.comp_op = '>' THEN
					curdw_filterstr = '('+column_name+'>'+ls_enddate+')'
				ELSEIF arg_esq_tran.comp_op = '>=' THEN
					curdw_filterstr = '('+column_name+'>'+ls_firstdate+')'
				ELSEIF arg_esq_tran.comp_op = '<' THEN
					curdw_filterstr = '('+column_name+'<'+ls_firstdate+')'
				ELSEIF arg_esq_tran.comp_op = '<=' THEN
					curdw_filterstr = '('+column_name+'<='+ls_enddate+')'
				END IF
				IF arg_esq_tran.else_boolean THEN curdw_filterstr = '( not '+curdw_filterstr +')'
			CASE ELSE
		END CHOOSE
	END IF
ELSE
	ls_firstdate = String(arg_esq_tran.dt_data,'yyyy-mm-dd hh:mm:ss') //一天的开始时间
	
	ls_firstdate_end = String(arg_esq_tran.dt_date_end,'yyyy-mm-dd hh:mm:ss') //一天的开始时间
	ls_enddate_end = String(DateTime(Date(arg_esq_tran.dt_date_end),Time('23:59:59')),'yyyy-mm-dd hh:mm:ss') //一天的结束时间
	
	ls_firstdate_area = 	ls_firstdate
	
	IF ls_timeinuse_end = 1 THEN
		ls_enddate_area = 	ls_firstdate_end
	ELSE
		ls_enddate_area = 	ls_enddate_end
	END IF
	
	CHOOSE CASE arg_esq_tran.return_flag
		CASE 0
			RETURN 0
		CASE 1 //补充
			IF Trim(curdw_filterstr) = '' THEN
				curdw_filterstr = '('+column_name+'>='+ls_firstdate_area+' and '+column_name+'<='+ls_enddate_area+")"
				IF arg_esq_tran.else_boolean THEN
					curdw_filterstr = ' ( not '+curdw_filterstr +') '
				END IF
			ELSE
				IF arg_esq_tran.else_boolean THEN
					curdw_filterstr = curdw_filterstr+" and not ( "+column_name+'>='+ls_firstdate_area+' and '+column_name+'<='+ls_enddate_area+")"
				ELSE
					curdw_filterstr = curdw_filterstr+" and ( "+column_name+'>='+ls_firstdate_area+' and '+column_name+'<='+ls_enddate_area+")"
				END IF
			END IF
		CASE 2 //新查询
			curdw_filterstr = '('+column_name+'>='+ls_firstdate_area+' and '+column_name+'<='+ls_enddate_area+")"
			IF arg_esq_tran.else_boolean THEN
				curdw_filterstr = '( not '+curdw_filterstr +')'
			END IF
		CASE ELSE
	END CHOOSE
END IF

RETURN 1
end function

public function integer uf_string_deal_setp (s_esq_tran arg_esq_tran, string column_name);//uf_string_deal_setp
OpenWithParm(w_publ_input_expr_posi,arg_esq_tran)
arg_esq_tran = Message.PowerObjectParm

IF arg_esq_tran.return_flag = 4 THEN
	IF NOT arg_esq_tran.DIST_BOOLEAN THEN
		arg_Positionstr = "pos(upper("+column_name+"), '"+Upper(arg_esq_tran.cur_data)+"') > 0 "
	ELSE
		arg_Positionstr = "pos("+column_name+", '"+arg_esq_tran.cur_data+"') > 0 "
	END IF
	arg_SetPosition = TRUE
END IF
RETURN 1




end function

event rbuttondown;String str_clickedobjecttype
String column_name,column_text_name
Long FindRow, FindPage
IF RBUTTON_SETPOSITION_USE OR rbutton_filter_use THEN
	String cur_data,ls_title
	
	str_clickedobjecttype = Lower(Left(dwo.TYPE,4))
	IF str_clickedobjecttype <> 'colu' THEN
		IF str_clickedobjecttype = 'data' THEN
			IF rbutton_filter_use THEN
				curdw_filterstr = ''
				THIS.SetFilter('')
				THIS.SetRedraw (FALSE)
				THIS.Filter()
				THIS.TriggerEvent("ue_after_filter")
				THIS.SetRedraw (TRUE)
			END IF
		END IF
		GOTO csort
	END IF
	
	s_esq_tran ls_esq_tran
	pointapi lppoint1
	column_name = dwo.Name
	
	IF getcursorpos(lppoint1) <> 0  THEN
		ls_esq_tran.X = PixelsToUnits(lppoint1.X, xpixelstounits!)
		ls_esq_tran.Y = PixelsToUnits(lppoint1.Y, ypixelstounits!)
	ELSE
		environment   exerun_env
		GetEnvironment(exerun_env )
		ls_esq_tran.X = xpos +THIS.X + ( PixelsToUnits(exerun_env.ScreenWidth, xpixelstounits!) - THIS.Width ) / 2
		ls_esq_tran.Y = ypos +THIS.Y + ( PixelsToUnits(exerun_env.ScreenHeight, xpixelstounits!) - THIS.Height) / 2.5
	END IF
	
	ls_esq_tran.cur_filter_expr = curdw_filterstr
	ls_title = THIS.Describe(column_name+ "_t.text")
	
	IF ls_title = "!" THEN ls_title = ''
	column_name = dwo.Name
	ls_esq_tran.Title = ls_title
	
	IF rbutton_filter_use THEN
		//分别处理不同类型
		CHOOSE CASE Left( THIS.Describe( dwo.Name+ ".coltype"),4)
			CASE "char"
				ls_esq_tran.cur_data = dwo.primary[row]
				If (uf_string_deal(ls_esq_tran,column_name)) = 0 THEN RETURN
			CASE "date","time"
				ls_esq_tran.dt_data = dwo.primary[row]
				If (uf_datetime_deal(ls_esq_tran,column_name)) = 0 THEN RETURN
			CASE ELSE
				ls_esq_tran.num_data = dwo.primary[row]
				If (uf_decimal_deal(ls_esq_tran,column_name)) = 0 THEN RETURN
		END CHOOSE
	ELSE
		//分别处理不同类型
		CHOOSE CASE Left( THIS.Describe( dwo.Name+ ".coltype"),4)
			CASE "char"
				ls_esq_tran.cur_data = dwo.primary[row]
				If (uf_string_deal_setp(ls_esq_tran,column_name)) = 0 THEN RETURN
		END CHOOSE
	END IF
	
	IF arg_SetPosition THEN
		
		FindRow = THIS.Find(arg_Positionstr, 1, THIS.RowCount())
//		if FindRow = row and this.rowcount( ) > row then
//			FindRow = THIS.Find(arg_Positionstr, row + 1, THIS.RowCount())
//		end if
		arg_SetPosition = FALSE
		
		IF FindRow <= 0 THEN GOTO csort
		THIS.SelectRow(0,FALSE)
		THIS.SelectRow(FindRow,TRUE)
		THIS.ScrollToRow( FindRow)
	ELSE
		THIS.SetFilter(curdw_filterstr)
		THIS.SetRedraw (FALSE)
		THIS.Filter()
		THIS.TriggerEvent("ue_after_filter")
		THIS.SetRedraw (TRUE)
	END IF
	
END IF
csort:

IF titleclick_sort_use THEN
	str_clickedobjecttype = Left(dwo.TYPE,4)
	
	IF str_clickedobjecttype = 'text' THEN
		column_text_name = dwo.Name
		
		IF Len(column_text_name) >= 3 AND Right(column_text_name,2) = '_t' THEN
			column_name = Left(column_text_name,Len(column_text_name) - 2)
		ELSE
			GOTO cend
		END IF
		
		IF Left(Describe(column_name+'.type'),4) <> 'colu' AND &
			Left(Describe(column_name+'.type'),4) <> 'comp' THEN
			RETURN
		END IF
		IF curDW_sortstr = column_name+' A ' THEN
			curDW_sortstr = column_name+' D '
		ELSE
			curDW_sortstr = column_name+' A '
		END IF
		
	ELSE
		curDW_sortstr = ''
	END IF
	
	IF curDW_sortstr <> '' THEN
		THIS.SetSort(curDW_sortstr)
		THIS.SetRedraw (FALSE)
		THIS.Sort()
		THIS.SetRedraw (TRUE)
	END IF
END IF

cend:
//IF THIS.RowCount() > 0 THEN
//	THIS.SetRow(1)
//	THIS.ScrollToRow(1)
//	THIS.SelectRow(0,FALSE)
//	THIS.SelectRow(1,TRUE)
//END IF






end event

event constructor;
// titleclick_sort_use=true  //单击标题排序-功能开关
// RBUTTON_FILTER_USE=true  //右键查询-功能开关
// setcolumn_visible_USE= true //自动保存显示列-功能开关
// autosave_setlayout_USE= true //自动保存列位置及宽度-功能开关
// RBUTTON_SETPOSITION_USE=false //右键定位功能开关

ins_INIfile_name = sys_inifilename
ins_opemp = publ_operator
cardw_empid = sys_empid
cur_DataObject = THIS.DataObject

 
end event

on u_dw_rbtnfilter2.create
end on

on u_dw_rbtnfilter2.destroy
end on

event clicked;//if titleclick_sort_use  then //and keydown(KeyControl!)
//	string str_clickedobjecttype
//	string column_name,column_text_name
//	str_clickedobjecttype=LEFT(dwo.type,4)
//
//	IF str_clickedobjecttype='text' then
//		column_text_name=dwo.name
//		if len(column_text_name)>=3 and right(column_text_name,2)='_t' then
//			column_name=left(column_text_name,len(column_text_name) - 2)
//		else
//			return
//		end if
//		if LEFT(describe(column_name+'.type'),4)<>'colu' then return
//		if curDW_sortstr=column_name+' A ' then
//			curDW_sortstr=column_name+' D '
//		else
//			curDW_sortstr=column_name+' A '
//		end if
//	
//	else
//		curDW_sortstr=''
//	END IF
//
//	if curDW_sortstr<>'' then
//		THIS.setsort(curDW_sortstr)
//		THIS.SetRedraw (false)
//		THIS.sort()
//		THIS.SetRedraw (true)
//	end if
//END IF
end event

