$PBExportHeader$us_fncpwrtree.sru forward global type us_fncpwrtree from treeview end type end forward global type us_fncpwrtree from treeview integer width = 919 integer height = 940 integer textsize = -12 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Arial" long textcolor = 33554432 borderstyle borderstyle = stylelowered! boolean fullrowselect = true long picturemaskcolor = 536870912 long statepicturemaskcolor = 536870912 event ue_tree_add_bro ( ) event ue_tree_add_son ( ) event ue_tree_del ( ) event ue_tree_edit ( ) event ue_build_tree_fnc ( ) end type global us_fncpwrtree us_fncpwrtree type variables long il_handle,ol_deep end variables forward prototypes public function integer pf_treegrowth (long arg_handl, long arg_funcid, integer arg_lp, integer arg_showtype) end prototypes event ue_tree_add_bro();if not il_handle>0 then return s_sys_func_parm s_sfp treeviewitem tvi this.getitem(il_handle,tvi) s_sfp.sfunc=tvi.data s_sfp.opflag=1 // add brother openwithparm(w_mftree_add,s_sfp) s_sfp=message.powerobjectparm if s_sfp.opflag=0 then return // 取消 LONG ll_getitem,ll_newhandle,ll_pahandle TreeViewItem ltvi_Item,ltvi_PaItem IF il_handle>0 THEN ll_getitem=this.GetItem(il_handle, ltvi_Item) IF ll_getitem>0 THEN //得到父项, ll_pahandle=FindItem(ParentTreeItem!, il_handle) IF ll_pahandle<0 THEN ll_pahandle=0 ltvi_Item.label=s_sfp.sfunc.treename ltvi_Item.Data = s_sfp.sfunc ltvi_Item.PictureIndex = 6 // ltvi_Item.SelectedPictureIndex = 5 ll_newhandle=this.InsertItemlast(ll_pahandle,ltvi_Item) this.GetItem(ll_newhandle, ltvi_Item) this.ExpandItem(ll_pahandle) //this.editlabel(ll_newhandle) il_handle=0 END IF END IF end event event ue_tree_add_son();if not il_handle>0 then return s_sys_func_parm s_sfp treeviewitem tvi this.getitem(il_handle,tvi) s_sfp.sfunc=tvi.data s_sfp.opflag=2 // add son openwithparm(w_mftree_add,s_sfp) s_sfp=message.powerobjectparm if s_sfp.opflag=0 then return // 取消 LONG ll_getitem,ll_newhandle TreeViewItem ltvi_Item IF il_handle>0 THEN ll_getitem=this.GetItem(il_handle, ltvi_Item) IF ll_getitem>0 THEN //ltvi_Item.children=true ltvi_Item.label=s_sfp.sfunc.treename ltvi_Item.Data = s_sfp.sfunc ltvi_Item.PictureIndex = 6 ltvi_Item.SelectedPictureIndex = 5 ll_newhandle=this.InsertItemlast(il_handle,ltvi_Item) this.ExpandItem(il_handle) //this.editlabel(ll_newhandle) il_handle=0 END IF END IF end event event ue_tree_del(); LONG ll_getitem TreeViewItem ltvi_Item uo_sys_funcpwr uo_sfp s_sys_func s_sf_ls //SetRedraw(FALSE) IF il_handle>0 THEN ll_getitem=this.GetItem(il_handle, ltvi_Item) IF ll_getitem>0 THEN IF MessageBox ("警告","是否确定要删除当前结点?("+trim(ltvi_Item.label )+")",Question!,YesNo! ) = 2 THEN RETURN s_sf_ls=ltvi_Item.data uo_sfp.del(s_sf_ls.funcid ) This.deleteitem(il_handle) il_handle=0 END IF END IF //SetRedraw(TRUE) end event event ue_tree_edit();if not il_handle>0 then return s_sys_func_parm s_sfp treeviewitem tvi this.getitem(il_handle,tvi) s_sfp.sfunc=tvi.data s_sfp.opflag=3 // add son openwithparm(w_mftree_add,s_sfp) s_sfp=message.powerobjectparm if s_sfp.opflag=0 then return // 取消 LONG ll_getitem TreeViewItem ltvi_Item IF il_handle>0 THEN ll_getitem=this.GetItem(il_handle, ltvi_Item) IF ll_getitem>0 THEN ltvi_Item.label=s_sfp.sfunc.treename ltvi_Item.data=s_sfp.sfunc ll_getitem=this.setItem(il_handle, ltvi_Item) il_handle=0 END IF END IF end event event ue_build_tree_fnc();//==================================================================== // Function: wf_build_functree() //-------------------------------------------------------------------- // Description: //-------------------------------------------------------------------- // Arguments:(None) //-------------------------------------------------------------------- // Returns: integer //-------------------------------------------------------------------- // Author: yyx Date: 2004.11.16 //-------------------------------------------------------------------- // Modify History: // //==================================================================== long hand,ll_getitem ol_deep=1 s_sys_func s_sf_ls treeviewitem ltvi_Item long tvi_hdl = 0 do until this.finditem(roottreeitem!, 0) = -1 this.deleteitem(tvi_hdl) loop hand=this.insertitemlast(0,sys_message_title,1) ll_getitem=this.GetItem(hand, ltvi_Item) IF ll_getitem>0 THEN ltvi_Item.data=s_sf_ls this.setitem( hand, ltvi_Item) END IF pf_treegrowth(hand,0,2,1) this.expanditem(hand) //return 1 end event public function integer pf_treegrowth (long arg_handl, long arg_funcid, integer arg_lp, integer arg_showtype);int rslt = 1 s_sys_func ls_s_func[] long count=0,ls_i long handl string ls_power_str long ll_hand treeviewitem tvi ol_deep++ if ol_deep>5000 then //防止死递归 return 0 end if for ls_i = 1 to sys_ds_funcinfo.rowcount( ) if sys_ds_funcinfo.object.if_use[ls_i] = 0 then continue if sys_ds_funcinfo.object.functype[ls_i] <= 9 then if sys_ds_funcinfo.object.parentid[ls_i] = arg_funcid then count++ ls_s_func[count].funcid = sys_ds_funcinfo.object.funcid[ls_i] ls_s_func[count].treename = sys_ds_funcinfo.object.treename[ls_i] ls_s_func[count].menuname = sys_ds_funcinfo.object.menuname[ls_i] ls_s_func[count].parentid = sys_ds_funcinfo.object.parentid[ls_i] ls_s_func[count].sortflag = sys_ds_funcinfo.object.sortflag[ls_i] ls_s_func[count].functype = sys_ds_funcinfo.object.functype[ls_i] ls_s_func[count].mainid = sys_ds_funcinfo.object.mainid[ls_i] ls_s_func[count].if_use = sys_ds_funcinfo.object.if_use[ls_i] ls_s_func[count].worktype= sys_ds_funcinfo.object.worktype[ls_i] end if end if next for ls_i=1 to count handl=this.insertitemlast(arg_handl,ls_s_func[ls_i].treename,ls_s_func[ls_i].functype) //生成树 //'['+string(ls_s_func[ls_i].mainid)+']' this.getitem(handl,tvi) tvi.data=ls_s_func[ls_i] this.setitem( handl, tvi) //this.expanditem(arg_handl) pf_treegrowth(handl,ls_s_func[ls_i].funcid,arg_lp+1,arg_showtype) //下级生成树 next return rslt end function on us_fncpwrtree.create end on on us_fncpwrtree.destroy end on event rightclicked; IF Handle<=0 THEN RETURN il_handle=handle m_popup om_1 om_1=CREATE m_popup //把菜单的anyobject指向被右击的对象(dw_1) om_1.anyobject=this //om_1.setmenuitem("添加子项|添加兄弟|编辑|-|删除") //可在此调用om_1.setitemdisable(itemorder)函数disable某菜单项。 om_1.popupmenu(this.x+this.pointerx(),this.y+this.pointery()) destroy om_1 end event event doubleclicked;long ll_hand,mainid treeviewitem tvi string ls_tv_label s_sys_func s_lss ll_hand=this.finditem(CurrentTreeItem!,0) this.getitem(ll_hand,tvi) s_lss=tvi.data mainid=s_lss.mainid if mainid>0 then f_sys_main(mainid) return 1 end if end event