Add hotkey Ctrl+B

[Top]  [Chapter]  [Previous]  [Next]

We want to use CtrlB to toggle the attribute 'bold'

 

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

 

The following values are supported by ToggleStyle and IncludeStyle:

 

WPWRT_BOLD = 0 ' Bit 1 bold

WPWRT_ITALIC = 1 ' Bit 2 italic

WPWRT_UNDERLINE = 2 ' Bit 3 underlined (solod)

WPWRT_STRIKEOUT = 3 ' Bit 4 strikeout

WPWRT_SUPERSCRIPT = 4 ' Bit 5 superscript

WPWRT_SUBSCRIPT = 5 ' Bit 6 subscript

WPWRT_HIDDEN = 6 ' Bit 7 hidden text

WPWRT_UPPERCASE = 7 ' Bit 8 all uppercase

WPWRT_LOWERCASE = 9 ' Bit 10 all lowercase

 

Please use this links to learn more about the features of "TextCursor" and "CurrAttr".


[addhotkeyctrlb.htm]    Copyright © 2007 by WPCubed GmbH