Windows窗体自定义控件:没有UIPermissionWindow.AllWindows的焦点和光标键 [英] Windows Forms custom control: focus and cursor keys without UIPermissionWindow.AllWindows
问题描述
我想为Windows Forms编写一个自定义控件(一个文本编辑器),它应该包含以下功能:
UIPermissionWindow.SafeTopLevelWindows
(即它不应该需要 UIPermissionWindow.AllWindows
)运行在半可信环境中。 / li>
有没有这样做的例子?
有些方法我可能想要使用像 Control.Focus()
和 Control.InInputKey()
,require UIPermissionWindow.AllWindows
。
是否有任何其他方式来获取/实现功能,而不使用这些方法? b
$ b
内置的TextBox控件具有此功能(获取焦点并处理光标键)。
继承文本框
私人小组UserControl1_GotFocus(BYVAL发件人作为对象,BYVAL e作为System.EventArgs)处理我。 GotFocus
End Sub
Private Sub UserControl1_KeyDown(ByVal sender As Object,ByVal e As System.Windows.Forms.KeyEventArgs)处理Me.KeyDown
Debug.WriteLine (downed)
Debug.WriteLine(e.KeyValue)
Debug.WriteLine(e.KeyCode)
End Sub
Private Sub UserControl1_KeyPress (ByVal sender As Object,ByVal e As System.Windows.Forms.KeyPressEventArgs)处理Me.KeyPress
Debug.WriteLine(pressed)
Debug.WriteLine(e.KeyChar)
End Sub
End Class
I want to write a custom control (a text editor) for Windows Forms, which should include the following functionality:
- Gets the keyboard focus, when you click on it with the mouse
- Sees all keyboard input (including cursor keys), when it has the focus,
- Can run in a semi-trusted environment, with
UIPermissionWindow.SafeTopLevelWindows
(i.e. it shouldn't requireUIPermissionWindow.AllWindows
)
Is there any example of doing this?
Some of the methods which I might want to use, like Control.Focus()
and Control.InInputKey()
, require UIPermissionWindow.AllWindows
.
Is there any other way to get/implement the functionality, without using these methods?
The built-in TextBox control has this functionality (gets the focus and handles cursor keys).
Public Class UserControl1
Inherits TextBox
Private Sub UserControl1_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.GotFocus
End Sub
Private Sub UserControl1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
Debug.WriteLine("downed")
Debug.WriteLine(e.KeyValue)
Debug.WriteLine(e.KeyCode)
End Sub
Private Sub UserControl1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Me.KeyPress
Debug.WriteLine("pressed")
Debug.WriteLine(e.KeyChar)
End Sub
End Class
这篇关于Windows窗体自定义控件:没有UIPermissionWindow.AllWindows的焦点和光标键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!