Friday, 15 May 2015

vb.net - Control KeyDown Event Trap CTRL-C etc -



vb.net - Control KeyDown Event Trap CTRL-C etc -

i'm having problem processing ctrl-c, ctrl-v, ctrl-x on form.

private function handlekeydown(sender object, e keyeventargs, byval vshow string) boolean handlekeydown = false if e.keycode = keys.f1 help.showpopup(me, vshow, cursor.position) end if if e.keycode = keys.c andalso e.modifiers = keys.control sender.copy() elseif e.keycode = keys.v andalso e.modifiers = keys.control sender.paste() elseif e.keycode = keys.x andalso e.modifiers = keys.control sender.cut() else console.writeline(string.format("modifiers:{0} keycode:{1} keydata:{2} keyvalue:{3} ", e.modifiers.tostring, e.keycode.tostring, e.keydata.tostring, e.keyvalue.tostring)) end if handlekeydown = true end function

the keydown event never picks sec key. value keycode ever seems hold keys.control. console.writeline outputs ctrl-c

modifiers:control keycode:controlkey keydata:controlkey, command keyvalue:17

where going wrong?

are calling actual event handler? had add together "handles mybase.keydown" , remove parameter.

private sub handlekeydown(byval sender object, byval e keyeventargs) handles mybase.keydown 'handlekeydown = false if e.keycode = keys.c andalso e.modifiers = keys.control messagebox.show(string.format("modifiers:{0} --- keycode:{1} --- keydata:{2} --- keyvalue:{3} ", e.modifiers.tostring, e.keycode.tostring, e.keydata.tostring, e.keyvalue.tostring)) 'sender.copy() elseif e.keycode = keys.v andalso e.modifiers = keys.control messagebox.show(string.format("modifiers:{0} --- keycode:{1} --- keydata:{2} --- keyvalue:{3} ", e.modifiers.tostring, e.keycode.tostring, e.keydata.tostring, e.keyvalue.tostring)) 'sender.paste() elseif e.keycode = keys.x andalso e.modifiers = keys.control messagebox.show(string.format("modifiers:{0} --- keycode:{1} --- keydata:{2} --- keyvalue:{3} ", e.modifiers.tostring, e.keycode.tostring, e.keydata.tostring, e.keyvalue.tostring)) 'sender.cut() end if 'handlekeydown = true end sub

it's working me. value of 88, 67, , 86 respectively.

vb.net forms control

No comments:

Post a Comment