<bdo id='NWZt5'></bdo><ul id='NWZt5'></ul>
  • <i id='NWZt5'><tr id='NWZt5'><dt id='NWZt5'><q id='NWZt5'><span id='NWZt5'><b id='NWZt5'><form id='NWZt5'><ins id='NWZt5'></ins><ul id='NWZt5'></ul><sub id='NWZt5'></sub></form><legend id='NWZt5'></legend><bdo id='NWZt5'><pre id='NWZt5'><center id='NWZt5'></center></pre></bdo></b><th id='NWZt5'></th></span></q></dt></tr></i><div id='NWZt5'><tfoot id='NWZt5'></tfoot><dl id='NWZt5'><fieldset id='NWZt5'></fieldset></dl></div>

    <legend id='NWZt5'><style id='NWZt5'><dir id='NWZt5'><q id='NWZt5'></q></dir></style></legend>

    1. <small id='NWZt5'></small><noframes id='NWZt5'>

      1. <tfoot id='NWZt5'></tfoot>

        使 DHTMLEd 控件用弯引号替换直引号的代码

        时间:2023-10-02

          <tbody id='itxtV'></tbody>
            <legend id='itxtV'><style id='itxtV'><dir id='itxtV'><q id='itxtV'></q></dir></style></legend>

            <small id='itxtV'></small><noframes id='itxtV'>

              <bdo id='itxtV'></bdo><ul id='itxtV'></ul>
              <tfoot id='itxtV'></tfoot>

                • <i id='itxtV'><tr id='itxtV'><dt id='itxtV'><q id='itxtV'><span id='itxtV'><b id='itxtV'><form id='itxtV'><ins id='itxtV'></ins><ul id='itxtV'></ul><sub id='itxtV'></sub></form><legend id='itxtV'></legend><bdo id='itxtV'><pre id='itxtV'><center id='itxtV'></center></pre></bdo></b><th id='itxtV'></th></span></q></dt></tr></i><div id='itxtV'><tfoot id='itxtV'></tfoot><dl id='itxtV'><fieldset id='itxtV'></fieldset></dl></div>
                  本文介绍了使 DHTMLEd 控件用弯引号替换直引号的代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个旧的、遗留的 VB6 应用程序,它使用 DHTML 编辑控件作为 HTML 编辑器.Microsoft DHTML 编辑控件,又名 DHTMLEd,可能只不过是一个在内部使用 IE 自己的本机编辑功能的 IE 控件.

                  I've got an old, legacy VB6 application that uses the DHTML editing control as an HTML editor. The Microsoft DHTML editing control, a.k.a. DHTMLEd, is probably nothing more than an IE control using IE's own native editing capability internally.

                  我想修改应用程序以实现 Word 等智能引号.具体来说," 被替换为 " 并且 ' 被替换为 '> 或 ' 视输入而定;如果用户在替换后立即按下 Ctrl+Z,它会恢复为直引号.

                  I'd like to modify the app to implement smart quotes like Word. Specifically, " is replaced with " or " and ' is replaced with or as appropriate as it is typed; and if the user presses Ctrl+Z immediately after the replacement, it goes back to being a straight quote.

                  有人有这样的代码吗?

                  如果你没有 DHTML/VB6 的代码,但有在带有 contentEditable 区域的浏览器中工作的 JavaScript 代码,我也可以使用它

                  推荐答案

                  这是VB6版本:

                  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) <> 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 <> " ") And (ch <> "")
                  
                  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
                  

                  注意:此解决方案在撤消链中插入了一个附加级别.例如,键入This is a test"会给出This is a test"->This is a test"-> This is a test -> ->"的链(额外水平粗体).要删除这个额外的级别,您必须实现某种不涉及取消本机按键的 PostMessage+subclassing 解决方案

                  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" -> "This is a test -> " -> " (extra level in bold). To remove this extra level you'd have to implement some sort of PostMessage+subclassing solution that doesn't involve cancelling the native keypress

                  不要忘记包含 DHTML 编辑控件可再发行,如果您的目标是 Windows Vista.

                  edit: Don't forget to include the DHTML Editing Control redistributable if you are targeting Windows Vista.

                  这篇关于使 DHTMLEd 控件用弯引号替换直引号的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何将一个div的内容克隆到另一个div 下一篇:单击 webbrowser html 页面中的链接时显示 VB6 表单

                  相关文章

                  <legend id='qjYbZ'><style id='qjYbZ'><dir id='qjYbZ'><q id='qjYbZ'></q></dir></style></legend>

                  • <bdo id='qjYbZ'></bdo><ul id='qjYbZ'></ul>

                  <small id='qjYbZ'></small><noframes id='qjYbZ'>

                    1. <tfoot id='qjYbZ'></tfoot>
                      <i id='qjYbZ'><tr id='qjYbZ'><dt id='qjYbZ'><q id='qjYbZ'><span id='qjYbZ'><b id='qjYbZ'><form id='qjYbZ'><ins id='qjYbZ'></ins><ul id='qjYbZ'></ul><sub id='qjYbZ'></sub></form><legend id='qjYbZ'></legend><bdo id='qjYbZ'><pre id='qjYbZ'><center id='qjYbZ'></center></pre></bdo></b><th id='qjYbZ'></th></span></q></dt></tr></i><div id='qjYbZ'><tfoot id='qjYbZ'></tfoot><dl id='qjYbZ'><fieldset id='qjYbZ'></fieldset></dl></div>