Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here's the VB6 version:</p> <pre><code>Private Sub DHTMLEdit1_onkeypress() Dim e As Object Set e = DHTMLEdit1.DOM.parentWindow.event 'Perform smart-quote replacement' Select Case e.keyCode Case 34: 'Double-Quote' e.keyCode = 0 If IsAtWordEnd Then InsertDoubleUndo ChrW$(8221), ChrW$(34) Else InsertDoubleUndo ChrW$(8220), ChrW$(34) End If Case 39: 'Single-Quote' e.keyCode = 0 If IsAtWordEnd Then InsertDoubleUndo ChrW$(8217), ChrW$(39) Else InsertDoubleUndo ChrW$(8216), ChrW$(39) End If End Select End Sub Private Function IsLetter(ByVal character As String) As Boolean IsLetter = UCase$(character) &lt;&gt; LCase$(character) End Function Private Sub InsertDoubleUndo(VisibleText As String, HiddenText As String) Dim selection As Object Set selection = DHTMLEdit1.DOM.selection.createRange() selection.Text = HiddenText selection.moveStart "character", -Len(HiddenText) selection.Text = VisibleText End Sub Private Function IsAtWordEnd() As Boolean Dim ch As String ch = PreviousChar IsAtWordEnd = (ch &lt;&gt; " ") And (ch &lt;&gt; "") End Function Private Function PreviousChar() As String Dim selection As Object Set selection = m_dom.selection.createRange() selection.moveStart "character", -1 PreviousChar = selection.Text End Function </code></pre> <p>Note: this solution inserts an additional level in the undo chain. For example, typing "This is a test" gives a chain of “This is a test” -> “This is a test" -> <strong>“This is a test</strong> -> “ -> " (extra level in bold). To remove this extra level you'd have to implement some sort of <code>PostMessage+subclassing</code> solution that doesn't involve cancelling the native keypress</p> <p>edit: Don't forget to include the <a href="http://www.microsoft.com/downloads/details.aspx?familyid=b769a4b8-48ed-41a1-8095-5a086d1937cb&amp;displaylang=en" rel="noreferrer">DHTML Editing Control redistributable</a> if you are targeting Windows Vista.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload