主题:文本框,右键功能:怎样能激活文本框的右键的剪切/复制/粘贴功能?
young66666
[专家分:0] 发布于 2006-01-02 02:40:00
文本框,右键功能:怎样能激活文本框的右键的剪切/复制/粘贴功能?
我的表单有几十个文本框,我想让用户编辑时,可以用右键剪切/复制/粘贴,不知是不是通过设文本框的属性实现?
回复列表 (共8个回复)
沙发
labxj0769 [专家分:21070] 发布于 2006-01-02 20:23:00
新建PRG文件MyRightClick.PRG:
DEFINE CLASS myhandler AS Session
PROCEDURE MyRightClick
Define POPUP EdtShort SHORTCUT RELATIVE FROM MROW(),MCOL()
Define BAR _med_undo OF EdtShort PROMPT "撤消(\<U)" ;
MESSAGE "撤消上一次命令或操作"
Define BAR 3 OF EdtShort PROMPT "\-"
Define BAR _med_cut OF EdtShort PROMPT "剪切(\<T)" ;
SKIP FOR _screen.activeform.activecontrol.sellength = 0 or !EMPTY(_screen.activeform.activecontrol.passwordchar) ;
MESSAGE "移去选定内容并将其放入剪贴板"
Define BAR _med_copy OF EdtShort PROMPT "复制(\<C)" ;
SKIP FOR _screen.activeform.activecontrol.sellength = 0 or !EMPTY(_screen.activeform.activecontrol.passwordchar) ;
MESSAGE "将选定内容复制到剪贴板上"
Define BAR _med_paste OF EdtShort PROMPT "粘贴(\<P)" ;
SKIP FOR empty(_cliptext) ;
MESSAGE "粘贴剪贴板上的内容"
Define BAR _med_clear OF EdtShort PROMPT "删除(\<D)" ;
SKIP FOR _screen.activeform.activecontrol.sellength = 0 ;
MESSAGE "移去选定内容,并且不将其放到剪贴板上"
Define BAR 8 OF EdtShort PROMPT "\-"
Define BAR _med_slcta OF EdtShort PROMPT "全选(\<A)" ;
MESSAGE "选定当前窗口中的所有文本或数据项"
Activate POPUP EdtShort
ENDDEFINE
在表单的init:
IF Thisform.ControlCount>0
PUBLIC oHandler
oHandler=NEWOBJECT("myhandler","prgrightclick.prg")
FOR i=1 TO Thisform.ControlCount
IF UPPER(Thisform.Controls(i).Class)="TEXTBOX"
BINDEVENT(Thisform.Controls(i),"RightClick",oHandler,"MyRightClick") &&动态绑定,用了公用变量传递信息
ENDIF
ENDFOR
ENDIF
板凳
dzgpy [专家分:10] 发布于 2006-01-05 08:22:00
这真是有价值的好东东,值得大家好好学习
3 楼
dzgpy [专家分:10] 发布于 2006-01-05 08:26:00
一个字
**** **
** **************
** **
** ** **
************** **
**** ** ** **
** ** ******************
** ** **
** ** **
**** ** **
**** **
** ** **
** **** **** **
** ****
**
4 楼
ihorse [专家分:970] 发布于 2007-08-25 08:53:00
我的解决方法和二楼的不太一样。
当然,仍然需要先创建一个rightclick。prg文件,内容大致同二楼。我的调用方法是:
在每一个需要调用右键的文本框的rightclick事件中写上:
DO rightclick。prg.
这样可能制作时麻烦了点,但是很容易理解,如果你也是 像一样对什么 oHandler
之类的东东感到恐惧的话。
5 楼
zhadalou [专家分:480] 发布于 2007-09-27 21:18:00
[quote]新建PRG文件MyRightClick.PRG:
DEFINE CLASS myhandler AS Session
PROCEDURE MyRightClick
Define POPUP EdtShort SHORTCUT RELATIVE FROM MROW(),MCOL()
Define BAR _med_undo OF EdtShort PROMPT "撤消(\<U)" ;
MESSAGE "撤消上一次命令或操作"
Define BAR 3 OF EdtShort PROMPT "\-"
Define BAR _med_cut OF EdtShort PROMPT "剪切(\<T)" ;
SKIP FOR _screen.activeform.activecontrol.sellength = 0 or !EMPTY(_screen.activeform.activecontrol.passwordchar) ;
MESSAGE "移去选定内容并将其放入剪贴板"
Define BAR _med_copy OF EdtShort PROMPT "复制(\<C)" ;
SKIP FOR _screen.activeform.activecontrol.sellength = 0 or !EMPTY(_screen.activeform.activecontrol.passwordchar) ;
MESSAGE "将选定内容复制到剪贴板上"
Define BAR _med_paste OF EdtShort PROMPT "粘贴(\<P)" ;
SKIP FOR empty(_cliptext) ;
MESSAGE "粘贴剪贴板上的内容"
Define BAR _med_clear OF EdtShort PROMPT "删除(\<D)" ;
SKIP FOR _screen.activeform.activecontrol.sellength = 0 ;
MESSAGE "移去选定内容,并且不将其放到剪贴板上"
Define BAR 8 OF EdtShort PROMPT "\-"
Define BAR _med_slcta OF EdtShort PROMPT "全选(\<A)" ;
MESSAGE "选定当前窗口中的所有文本或数据项"
Activate POPUP EdtShort
ENDDEFINE
在表单的init:
IF Thisform.ControlCount>0
PUBLIC oHandler
oHandler=NEWOBJECT("myhandler","prgrightclick.prg")
FOR i=1 TO Thisform.ControlCount
IF UPPER(Thisform.Controls(i).Class)="TEXTBOX"
BINDEVENT(Thisform.Controls(i),"RightClick",oHandler,"MyRightClick") &&动态绑定,用了公用变量传递信息
ENDIF
ENDFOR
ENDIF
[/quote]
labxj0769老师:
用你的方法好像在 editbox 中不起作用。可能是我不会用。能不能告诉我,Editbox 中怎么绑定?谢谢。
6 楼
zhengxinhai [专家分:30] 发布于 2009-08-20 22:18:00
labxj0769老师:一楼代码在页框架文本框中不起作用,请问如何改一改?
7 楼
lbscyb [专家分:4780] 发布于 2009-08-22 01:48:00
[quote][quote]新建PRG文件MyRightClick.PRG:
DEFINE CLASS myhandler AS Session
PROCEDURE MyRightClick
Define POPUP EdtShort SHORTCUT RELATIVE FROM MROW(),MCOL()
Define BAR _med_undo OF EdtShort PROMPT "撤消(\<U)" ;
MESSAGE "撤消上一次命令或操作"
Define BAR 3 OF EdtShort PROMPT "\-"
Define BAR _med_cut OF EdtShort PROMPT "剪切(\<T)" ;
SKIP FOR _screen.activeform.activecontrol.sellength = 0 or !EMPTY(_screen.activeform.activecontrol.passwordchar) ;
MESSAGE "移去选定内容并将其放入剪贴板"
Define BAR _med_copy OF EdtShort PROMPT "复制(\<C)" ;
SKIP FOR _screen.activeform.activecontrol.sellength = 0 or !EMPTY(_screen.activeform.activecontrol.passwordchar) ;
MESSAGE "将选定内容复制到剪贴板上"
Define BAR _med_paste OF EdtShort PROMPT "粘贴(\<P)" ;
SKIP FOR empty(_cliptext) ;
MESSAGE "粘贴剪贴板上的内容"
Define BAR _med_clear OF EdtShort PROMPT "删除(\<D)" ;
SKIP FOR _screen.activeform.activecontrol.sellength = 0 ;
MESSAGE "移去选定内容,并且不将其放到剪贴板上"
Define BAR 8 OF EdtShort PROMPT "\-"
Define BAR _med_slcta OF EdtShort PROMPT "全选(\<A)" ;
MESSAGE "选定当前窗口中的所有文本或数据项"
Activate POPUP EdtShort
ENDDEFINE
在表单的init:
IF Thisform.ControlCount>0
PUBLIC oHandler
oHandler=NEWOBJECT("myhandler","prgrightclick.prg")
FOR i=1 TO Thisform.ControlCount
IF UPPER(Thisform.Controls(i).Class)="TEXTBOX"
BINDEVENT(Thisform.Controls(i),"RightClick",oHandler,"MyRightClick") &&动态绑定,用了公用变量传递信息
ENDIF
ENDFOR
ENDIF
[/quote]
labxj0769老师:
用你的方法好像在 editbox 中不起作用。可能是我不会用。能不能告诉我,Editbox 中怎么绑定?谢谢。[/quote]
在表单的init:
IF Thisform.ControlCount>0
PUBLIC oHandler
oHandler=NEWOBJECT("myhandler","prgrightclick.prg")
FOR i=1 TO Thisform.ControlCount
IF UPPER(Thisform.Controls(i).Class)="TEXTBOX" && 改成 UPPER(Thisform.Controls(i).Class) $ "TEXTBOXEDITBOX"
BINDEVENT(Thisform.Controls(i),"RightClick",oHandler,"MyRightClick") &&动态绑定,用了公用变量传递信息
ENDIF
ENDFOR
ENDIF
8 楼
zhengxinhai [专家分:30] 发布于 2009-08-22 22:00:00
用labxj0769老师:一楼的经典代码用在页框架文本框中,其中有的表单运行良好,而有的使用快捷菜单后,表单最小化,连编后,快捷菜单正常没有反映,请问各位怎样处理呢?
我来回复