窗口open event:
long i, num, j, row
string s, ls_tmp, ss, ls_object[]
//1 取得当前数据窗口列属性:列名 可见属性 缺省宽度
s = idw_source.describe('datawindow.objects')
num = f_depart_string(s, '~t', ls_object)
if num =0 then return messagebox('失败','没有取得任何备用列!')
j =0
for i = 1 to num
ls_tmp = ls_object[i]
s = idw_source. describe(ls_tmp +'.type')
if s <>'column' and left(lower(s),5)<>lower('Compu') then continue
//get column name
s = idw_source. describe(ls_tmp +'_t.text')
if s ='?' or s ='!' then continue//s ='无中文列名字段'
j ++
colname_eng[j] = ls_tmp
colname_chi[j] = s
//visible now?
ss = idw_source.describe(ls_tmp+'.visible')
col_visible [j] = ss
ss = idw_source.describe(ls_tmp+'.width')
if long(ss)= 0 then col_visible[j] ='0'
if ss ='0' then debugbreak()
//default width
col_width[j] = integer(ss)
if ss ='0' then
ss = idw_source.describe(ls_tmp +'.tag')
if not(ss ='?' or ss ='!') then
ss = mid( ss, pos(ss, WIDTH_FLAG) +len(WIDTH_FLAG) )
col_width[j] = long(ss)
end if
end if
if col_width[j]< 1 then col_width [j] = 200
next
//2 将列属性填入备选列表
if j < 1 then return
for i = 1 to j
row = dw_1.insertRow(0)
dw_1.object.visible[row] = long(col_visible[i])
dw_1.object.visible_pre[row] = long(col_visible[i])
dw_1.object.colname_eng[row] = colname_eng[i]
dw_1.object.colname_chi[row] = (colname_chi[i])
next
//确定按钮事件:确认选择的栏后的处理
long i, num
long ll_width
string ls_visible, ls_visible_pre, ls_col, ls_width, ls_tmp
num = dw_1.rowcount()
//根据设置情况,动态修改数据窗口列宽度
for i = 1 to num
ls_col = dw_1.object .colname_eng[i]
ls_visible = string(dw_1.object .visible[i])
ls_visible_pre = string(dw_1.object .visible_pre[i])
ls_width = string(col_width[i])
if ls_visible = ls_visible_pre then continue
if ls_visible ='0' then
//保存原宽度至TAG
ls_tmp = idw_source.describe( ls_col+'.tag')
if ls_tmp ='?' then ls_tmp =''
if pos(ls_tmp, WIDTH_FLAG) =0 then ls_tmp += WIDTH_FLAG + ls_width
idw_source.modify(ls_col+'.tag="'+ls_tmp+'"')
//修改宽度->0
idw_source.modify(ls_col+'.width=0')
idw_source.modify(colname_chi[i]+ '.width=0')
elseif ls_visible ='1' then
idw_source.modify(ls_col+'.width="'+ls_width+'""~t'+ ls_col+'.visible="1"')
idw_source.modify(colname_chi[i]+'.x="'+idw_source.describe(ls_col+'.x')+'"~t'+colname_chi[i]+ '.width="'+ls_width+'"~t'+ colname_chi[i]+'.visible="1"')
end if
//
next
int p, i
string ls_str, ls_name, ls_type
//instance varible datawindow dw_param
dw_param = message.PowerObjectParm
ls_str = dw_param.Describe("DataWindow.Objects")
do while true
p = Pos(ls_str, ' ')
if p = 0 then exit
ls_name = left(ls_str, p - 1)
ls_str = Replace(ls_str, 1, p, '') //delete the tab character found and all before it
ls_type = dw_param.Describe(ls_name + ".type")
if ls_type = "text" then
i = dw_col.InsertRow(0)
dw_col.SetItem(i, "col_name", ls_name)
dw_col.SetItem(i, "col_x", dw_param.Describe(ls_name + ".X"))
dw_col.SetItem(i, "col_label", dw_param.Describe(ls_name + ".Text"))
else
if ls_type = "column" then
i = dw_ref.InsertRow(0)
dw_ref.SetItem(i, "col_name", ls_name)
dw_ref.SetItem(i, "col_x", dw_param.Describe(ls_name + ".X"))
end if
end if
loop
dw_col.SetSort("col_x A, col_name A")
dw_col.Sort()
dw_ref.SetSort("col_x A, col_name A")
dw_ref.Sort()
//todo: set col_check=1 in dw_col if dw_ref.<col_name>.visible=false