姓名:李小龙 性别:男 生日:1970-01-01
国家:中国 爱好:武术 特长:截拳道
作品:唐山大兄 偶像:叶问
如上:焦点现在在爱好上,如果按向上键就到性别,向下键就到偶像,向左键就到国家,向右键就到特长。
请教高人问如何实现?
Choose Case Key
Case Keyenter!
keybd_event(9,0,0,0)
keybd_event(9,0,2,0)
Return -1
Case Keyrightarrow!
send(handle(this),256,9,long(0))
Case Keyleftarrow!
Keybd_event(16,0,0,0)
Keybd_event(9,0,0,0)
Keybd_event(16,0,2,0)
Keybd_event(9,0,2,0)
Case Keydownarrow!
keybd_event(9,0,0,0)
keybd_event(9,0,2,0)
Return -1
Case Keyuparrow!
keybd_event(16,0,0,0)
keybd_event(9,0,0,0)
keybd_event(16,0,2,0)
keybd_event(9,0,2,0)
Return -1
Case Keypagedown!
Return -1
Case Keypageup!
Return -1
End Choose
我用这段代码只能实现在前后焦点之间移动。 无需考虑dddw的情况。
------解决方案--------------------
这个比较麻烦,你只能key事件里实现
choose case getcolumnname()
case '武术'
if key = Keyleftarrow! then
this.setcolumn('中国')
elseif key = Keyrightarrow! then
this.setcolumn('截拳道')
//对其它键进行处理
end if
//对其它列进行处理
end choose
注意:代码中的字符串为你数据窗口对应的列名
姓名:李小龙 性别:男 生日:1970-01-01
国家:中国 爱好:武术 特长:截拳道
作品:唐山大兄 偶像:叶问
如上:焦点现在在爱好上,如果按向上键就到性别,向下键就到偶像,向左键就到国家,向右键就到特长。
请教高人问如何实现?
------解决方案--------------------
有两个对象,一个是自定义datawindow对象uo_datawindow
一个是grid类型的数据窗口d_obj_free
PB9做的,
(1)uo_datawindow, 直接复制内容保存为 .sru格式文件,然后导入
- C/C++ code
$PBExportHeader$uo_datawindow.sruforwardglobal type uo_datawindow from datawindowend typeend forwardglobal type uo_datawindow from datawindowinteger width = 686integer height = 400string title = "none"boolean livescroll = trueborderstyle borderstyle = stylelowered!event ue_dwmousemove pbm_dwnmousemoveevent key pbm_dwnkeyend typeglobal uo_datawindow uo_datawindowtype prototypesend prototypestype variablesdatastore ids_objend variablesforward prototypespublic function string of_describe (string as_describe, long row)public function string of_getcol (string as, string ap)end prototypesevent key;if getrow() = 0 then returnchoose case key case keyleftarrow! setcolumn(of_getcol( getcolumnname(), 'l')) case keyrightarrow! setcolumn(of_getcol( getcolumnname(), 'r')) case keyuparrow! setcolumn(of_getcol( getcolumnname(), 'u')) case keydownarrow! setcolumn(of_getcol( getcolumnname(), 'd')) case elseend chooseend eventpublic function string of_describe (string as_describe, long row);//========================================================================================================================// 取得数据窗口的describe值,兼容带表达式的列//========================================================================================================================string lsstring str_returnint li_typestr_return = this.describe(as_describe)if pos(str_return, "~t") < 1 then return str_returnif left(str_return, 1) = '"' or left(str_return, 1) = "'" then str_return = mid(str_return, 2) if right(str_return, 1) = '"' or right(str_return, 1) = "'" then str_return = left(str_return, len(str_return) - 1) str_return = mid(str_return, pos(str_return, "~t") + len("~t"))if row < 1 or row > this.rowcount() then row = this.getrow()if row = 0 then return ''return this.describe("evaluate(~"" + str_return + "~"," + string(row) + ")")end functionpublic function string of_getcol (string as, string ap);string ls_col, ls_filter, ls_sortlong row, row_p, ox, oy, ow, ohids_obj.setfilter("obj = '" + as + "'"); ids_obj.filter()if ids_obj.rowcount() <= 0 then return asrow = 1ox = ids_obj.getitemnumber(row, 'ox')oy = ids_obj.getitemnumber(row, 'oy')ow = ids_obj.getitemnumber(row, 'ow')oh = ids_obj.getitemnumber(row, 'oh')choose case ap case 'l' ls_filter = "obj <> '" + as + "' and ( (ox < " + string(ox) + " and oy < " + string(oy + oh) + ") or ((oy + oh) < " + string(oy) + "))" ls_sort = "(oy + oh) desc, (ox + ow) desc" case 'r' ls_filter = "obj <> '" + as + "' and ( (ox > " + string(ox) + " and oy >= " + string(oy) + ") or (oy > " + string(oy + oh) + "))" ls_sort = "(oy + oh) asc, (ox + ow) asc" case 'u' ls_filter = "obj <> '" + as + "' and ((oy + oh) <= " + string(oy) + ") " ls_sort = "abs(ox + ow / 2 - " + string(ox + ow / 2) + ") asc, (oy + oh) desc" case 'd' ls_filter = "obj <> '" + as + "' and (oy >= " + string(oy + oh) + ") " ls_sort = "abs(ox + ow / 2 - " + string(ox + ow / 2) + ") asc, (oy + oh) asc" case else return asend chooseids_obj.setfilter(ls_filter) ; ids_obj.filter()if ids_obj.rowcount() = 0 then return asids_obj.setsort(ls_sort); ids_obj.sort()row = 0do while true row ++ ls_col = ids_obj.getitemstring(row, 'obj') if of_describe(ls_col + ".visible", getrow()) = '0' then continue //该行的该单元格不可见,则取下一个 if of_describe(ls_col + ".protect", getrow()) = '1' then continue //该行的该单元格被保护,则取下一个 return ls_colloopreturn asend functionon uo_datawindow.createend onon uo_datawindow.destroyend onevent constructor;ids_obj = create datastoreids_obj.dataobject = 'd_obj_free'int listring ls_objects, ls_collong ll_detail_height, rowll_detail_height = long(describe("datawindow.detail.height"))ls_objects = Object.DataWindow.Objects + '~t'ids_obj.reset()do while true li = pos(ls_objects, '~t') if li <= 0 then exit ls_col = left(ls_objects, li - 1) ls_objects = mid(ls_objects, li + 1) if ls_col = '' then continue //取出来的列为空,则继续 if lower(describe(ls_col + ".band")) <> 'detail' then continue //非detail的不要 if lower(describe(ls_col + ".type")) <> 'column' then continue //非column的不要 if long (describe(ls_col + ".TabSequence")) <= 0 then continue //非可获得焦点的不要 if long (describe(ls_col + ".protect")) = 1 then continue //被保护的不要 if lower(describe(ls_col + ".visible")) = '0' then continue //不可见的不要 if long (of_describe(ls_col + ".y", 1)) + long (of_describe(ls_col + ".height", 1)) > ll_detail_height then continue //detail高度以外的不要 row = ids_obj.insertrow(0) ids_obj.setitem(row, 'obj', ls_col) ids_obj.setitem(row, 'ox', long (of_describe(ls_col + ".x", 1))) ids_obj.setitem(row, 'oy', long (of_describe(ls_col + ".y", 1))) ids_obj.setitem(row, 'ow', long (of_describe(ls_col + ".width", 1))) ids_obj.setitem(row, 'oh', long (of_describe(ls_col + ".height", 1)))loopids_obj.saveas("e:\a.xls", excel!, true)end eventevent destructor;if isvalid(ids_obj) then destroy ids_objend event