• <tfoot id='ej9Lw'></tfoot>

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

          <bdo id='ej9Lw'></bdo><ul id='ej9Lw'></ul>

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

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

        检测何时显示 TextBox 自动完成列表

        时间:2023-06-08
      1. <small id='Bqa9U'></small><noframes id='Bqa9U'>

        1. <legend id='Bqa9U'><style id='Bqa9U'><dir id='Bqa9U'><q id='Bqa9U'></q></dir></style></legend>

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

                <tbody id='Bqa9U'></tbody>
                <i id='Bqa9U'><tr id='Bqa9U'><dt id='Bqa9U'><q id='Bqa9U'><span id='Bqa9U'><b id='Bqa9U'><form id='Bqa9U'><ins id='Bqa9U'></ins><ul id='Bqa9U'></ul><sub id='Bqa9U'></sub></form><legend id='Bqa9U'></legend><bdo id='Bqa9U'><pre id='Bqa9U'><center id='Bqa9U'></center></pre></bdo></b><th id='Bqa9U'></th></span></q></dt></tr></i><div id='Bqa9U'><tfoot id='Bqa9U'></tfoot><dl id='Bqa9U'><fieldset id='Bqa9U'></fieldset></dl></div>
                  本文介绍了检测何时显示 TextBox 自动完成列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有 TextBox 控件和关联的计时器,它们在每个 KeyDownMouseClick 事件上重新启动,并在 3 秒后根据键入的文本执行查询没有那些事件.到目前为止一切顺利.

                  I have TextBox controls and associated Timers that restarts on each KeyDown or MouseClick event, and performs queries based on typed text after 3 seconds without those events. So far so good.

                  但我的一些文本框也有用户可以浏览的自动完成列表,但即使他们使用键盘箭头键,计时器也不会停止,并且在用户浏览列表的过程中会触发意外查询.

                  But some of my TextBoxes also have AutoComplete lists which user can browse in, but even if they do using keyboard arrow keys, timer is not halted and an unexpected query is fired in the middle of user browsing the list.

                  问题:有没有办法检测自动完成列表何时显示,以便我可以暂停计时器或忽略它的滴答声?

                  Question: is there a way of detecting when autocomplete list is showing, so that I can suspend timer or ignoring its tick?

                  非常感谢!

                  推荐答案

                  你可以使用EnumThreadWindows 查找所有自动完成的下拉窗口并检查它们是否可见.自动完成下拉窗口类名称为 Auto-Suggest Dropdown.您可以使用 GetClassName 方法获取枚举窗口的类名,然后使用 IsWindowVisible 方法检查窗口是否可见.

                  You can use EnumThreadWindows to find all auto complete dropdown windows and check if any of them is visible. The Auto-complete dropdown window class name is Auto-Suggest Dropdown. You can use GetClassName method to get class name of enumerated windows and then using IsWindowVisible method check if the window is visible.

                  示例

                  在下面的示例中,我在问题中的代码中使用了一个计时器,在计时器的滴答事件中,我检查了是否打开了一个自动完成窗口,我在标题中显示了打开"表格,否则显示关闭":

                  In below example, I used a timer like you have in your code in the question, and in tick event of the timer, I've checked if there is an auto-complete window open I showed "Open" in title of form, otherwise showed "close":

                  Delegate Function EnumThreadDelegate(hWnd As IntPtr, lParam As IntPtr) As Boolean
                  
                  <System.Runtime.InteropServices.DllImport("user32.dll")> _
                  Shared Function EnumThreadWindows(dwThreadId As Integer, _
                      lpfn As EnumThreadDelegate, lParam As IntPtr) As Boolean
                  End Function
                  
                  <System.Runtime.InteropServices.DllImport("user32.dll")> _
                  Shared Function GetClassName(ByVal hWnd As System.IntPtr,
                      lpClassName As System.Text.StringBuilder, _
                      nMaxCount As Integer) As Integer
                  End Function
                  
                  <System.Runtime.InteropServices.DllImport("kernel32.dll")> _
                  Shared Function GetCurrentThreadId() As Integer
                  End Function
                  
                  <System.Runtime.InteropServices.DllImport("user32.dll")> _
                  Shared Function IsWindowVisible(hWnd As IntPtr) As Boolean
                  End Function
                  

                  Const AutoCompleteClassName As String = "Auto-Suggest Dropdown"
                  Function EnumThreadCallback(hWnd As IntPtr, lParam As IntPtr) As Boolean
                      Dim className As New System.Text.StringBuilder("", 256)
                      GetClassName(hWnd, className, 256)
                      If className.ToString() = AutoCompleteClassName AndAlso IsWindowVisible(hWnd) Then
                          AnAutoCOmpleteIsOpen = True
                      End If
                      Return True
                  End Function
                  Dim AnAutoCOmpleteIsOpen As Boolean = False
                  Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
                      AnAutoCOmpleteIsOpen = False
                      EnumThreadWindows(GetCurrentThreadId(), _
                          New EnumThreadDelegate(AddressOf Me.EnumThreadCallback), IntPtr.Zero)
                      If (AnAutoCOmpleteIsOpen) Then
                          Me.Text = "Open"
                      Else
                          Me.Text = "Close"
                      End If
                  End Sub
                  

                  这篇关于检测何时显示 TextBox 自动完成列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:文本框中的中间按钮滚动的东西 下一篇:文本框自动完成无法正常工作

                  相关文章

                  1. <legend id='K6vbP'><style id='K6vbP'><dir id='K6vbP'><q id='K6vbP'></q></dir></style></legend>

                      <bdo id='K6vbP'></bdo><ul id='K6vbP'></ul>

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

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

                      <tfoot id='K6vbP'></tfoot>