OnKeyPress Event |
[Top] [Chapter] [Previous] [Next] |
Member of WPDLLInt Declaration C# KeyPress(KeyPressEventArgs e)
Here the standard event is used. You need to cast e to wpKeyEventArgs which contains the properties Editor, Shift, Alt and Control:
if ((wpKeyEventArgs)e).Control) ...
Declaration OCX OnKeyPress(ByVal Editor As Long, Key As Byte)
This event is triggered when the user types on the keyboard. It receives the key as character value. You can use this event to implement short cuts, for example activate 'bold' when Ctrl+B is pressed:
Example VB6 (also see OnKeyDown):
Private Sub WPDLLInt1_OnKeyPress(ByVal Editor As Long, Key As Byte) Dim Memo As IWPMemo If Editor = 2 Then Set Memo = WPDLLInt1.Memo2 Else: Set Memo = WPDLLInt1.Memo If Key = 2 Then ' Ctrl B If Memo.TextCursor.IsSelected Then Memo.CurrSelAttr.ToggleStyle (0) Else Memo.CurrAttr.ToggleStyle (0) ' set bold! End If Key = 0 End If End Sub |