马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
本帖最后由 yxpxa 于 2013-6-23 05:43 编辑
OpenDCL没有右键菜单,我用按钮控件简单组合了一个,按照这个方法,窗口顶部的下拉菜单也能模拟出来,甚至比右键菜单简单些,不需提取x y坐标。这是在我的 dtx 文本编辑里已实现的,现发布出来请大家提提意见。
![](source/plugin/imc_colorcode/images/loading.gif)
- ;;OpenDCL右键菜单的实现
- ;;原创,小蜜蜂,小东空间,2013-6-23
- (defun c:rmenu( / ssr lt)
- (setq ssr "Rmenu_Form1_RightMneu" Lt '("1" "2" "3" "4" "5") ;;5个菜单控件,不够可以加
- *Namecap* '("菜单1" "背景-蓝色" "背景-红色" "背景-青色" "退出")
- *ss-rigthmenu* (mapcar '(lambda(x)(strcat ssr x)) Lt))
- (dcl_Project_Load "Rmenu.odcl" t)
- (dcl_Form_Show Rmenu_Form1)
- (princ)
- )
- ;;初始化窗口
- (defun c:Rmenu_Form1_OnInitialize (/)
- (setq *RM-ent* (mapcar '(lambda(x)(eval (read x))) *ss-rigthmenu*)) ;;控件数组
- (Def_Clicked_Fun)
- (move_mouse_color)
- )
- (defun c:Rmenu_Form1_PictureBox1_OnRightClick (/)
- (show_hidee_cs t)
- (right_menue_pos *x^_^x* *y$$$$_$$$$Y*)
- )
- (defun c:Rmenu_Form1_PictureBox1_OnMouseMove (Flags X Y /)(setq *x^_^x* x *y$$$$_$$$$Y* y))
- (defun c:Rmenu_Form1_PictureBox1_OnClicked (/)(show_hidee_cs nil))
- ;;设置菜单显示的位置
- (defun right_menue_pos(x y)
- (setq D (- y 23)) ;;23为每条菜单的高度
- (foreach a (mapcar 'cons *RM-ent* *Namecap*)
- (dcl_Control_SetPos (car a) x (setq d (+ d 23)))
- (dcl_Control_SetCaption (car a) (cdr a)))
- )
- ;;定义菜单单击事件
- (defun Def_Clicked_Fun( / dcf)
- (setq dcf '("fun1" "fun2" "fun3" "fun4" "fun5")) ;;单击响应函数列表
- (foreach x (mapcar 'cons *ss-rigthmenu* dcf)
- (eval (read (strcat "(defun c:" (car x) "_OnClicked (/)"
- "(" (cdr x) " (dcl_Control_GetCaption " (car x) ")))"))))
- )
- ;;定义鼠标滑过菜单的高亮显示
- (defun move_mouse_color()
- (foreach x *ss-rigthmenu*
- (eval (read (strcat "(defun c:" x "_OnMouseMove (Flags X Y / xxLt)"
- "(setq xxLt (mapcar '(lambda(y)(list y -16 -19)) (vl-remove "" x "" *ss-rigthmenu*))"
- " xxLt (cons (list "" x "" -3 -16) xxLt))"
- "(foreach y xxLt "
- "(dcl_Control_SetBackColor (eval (read (car y))) (cadr y))"
- "(dcl_Control_SetForeColor (eval (read (car y))) (caddr y))))"))))
- )
- ;;菜单的切换显示
- (defun show_hidee_cs(c)
- (foreach x *RM-ent* (dcl_Control_SetVisible x c))
- )
- ;;调用自定义函数
- (defun fun1( ss )
- (show_hidee_cs nil)
- (dcl_MessageBox (strcat "你点击了 " ss " ") "提示" 2 2)
- )
- (defun fun2( ss )
- (show_hidee_cs nil)
- (dcl_Control_SetBackColor Rmenu_Form1_PictureBox1 5)
- )
- (defun fun3( ss )
- (show_hidee_cs nil)
- (dcl_Control_SetBackColor Rmenu_Form1_PictureBox1 1)
- )
- (defun fun4( ss )
- (show_hidee_cs nil)
- (dcl_Control_SetBackColor Rmenu_Form1_PictureBox1 4)
- )
- (defun fun5( ss )
- (dcl_Form_Close Rmenu_Form1)
- )
源码共享如下:
|