Autocomplete text field and "Hide pointer when entering text" in windows

How to disable the "Hide pointer when entering text" application? I have a problem with hiding the cursor and not returning without pressing the Exit key or without losing the focus of the window. The application is written in C # and uses WPF. An answer to a specific technology is not required, since it is likely to be possible using any technology.

Here's the scenario: the user can enter a TextBox, and an autocomplete list is displayed below the field. Once the user starts typing, he / she can no longer select an item from the drop-down list because there is no mouse cursor.

I noticed that Firefox does not have this behavior. For example, when entering a URL in the address bar, the mouse cursor never disappears. There are other places where I have seen this behavior, so I know that this should be possible.

Any help is much appreciated!

+2
source share
2 answers

I found by setting breakpoints that when I first entered a text field, WPF reads a public property SystemParameters.MouseVanishthat calls SystemParametersInfo(SPI_GETMOUSEVANISH, ...)to set the mouse value. Subsequent calls SystemParameters.MouseVanishuse a cached value.

Two possible solutions:

  • SystemParameters.MouseVanish, , false.
  • Win32 SystemParametersInfo(SPI_SETMOUSEVANISH, ...), ( ), SystemParameters.MouseVanish, SystemParametersInfo(SPI_SETMOUSEVANISH, ...), ( )

, .

:

void LocallyDisableMouseVanish()
{
  if(SystemParameters.MouseVanish)
    foreach(var field in typeof(SystemParameters).GetFields(BindingFlags.NonPublic | BindingFlags.Static)
      if(field.Name.Contains("mouseVanish"))
        field.SetValue(null, false);
}

, , , MouseVanish . , HwndSource.AddHook WM_SETTINGCHANGE :

const int WM_SETTINGCHANGE = 26;

public void AddSettingChangeHook()
{
  _settingChangeWatcher = new HwndSource(new HwndSourceParameters("WM_SETTINGSCHANGE watcher"));
  _settingChangeWatcher.AddHook((IntPtr hwnd, IntPtr msg, IntPtr wParam, IntPtr lParam, ref bool handled) =>
  {
    if((int)msg == WM_SETTINGCHANGE)
      Dispatcher.Invoke(DispatcherPriority.Input, new Action(() =>
      {
        LocallyDisableMousePointerVanish();
      });
  });
}
+3

, win api SystemParametersInfo , ; :

SPI_GETMOUSEVANISH SPI_SETMOUSEVANISH

Vanish ​​ Windows Me Windows XP. , . , . , , .

SystemParametersInfo msdn

+1

All Articles